mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-25 15:52:13 +00:00
feat: add account info parsers
This commit is contained in:
18
src/parser/classes/AccountChannel.ts
Normal file
18
src/parser/classes/AccountChannel.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import Text from './misc/Text';
|
||||
import NavigationEndpoint from './NavigationEndpoint';
|
||||
import { YTNode } from '../helpers';
|
||||
|
||||
class AccountChannel extends YTNode {
|
||||
static type = 'AccountChannel';
|
||||
|
||||
title: Text;
|
||||
endpoint: NavigationEndpoint;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.title = new Text(data.title);
|
||||
this.endpoint = new NavigationEndpoint(data.navigationEndpoint);
|
||||
}
|
||||
}
|
||||
|
||||
export default AccountChannel;
|
||||
45
src/parser/classes/AccountItemSection.ts
Normal file
45
src/parser/classes/AccountItemSection.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import Parser from '..';
|
||||
|
||||
import Text from './misc/Text';
|
||||
import Thumbnail from './misc/Thumbnail';
|
||||
import NavigationEndpoint from './NavigationEndpoint';
|
||||
import AccountItemSectionHeader from './AccountItemSectionHeader';
|
||||
|
||||
import { YTNode } from '../helpers';
|
||||
|
||||
class AccountItem {
|
||||
static type = 'AccountItem';
|
||||
|
||||
account_name: Text;
|
||||
account_photo: Thumbnail[];
|
||||
is_selected: boolean;
|
||||
is_disabled: boolean;
|
||||
has_channel: boolean;
|
||||
endpoint: NavigationEndpoint;
|
||||
account_byline: Text;
|
||||
|
||||
constructor(data: any) {
|
||||
this.account_name = new Text(data.accountName);
|
||||
this.account_photo = Thumbnail.fromResponse(data.accountPhoto);
|
||||
this.is_selected = data.isSelected;
|
||||
this.is_disabled = data.isDisabled;
|
||||
this.has_channel = data.hasChannel;
|
||||
this.endpoint = new NavigationEndpoint(data.serviceEndpoint);
|
||||
this.account_byline = new Text(data.accountByline);
|
||||
}
|
||||
}
|
||||
|
||||
class AccountItemSection extends YTNode {
|
||||
static type = 'AccountItemSection';
|
||||
|
||||
contents;
|
||||
header;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.contents = data.contents.map((ac: any) => new AccountItem(ac.accountItem));
|
||||
this.header = Parser.parseItem<AccountItemSectionHeader>(data.header, AccountItemSectionHeader);
|
||||
}
|
||||
}
|
||||
|
||||
export default AccountItemSection;
|
||||
15
src/parser/classes/AccountItemSectionHeader.ts
Normal file
15
src/parser/classes/AccountItemSectionHeader.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import Text from './misc/Text';
|
||||
import { YTNode } from '../helpers';
|
||||
|
||||
class AccountItemSectionHeader extends YTNode {
|
||||
static type = 'AccountItemSectionHeader';
|
||||
|
||||
title: Text;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.title = new Text(data.title);
|
||||
}
|
||||
}
|
||||
|
||||
export default AccountItemSectionHeader;
|
||||
20
src/parser/classes/AccountSectionList.ts
Normal file
20
src/parser/classes/AccountSectionList.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import Parser from '..';
|
||||
import AccountChannel from './AccountChannel';
|
||||
import AccountItemSection from './AccountItemSection';
|
||||
|
||||
import { YTNode } from '../helpers';
|
||||
|
||||
class AccountSectionList extends YTNode {
|
||||
static type = 'AccountSectionList';
|
||||
|
||||
contents;
|
||||
footers;
|
||||
|
||||
constructor(data: any) {
|
||||
super();
|
||||
this.contents = Parser.parseItem<AccountItemSection>(data.contents[0], AccountItemSection);
|
||||
this.footers = Parser.parseItem<AccountChannel>(data.footers[0], AccountChannel);
|
||||
}
|
||||
}
|
||||
|
||||
export default AccountSectionList;
|
||||
Reference in New Issue
Block a user