From 499937fe3aadc03e9b1b86dd5953746fd3694394 Mon Sep 17 00:00:00 2001 From: LuanRT Date: Fri, 14 Jul 2023 03:01:47 +0000 Subject: [PATCH] chore: v5.4.0 release --- README.md | 2 ++ deno/package.json | 2 +- deno/src/parser/classes/Playlist.ts | 5 +++-- deno/src/parser/classes/Quiz.ts | 25 +++++++++++++++++++++++++ deno/src/parser/nodes.ts | 1 + deno/src/parser/youtube/Channel.ts | 18 ++++++++++++++++++ 6 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 deno/src/parser/classes/Quiz.ts diff --git a/README.md b/README.md index 634ffc07..5d7a5885 100644 --- a/README.md +++ b/README.md @@ -542,6 +542,8 @@ Retrieves contents for a given channel. - `#getVideos()` - `#getShorts()` - `#getLiveStreams()` +- `#getReleases()` +- `#getPodcasts()` - `#getPlaylists()` - `#getHome()` - `#getCommunity()` diff --git a/deno/package.json b/deno/package.json index 88286d9e..e01477be 100644 --- a/deno/package.json +++ b/deno/package.json @@ -1,6 +1,6 @@ { "name": "youtubei.js", - "version": "5.3.0", + "version": "5.4.0", "description": "A wrapper around YouTube's private API. Supports YouTube, YouTube Music, YouTube Kids and YouTube Studio (WIP).", "type": "module", "types": "./dist/src/platform/lib.d.ts", diff --git a/deno/src/parser/classes/Playlist.ts b/deno/src/parser/classes/Playlist.ts index 17095819..3ac84f75 100644 --- a/deno/src/parser/classes/Playlist.ts +++ b/deno/src/parser/classes/Playlist.ts @@ -1,6 +1,7 @@ import { YTNode, type ObservedArray } from '../helpers.ts'; import Parser, { type RawNode } from '../index.ts'; import NavigationEndpoint from './NavigationEndpoint.ts'; +import PlaylistCustomThumbnail from './PlaylistCustomThumbnail.ts'; import PlaylistVideoThumbnail from './PlaylistVideoThumbnail.ts'; import Author from './misc/Author.ts'; import Text from './misc/Text.ts'; @@ -13,7 +14,7 @@ export default class Playlist extends YTNode { title: Text; author: Text | Author; thumbnails: Thumbnail[]; - thumbnail_renderer?: PlaylistVideoThumbnail; + thumbnail_renderer?: PlaylistVideoThumbnail | PlaylistCustomThumbnail; video_count: Text; video_count_short: Text; first_videos: ObservedArray; @@ -44,7 +45,7 @@ export default class Playlist extends YTNode { this.thumbnail_overlays = Parser.parseArray(data.thumbnailOverlays); if (Reflect.has(data, 'thumbnailRenderer')) { - this.thumbnail_renderer = Parser.parseItem(data.thumbnailRenderer, PlaylistVideoThumbnail) || undefined; + this.thumbnail_renderer = Parser.parseItem(data.thumbnailRenderer, [ PlaylistVideoThumbnail, PlaylistCustomThumbnail ]) || undefined; } if (Reflect.has(data, 'viewPlaylistText')) { diff --git a/deno/src/parser/classes/Quiz.ts b/deno/src/parser/classes/Quiz.ts new file mode 100644 index 00000000..24f26238 --- /dev/null +++ b/deno/src/parser/classes/Quiz.ts @@ -0,0 +1,25 @@ +import { YTNode } from '../helpers.ts'; +import type { RawNode } from '../index.ts'; +import Text from './misc/Text.ts'; + +export default class Quiz extends YTNode { + static type = 'Quiz'; + + choices: { + text: Text; + is_correct: boolean; + }[]; + + total_votes: Text; + + constructor(data: RawNode) { + super(); + + this.choices = data.choices.map((choice: RawNode) => ({ + text: new Text(choice.text), + is_correct: choice.isCorrect + })); + + this.total_votes = new Text(data.totalVotes); + } +} \ No newline at end of file diff --git a/deno/src/parser/nodes.ts b/deno/src/parser/nodes.ts index 33a331ee..e8e6c368 100644 --- a/deno/src/parser/nodes.ts +++ b/deno/src/parser/nodes.ts @@ -265,6 +265,7 @@ export { default as ProfileColumn } from './classes/ProfileColumn.ts'; export { default as ProfileColumnStats } from './classes/ProfileColumnStats.ts'; export { default as ProfileColumnStatsEntry } from './classes/ProfileColumnStatsEntry.ts'; export { default as ProfileColumnUserInfo } from './classes/ProfileColumnUserInfo.ts'; +export { default as Quiz } from './classes/Quiz.ts'; export { default as RecognitionShelf } from './classes/RecognitionShelf.ts'; export { default as ReelItem } from './classes/ReelItem.ts'; export { default as ReelShelf } from './classes/ReelShelf.ts'; diff --git a/deno/src/parser/youtube/Channel.ts b/deno/src/parser/youtube/Channel.ts index 1c9eba86..2a71c50f 100644 --- a/deno/src/parser/youtube/Channel.ts +++ b/deno/src/parser/youtube/Channel.ts @@ -163,6 +163,16 @@ export default class Channel extends TabbedFeed { return new Channel(this.actions, tab.page, true); } + async getReleases(): Promise { + const tab = await this.getTabByURL('releases'); + return new Channel(this.actions, tab.page, true); + } + + async getPodcasts(): Promise { + const tab = await this.getTabByURL('podcasts'); + return new Channel(this.actions, tab.page, true); + } + async getPlaylists(): Promise { const tab = await this.getTabByURL('playlists'); return new Channel(this.actions, tab.page, true); @@ -217,6 +227,14 @@ export default class Channel extends TabbedFeed { return this.hasTabWithURL('streams'); } + get has_releases(): boolean { + return this.hasTabWithURL('releases'); + } + + get has_podcasts(): boolean { + return this.hasTabWithURL('podcasts'); + } + get has_playlists(): boolean { return this.hasTabWithURL('playlists'); }