Skip to content

Commit

Permalink
Add getPlaylists function (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
iBicha committed Apr 29, 2024
1 parent 0602dd2 commit 7315fca
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Innertube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,18 @@ export default class Innertube {
return response.data?.unseenCount || response.data?.actions?.[0].updateNotificationsUnseenCountAction?.unseenCount || 0;
}

/**
* Retrieves playlists.
*/
async getPlaylists() {
const response = await this.actions.execute(
BrowseEndpoint.PATH, { ...BrowseEndpoint.build({ browse_id: 'FEplaylist_aggregation' }), parse: true }
);

const feed = new Feed(this.actions, response);
return feed.playlists;
}

/**
* Retrieves playlist contents.
* @param id - Playlist id
Expand Down
1 change: 1 addition & 0 deletions src/core/Actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export default class Actions {
'FEhistory',
'FEsubscriptions',
'FEchannels',
'FEplaylist_aggregation',
'FEmusic_listening_review',
'FEmusic_library_landing',
'SPaccount_overview',
Expand Down
14 changes: 14 additions & 0 deletions src/parser/classes/ChipBarView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { YTNode, type ObservedArray } from '../helpers.js';
import { Parser, type RawNode } from '../index.js';
import ChipView from './ChipView.js';

export default class ChipBarView extends YTNode {
static type = 'ChipBarView';

chips: ObservedArray<ChipView> | null;

constructor(data: RawNode) {
super();
this.chips = Parser.parseArray(data.chips, ChipView);
}
}
20 changes: 20 additions & 0 deletions src/parser/classes/ChipView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { YTNode } from '../helpers.js';
import { type RawNode } from '../index.js';
import NavigationEndpoint from './NavigationEndpoint.js';

export default class ChipView extends YTNode {
static type = 'ChipView';

text: string;
display_type: string;
endpoint: NavigationEndpoint;
chip_entity_key: string;

constructor(data: RawNode) {
super();
this.text = data.text;
this.display_type = data.displayType;
this.endpoint = new NavigationEndpoint(data.tapCommand);
this.chip_entity_key = data.chipEntityKey;
}
}
2 changes: 2 additions & 0 deletions src/parser/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ export { default as ChannelThumbnailWithLink } from './classes/ChannelThumbnailW
export { default as ChannelVideoPlayer } from './classes/ChannelVideoPlayer.js';
export { default as Chapter } from './classes/Chapter.js';
export { default as ChildVideo } from './classes/ChildVideo.js';
export { default as ChipBarView } from './classes/ChipBarView.js';
export { default as ChipCloud } from './classes/ChipCloud.js';
export { default as ChipCloudChip } from './classes/ChipCloudChip.js';
export { default as ChipView } from './classes/ChipView.js';
export { default as ClipAdState } from './classes/ClipAdState.js';
export { default as ClipCreation } from './classes/ClipCreation.js';
export { default as ClipCreationScrubber } from './classes/ClipCreationScrubber.js';
Expand Down

0 comments on commit 7315fca

Please sign in to comment.