better-youtube-api
Advanced tools
Comparing version 2.1.1 to 2.1.2
@@ -111,2 +111,12 @@ "use strict"; | ||
} | ||
/** | ||
* Fetches the channel's playlists and assigns them to Channel#playlists. | ||
* @param maxResults The maximum amount of playlists to fetch | ||
*/ | ||
fetchPlaylists(maxResults = -1) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.playlists = yield this.youtube.getChannelPlaylists(this.id, maxResults); | ||
return this.playlists; | ||
}); | ||
} | ||
} | ||
@@ -113,0 +123,0 @@ exports.Channel = Channel; |
@@ -196,2 +196,13 @@ "use strict"; | ||
/** | ||
* Get `maxResults` of a channel's playlists. Used mostly internally with `Channel#fetchPlaylists`. | ||
* @param channelResolvable The Username, URL, or ID of the channel. | ||
* @param maxResults The maximum amount of playlists to get from the channel. If <= 0 or not included, returns all playlists. | ||
*/ | ||
getChannelPlaylists(channelResolvable, maxResults = -1) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const channelId = yield this.getId(channelResolvable, 'channel'); | ||
return this.getPaginatedItems('playlists:channel', channelId, maxResults); | ||
}); | ||
} | ||
/** | ||
* Get `maxResults` replies to a comment. Used mostly internally with `Comment#fetchReplies`. | ||
@@ -308,2 +319,9 @@ * @param commentId The ID of the comment to get replies from. | ||
} | ||
else if (endpoint === 'playlists:channel') { | ||
max = 50; | ||
clazz = entities_1.Playlist; | ||
endpoint = 'playlists'; | ||
options.part += ',contentDetails,player'; | ||
options.channelId = id; | ||
} | ||
else { | ||
@@ -310,0 +328,0 @@ return Promise.reject('Unknown item type ' + endpoint); |
{ | ||
"name": "better-youtube-api", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "A very easy to use promise-based Youtube Data v3 API.", | ||
@@ -5,0 +5,0 @@ "main": "out/index.js", |
@@ -98,3 +98,3 @@ import { YouTube, Playlist, Thumbnail, Banners } from '..'; | ||
/** | ||
* The channel's comments. Only defined when Channel#fetchComments is called. | ||
* The channel's comments. Only defined when `Channel#fetchComments` is called. | ||
*/ | ||
@@ -107,2 +107,6 @@ comments: YTComment[]; | ||
/** | ||
* The channel's playlists. Only defined when `Channel#fetchPlaylists` is called. | ||
*/ | ||
playlists: Playlist[]; | ||
/** | ||
* Only set if the channel is a search result. | ||
@@ -137,2 +141,7 @@ * | ||
fetchComments(maxResults?: number): Promise<YTComment[]>; | ||
/** | ||
* Fetches the channel's playlists and assigns them to Channel#playlists. | ||
* @param maxResults The maximum amount of playlists to fetch | ||
*/ | ||
fetchPlaylists(maxResults?: number): Promise<Playlist[]>; | ||
} |
@@ -15,2 +15,5 @@ import { Video, Channel, Playlist, YTComment } from './entities'; | ||
tokenType: 'key' | 'oauth'; | ||
/** | ||
* Methods requiring an OAuth token | ||
*/ | ||
oauth: OAuth; | ||
@@ -31,3 +34,3 @@ /** | ||
*/ | ||
search(types: (typeof Video | typeof Channel | typeof Playlist)[], searchTerm: string, maxResults?: number): Promise<(Video | Channel | Playlist)[]>; | ||
search(types: (typeof Video | typeof Channel | typeof Playlist)[], searchTerm: string, maxResults?: number): Promise<(Video | Playlist | Channel)[]>; | ||
/** | ||
@@ -108,2 +111,8 @@ * Search videos on YouTube. | ||
/** | ||
* Get `maxResults` of a channel's playlists. Used mostly internally with `Channel#fetchPlaylists`. | ||
* @param channelResolvable The Username, URL, or ID of the channel. | ||
* @param maxResults The maximum amount of playlists to get from the channel. If <= 0 or not included, returns all playlists. | ||
*/ | ||
getChannelPlaylists(channelResolvable: string, maxResults?: number): Promise<Playlist[]>; | ||
/** | ||
* Get `maxResults` replies to a comment. Used mostly internally with `Comment#fetchReplies`. | ||
@@ -110,0 +119,0 @@ * @param commentId The ID of the comment to get replies from. |
@@ -10,3 +10,3 @@ import YouTube from '.'; | ||
constructor(youtube: YouTube); | ||
checkTokenAndThrow(): void; | ||
private checkTokenAndThrow; | ||
/** | ||
@@ -13,0 +13,0 @@ * Post a comment on a video or channel discussion. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
158732
1904