Compare commits

...

3 Commits

Author SHA1 Message Date
github-actions[bot]
8c688efb4a chore(main): release 5.4.0 (#438)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-07-14 00:00:43 -03:00
ChunkyProgrammer
cffa868c6e feat(parser): Add Quiz (#437) 2023-07-13 23:57:39 -03:00
ChunkyProgrammer
f267fcd8be Add getReleases and getPodcasts to Channel (#436)
* feat(Channel): Add `getReleases` method

* feat(Channel): Add `getPodcasts` method

* Fix(Playlist): Parse `PlaylistCustomThumbnail`
2023-07-13 15:25:20 -03:00
8 changed files with 66 additions and 5 deletions

View File

@@ -1,5 +1,19 @@
# Changelog
## [5.4.0](https://github.com/LuanRT/YouTube.js/compare/v5.3.0...v5.4.0) (2023-07-14)
### Features
* **Channel:** Add `getPodcasts()` method ([f267fcd](https://github.com/LuanRT/YouTube.js/commit/f267fcd8beccf237b8d1924463990273887cae28))
* **Channel:** Add `getReleases()` method ([f267fcd](https://github.com/LuanRT/YouTube.js/commit/f267fcd8beccf237b8d1924463990273887cae28))
* **parser:** Add `Quiz` ([#437](https://github.com/LuanRT/YouTube.js/issues/437)) ([cffa868](https://github.com/LuanRT/YouTube.js/commit/cffa868c6eeb579047653fac65da8e913fb3c621))
### Bug Fixes
* **Playlist:** Parse `PlaylistCustomThumbnail` for `thumbnail_renderer` ([f267fcd](https://github.com/LuanRT/YouTube.js/commit/f267fcd8beccf237b8d1924463990273887cae28))
## [5.3.0](https://github.com/LuanRT/YouTube.js/compare/v5.2.1...v5.3.0) (2023-07-11)

View File

@@ -542,6 +542,8 @@ Retrieves contents for a given channel.
- `<channel>#getVideos()`
- `<channel>#getShorts()`
- `<channel>#getLiveStreams()`
- `<channel>#getReleases()`
- `<channel>#getPodcasts()`
- `<channel>#getPlaylists()`
- `<channel>#getHome()`
- `<channel>#getCommunity()`

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "youtubei.js",
"version": "5.3.0",
"version": "5.4.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "youtubei.js",
"version": "5.3.0",
"version": "5.4.0",
"funding": [
"https://github.com/sponsors/LuanRT"
],

View File

@@ -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",

View File

@@ -1,6 +1,7 @@
import { YTNode, type ObservedArray } from '../helpers.js';
import Parser, { type RawNode } from '../index.js';
import NavigationEndpoint from './NavigationEndpoint.js';
import PlaylistCustomThumbnail from './PlaylistCustomThumbnail.js';
import PlaylistVideoThumbnail from './PlaylistVideoThumbnail.js';
import Author from './misc/Author.js';
import Text from './misc/Text.js';
@@ -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<YTNode>;
@@ -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')) {

View File

@@ -0,0 +1,25 @@
import { YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';
import Text from './misc/Text.js';
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);
}
}

View File

@@ -265,6 +265,7 @@ export { default as ProfileColumn } from './classes/ProfileColumn.js';
export { default as ProfileColumnStats } from './classes/ProfileColumnStats.js';
export { default as ProfileColumnStatsEntry } from './classes/ProfileColumnStatsEntry.js';
export { default as ProfileColumnUserInfo } from './classes/ProfileColumnUserInfo.js';
export { default as Quiz } from './classes/Quiz.js';
export { default as RecognitionShelf } from './classes/RecognitionShelf.js';
export { default as ReelItem } from './classes/ReelItem.js';
export { default as ReelShelf } from './classes/ReelShelf.js';

View File

@@ -163,6 +163,16 @@ export default class Channel extends TabbedFeed<IBrowseResponse> {
return new Channel(this.actions, tab.page, true);
}
async getReleases(): Promise<Channel> {
const tab = await this.getTabByURL('releases');
return new Channel(this.actions, tab.page, true);
}
async getPodcasts(): Promise<Channel> {
const tab = await this.getTabByURL('podcasts');
return new Channel(this.actions, tab.page, true);
}
async getPlaylists(): Promise<Channel> {
const tab = await this.getTabByURL('playlists');
return new Channel(this.actions, tab.page, true);
@@ -217,6 +227,14 @@ export default class Channel extends TabbedFeed<IBrowseResponse> {
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');
}