Comparing version 4.2.0 to 5.0.0
@@ -63,3 +63,2 @@ "use strict"; | ||
if (channel.brandingSettings) { | ||
this.banners = channel.brandingSettings.image; | ||
// Unknown behavior | ||
@@ -66,0 +65,0 @@ /* istanbul ignore next */ |
@@ -20,3 +20,2 @@ "use strict"; | ||
__exportStar(require("./video-abuse-report-reason"), exports); | ||
__exportStar(require("./guide-category"), exports); | ||
__exportStar(require("./language"), exports); | ||
@@ -23,0 +22,0 @@ __exportStar(require("./region"), exports); |
@@ -53,2 +53,4 @@ "use strict"; | ||
} | ||
/* **CURRENTLY NOT WORKING**, see https://issuetracker.google.com/issues/181152600 */ | ||
/* istanbul ignore next */ | ||
if (subscription.contentDetails) { | ||
@@ -64,2 +66,4 @@ this.items = { | ||
} | ||
/* **CURRENTLY NOT WORKING**, see https://issuetracker.google.com/issues/181152600 */ | ||
/* istanbul ignore next */ | ||
if (subscription.subscriberSnippet) { | ||
@@ -77,2 +81,3 @@ this.subscriber.name = subscription.subscriberSnippet.title; | ||
* Only useful if `this.full` is false, or if you want updated subscription info. | ||
* **CURRENTLY NOT WORKING**, see https://issuetracker.google.com/issues/181152600 | ||
*/ | ||
@@ -79,0 +84,0 @@ fetch() { |
@@ -69,3 +69,6 @@ "use strict"; | ||
this.datePublished = new Date(data.snippet.publishedAt); | ||
this.channelId = data.snippet.channelId; | ||
this.channel = { | ||
id: data.snippet.channelId || data.snippet.videoOwnerChannelId, | ||
name: data.snippet.channelTitle || data.snippet.videoOwnerChannelTitle | ||
}; | ||
// Impossible to test | ||
@@ -102,3 +105,3 @@ /* istanbul ignore next */ | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const comment = yield this.youtube.oauth.postComment(text, this.channelId, this.id); | ||
const comment = yield this.youtube.oauth.postComment(text, this.channel.id, this.id); | ||
if (this.comments !== undefined) { | ||
@@ -266,4 +269,5 @@ this.comments.push(comment); | ||
Video.fields = 'items(kind,id,contentDetails(duration),statistics(likeCount,dislikeCount,viewCount,commentCount),' + | ||
'status(privacyStatus,madeForKids,selfDeclaredMadeForKids),snippet(title,description,thumbnails,tags,publishedAt,channelId,liveBroadcastContent,categoryId))'; | ||
'status(privacyStatus,madeForKids,selfDeclaredMadeForKids),snippet(title,description,thumbnails,tags,publishedAt,channelId,channelTitle,liveBroadcastContent,' + | ||
'categoryId))'; | ||
//# sourceMappingURL=video.js.map |
@@ -131,2 +131,3 @@ "use strict"; | ||
* Meant mostly for getting by URL or ID. | ||
* **Beware**, custom channel URLs may not work. | ||
* @param channelResolvable The Username, URL or ID of the channel. | ||
@@ -173,11 +174,2 @@ */ | ||
/** | ||
* Get a [[GuideCategory]] object from the ID of a category. | ||
* @param categoryId The ID of the category. | ||
* @deprecated See https://developers.google.com/youtube/v3/docs/guideCategories/list | ||
*/ | ||
/* istanbul ignore next */ | ||
getGuideCategory(categoryId) { | ||
return services_1.GenericService.getItem(this, entities_1.GuideCategory, false, categoryId); | ||
} | ||
/** | ||
* Get a [[ChannelSection]] object from the ID of a section. | ||
@@ -289,10 +281,2 @@ * @param categoryId The ID of the section. | ||
/** | ||
* Get the list of guide categories in `this.region`. | ||
* @deprecated See https://developers.google.com/youtube/v3/docs/guideCategories/list | ||
*/ | ||
/* istanbul ignore next */ | ||
getGuideCategories() { | ||
return services_1.GenericService.getPaginatedItems(this, 'guideCategories', false); | ||
} | ||
/** | ||
* Get a list of languages that YouTube supports. | ||
@@ -299,0 +283,0 @@ */ |
@@ -22,4 +22,4 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!([__1.Video, __1.Channel, __1.Playlist, __1.YTComment, __1.Subscription, __1.VideoCategory, __1.VideoAbuseReportReason, __1.GuideCategory, __1.ChannelSection, __1.Caption].includes(type))) { | ||
return Promise.reject('Type must be a video, channel, playlist, comment, subscription, video/guide category, or channel section.'); | ||
if (!([__1.Video, __1.Channel, __1.Playlist, __1.YTComment, __1.Subscription, __1.VideoCategory, __1.VideoAbuseReportReason, __1.ChannelSection, __1.Caption].includes(type))) { | ||
return Promise.reject('Type must be a video, channel, playlist, comment, subscription, video category, or channel section.'); | ||
} | ||
@@ -41,3 +41,3 @@ if (!mine && (id === undefined || id === null)) { | ||
}; | ||
if (type === __1.VideoCategory || type === __1.GuideCategory) { | ||
if (type === __1.VideoCategory) { | ||
params.hl = youtube.language; | ||
@@ -64,7 +64,7 @@ } | ||
if (!mine && (id === undefined || id === null) && | ||
!(['videoAbuseReportReasons', 'i18nLanguages', 'i18nRegions', 'guideCategories', 'videoCategories'].includes(endpoint))) { | ||
!(['videoAbuseReportReasons', 'i18nLanguages', 'i18nRegions', 'videoCategories'].includes(endpoint))) { | ||
return Promise.reject(`${endpoint} must either specify an ID or the 'mine' parameter.`); | ||
} | ||
if (mine && (endpoint.startsWith('comment') || | ||
['playlistItems', 'videoCategories', 'videoAbuseReportReasons', 'guideCategories', 'i18nLanguages', 'i18nRegions', 'captions'].includes(endpoint))) { | ||
['playlistItems', 'videoCategories', 'videoAbuseReportReasons', 'i18nLanguages', 'i18nRegions', 'captions'].includes(endpoint))) { | ||
return Promise.reject(`${endpoint} cannot be filtered by the 'mine' parameter.`); | ||
@@ -122,4 +122,4 @@ } | ||
} | ||
else if (endpoint === 'videoCategories' || endpoint === 'guideCategories') { | ||
clazz = endpoint === 'videoCategories' ? __1.VideoCategory : __1.GuideCategory; | ||
else if (endpoint === 'videoCategories') { | ||
clazz = __1.VideoCategory; | ||
options.regionCode = youtube.region; | ||
@@ -153,5 +153,5 @@ options.hl = youtube.language; | ||
let results; | ||
let pages = null; | ||
let pages = -1; | ||
let shouldReturn = !full; | ||
for (let i = 1; i < pages ? pages : 3; i++) { | ||
for (let i = 1; i < (pages > 0 ? pages : 3); i++) { | ||
results = yield youtube._request.api(endpoint, options, youtube.token, youtube.accessToken); | ||
@@ -161,3 +161,3 @@ if (results.items.length === 0) { | ||
} | ||
if (!pages) { | ||
if (pages < 1) { | ||
pages = results.pageInfo ? results.pageInfo.totalResults / results.pageInfo.resultsPerPage : 0; | ||
@@ -213,12 +213,12 @@ if (pages <= 1) { | ||
if (input.includes('youtube.com') || input.includes('youtu.be')) { | ||
const idFromUrl = util_1.Parser.parseUrl(input)[type.name.toLowerCase()]; | ||
id = util_1.Parser.parseUrl(input)[type.name.toLowerCase()]; | ||
// Custom channel URLs don't work that well | ||
if (type === __1.Channel && idFromUrl && !idFromUrl.startsWith('UC')) { | ||
if (type === __1.Channel && id && !id.startsWith('UC')) { | ||
id = yield youtube._request.api('search', { | ||
q: encodeURIComponent(idFromUrl), | ||
q: encodeURIComponent(id), | ||
type: 'channel', | ||
part: 'id' | ||
part: 'id', | ||
maxResults: 1 | ||
}, youtube.token, youtube.accessToken).then(r => r.items[0] ? r.items[0].id.channelId : undefined); | ||
} | ||
id = idFromUrl; | ||
} | ||
@@ -225,0 +225,0 @@ if (id !== null && id !== undefined && id !== '') { |
@@ -32,3 +32,4 @@ "use strict"; | ||
q: encodeURIComponent(searchTerm), | ||
fields: encodeURIComponent(fields || 'prevPageToken,nextPageToken,items(kind,id,snippet(title,description,thumbnails,publishedAt,channelId,liveBroadcastContent))'), | ||
fields: encodeURIComponent(fields || | ||
'prevPageToken,nextPageToken,items(kind,id,snippet(title,description,thumbnails,publishedAt,channelId,channelTitle,liveBroadcastContent))'), | ||
maxResults, | ||
@@ -35,0 +36,0 @@ part: 'snippet', |
@@ -19,2 +19,5 @@ "use strict"; | ||
const idRegex = /^[a-zA-Z0-9-_]+$/; | ||
if (parsed.pathname.endsWith('/')) { | ||
parsed.pathname = parsed.pathname.substring(0, parsed.pathname.length - 1); | ||
} | ||
if (parsed.pathname === '/watch') { | ||
@@ -21,0 +24,0 @@ if (!parsed.query.v || !idRegex.test(parsed.query.v)) { |
@@ -132,3 +132,3 @@ "use strict"; | ||
if (res.statusCode === 204) { | ||
return resolve(); | ||
return resolve(undefined); | ||
} | ||
@@ -135,0 +135,0 @@ if (res.headers['content-type'].startsWith('application/octet-stream')) { |
{ | ||
"name": "popyt", | ||
"version": "4.2.0", | ||
"version": "5.0.0", | ||
"description": "A very easy to use promise-based Youtube Data v3 API.", | ||
"homepage": "https://bbothell.me/popyt", | ||
"homepage": "https://bbothell.rocks/popyt", | ||
"main": "out/index.js", | ||
@@ -10,3 +10,3 @@ "types": "typings/index.d.ts", | ||
"test": "mocha --exit --require ts-node/register/transpile-only --require source-map-support/register --parallel --recursive \"./test/!(oauth).spec.ts\" --timeout 10000", | ||
"coverage": "nyc yarn test && nyc report --reporter=text-lcov | coveralls", | ||
"coverage": "tsc && cross-env NODE_ENV=test nyc yarn test && cross-env NODE_ENV=test nyc report --reporter=text-lcov | coveralls", | ||
"docs": "gulp typedoc", | ||
@@ -31,28 +31,29 @@ "prepublishOnly": "gulp", | ||
"@istanbuljs/nyc-config-typescript": "1.0.1", | ||
"@types/chai": "4.2.14", | ||
"@types/chai": "4.2.15", | ||
"@types/gulp": "4.0.7", | ||
"@types/gulp-sourcemaps": "0.0.32", | ||
"@types/gulp-sourcemaps": "0.0.34", | ||
"@types/merge2": "1.3.0", | ||
"@types/mocha": "8.0.3", | ||
"@types/node": "13.13.30", | ||
"@typescript-eslint/eslint-plugin": "4.7.0", | ||
"@typescript-eslint/parser": "4.7.0", | ||
"chai": "4.2.0", | ||
"@types/mocha": "8.2.1", | ||
"@types/node": "13.13.45", | ||
"@typescript-eslint/eslint-plugin": "4.16.1", | ||
"@typescript-eslint/parser": "4.16.1", | ||
"chai": "4.3.1", | ||
"coveralls": "3.1.0", | ||
"cross-env": "7.0.3", | ||
"dotenv": "8.2.0", | ||
"eslint": "7.12.1", | ||
"eslint": "7.21.0", | ||
"eslint-plugin-import": "2.22.1", | ||
"eslint-plugin-jsdoc": "30.7.5", | ||
"eslint-plugin-jsdoc": "32.2.0", | ||
"fs-nextra": "0.5.1", | ||
"gulp": "4.0.2", | ||
"gulp-sourcemaps": "2.6.5", | ||
"gulp-typedoc": "2.2.5", | ||
"gulp-sourcemaps": "3.0.0", | ||
"gulp-typedoc": "2.2.9", | ||
"gulp-typescript": "5.0.1", | ||
"merge2": "1.4.1", | ||
"mocha": "8.2.1", | ||
"mocha": "8.3.0", | ||
"nyc": "15.1.0", | ||
"source-map-support": "0.5.19", | ||
"ts-node": "9.0.0", | ||
"ts-node": "9.1.1", | ||
"typedoc": "0.19.2", | ||
"typescript": "4.0.5" | ||
"typescript": "4.2.2" | ||
}, | ||
@@ -59,0 +60,0 @@ "repository": { |
@@ -9,7 +9,6 @@ # popyt | ||
[![Actions status](https://github.com/jasonhaxstuff/popyt/workflows/Test/badge.svg)](https://github.com/jasonhaxstuff/popyt/actions) | ||
[![DeepScan grade](https://deepscan.io/api/teams/13038/projects/16072/branches/335663/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=13038&pid=16072&bid=335663) | ||
[![Downloads](https://img.shields.io/npm/dt/popyt.svg)](https://www.npmjs.com/package/popyt) | ||
[![Version](https://img.shields.io/npm/v/popyt.svg)](https://www.npmjs.com/package/popyt) | ||
Check out [our website](https://bbothell.rocks/popyt)! | ||
# Examples | ||
@@ -63,3 +62,3 @@ ## See [the documentation](https://bbothell.rocks/popyt/docs). | ||
Note: This wrapper does not implement every feature of the YouTube API. With a single developer working on it, there just isn't time for everything to be implemented. Some of the objectively most-important features have been added. The limits imposed by the wrapper are not imposed by YouTube. | ||
Note: This wrapper does not implement every feature of the YouTube API. If you would like anything added, feel free to open an issue. The limits imposed by the wrapper are not imposed by YouTube. | ||
@@ -66,0 +65,0 @@ # Development/Contributing |
/// <reference types="node" /> | ||
import { YouTube, Playlist, Thumbnail, Banners, YTComment, Subscription, ChannelSection, ChannelBrandingSettings } from '..'; | ||
import { YouTube, Playlist, Thumbnail, YTComment, Subscription, ChannelSection, ChannelBrandingSettings } from '..'; | ||
/** | ||
@@ -66,7 +66,2 @@ * A YouTube channel. | ||
/** | ||
* This channel's banners. | ||
* @deprecated See https://developers.google.com/youtube/v3/docs/channels#brandingSettings.image | ||
*/ | ||
banners: Banners; | ||
/** | ||
* The date this channel was created. | ||
@@ -73,0 +68,0 @@ */ |
@@ -8,3 +8,2 @@ export * from './video'; | ||
export * from './video-abuse-report-reason'; | ||
export * from './guide-category'; | ||
export * from './language'; | ||
@@ -11,0 +10,0 @@ export * from './region'; |
@@ -19,15 +19,15 @@ import YouTube from '..'; | ||
/** | ||
* The YouTube object that created this language object. | ||
* The YouTube object that created this region object. | ||
*/ | ||
youtube: YouTube; | ||
/** | ||
* Whether or not this is a full language object. | ||
* Whether or not this is a full region object. | ||
*/ | ||
full: boolean; | ||
/** | ||
* The raw data of this language. | ||
* The raw data of this region. | ||
*/ | ||
data: any; | ||
/** | ||
* The ID of this language. | ||
* The ID of this region. | ||
*/ | ||
@@ -34,0 +34,0 @@ id: string; |
@@ -25,2 +25,3 @@ import YouTube from '..'; | ||
* Whether or not this is a full subscription object. | ||
* **CURRENTLY NOT WORKING**, see https://issuetracker.google.com/issues/181152600 | ||
*/ | ||
@@ -63,2 +64,3 @@ full: boolean; | ||
* Information on the user that subscribed to the channel. | ||
* **CURRENTLY NOT WORKING**, see https://issuetracker.google.com/issues/181152600 | ||
*/ | ||
@@ -97,2 +99,3 @@ subscriber: { | ||
* Statistics on the items that the subscription points to. | ||
* **CURRENTLY NOT WORKING**, see https://issuetracker.google.com/issues/181152600 | ||
*/ | ||
@@ -111,2 +114,3 @@ items: { | ||
* The activities that the user has subscribed to. | ||
* **CURRENTLY NOT WORKING**, see https://issuetracker.google.com/issues/181152600 | ||
*/ | ||
@@ -122,4 +126,5 @@ activities: 'all' | 'uploads'; | ||
* Only useful if `this.full` is false, or if you want updated subscription info. | ||
* **CURRENTLY NOT WORKING**, see https://issuetracker.google.com/issues/181152600 | ||
*/ | ||
fetch(): Promise<(this & string) | (this & Subscription)>; | ||
fetch(): Promise<this & (string | Subscription)>; | ||
} |
@@ -64,5 +64,8 @@ /// <reference types="node" /> | ||
/** | ||
* The ID of the channel that uploaded the video. | ||
* Information on the channel that uploaded the video. | ||
*/ | ||
channelId: string; | ||
channel: { | ||
id: string; | ||
name: string; | ||
}; | ||
/** | ||
@@ -69,0 +72,0 @@ * @ignore |
@@ -1,2 +0,2 @@ | ||
import { Video, Channel, Playlist, YTComment, Subscription, VideoCategory, GuideCategory, Language, Region, ChannelSection } from './entities'; | ||
import { Video, Channel, Playlist, YTComment, Subscription, VideoCategory, Language, Region, ChannelSection } from './entities'; | ||
import { Request } from './util'; | ||
@@ -67,2 +67,5 @@ import { OAuth } from './oauth'; | ||
search(types: (typeof Video | typeof Channel | typeof Playlist)[], searchTerm: string, maxResults?: number, pageToken?: string, fields?: string): Promise<{ | ||
/** | ||
* @ignore | ||
*/ | ||
results: (Video | Channel | Playlist)[]; | ||
@@ -118,2 +121,3 @@ prevPageToken: string; | ||
* Meant mostly for getting by URL or ID. | ||
* **Beware**, custom channel URLs may not work. | ||
* @param channelResolvable The Username, URL or ID of the channel. | ||
@@ -144,8 +148,2 @@ */ | ||
/** | ||
* Get a [[GuideCategory]] object from the ID of a category. | ||
* @param categoryId The ID of the category. | ||
* @deprecated See https://developers.google.com/youtube/v3/docs/guideCategories/list | ||
*/ | ||
getGuideCategory(categoryId: string): Promise<GuideCategory>; | ||
/** | ||
* Get a [[ChannelSection]] object from the ID of a section. | ||
@@ -215,7 +213,2 @@ * @param categoryId The ID of the section. | ||
/** | ||
* Get the list of guide categories in `this.region`. | ||
* @deprecated See https://developers.google.com/youtube/v3/docs/guideCategories/list | ||
*/ | ||
getGuideCategories(): Promise<GuideCategory[]>; | ||
/** | ||
* Get a list of languages that YouTube supports. | ||
@@ -222,0 +215,0 @@ */ |
@@ -1,9 +0,9 @@ | ||
import { Video, Channel, Playlist, YTComment, Subscription, VideoCategory, GuideCategory, ChannelSection, Caption } from '..'; | ||
import { Video, Channel, Playlist, YTComment, Subscription, VideoCategory, ChannelSection, Caption } from '..'; | ||
/** | ||
* @ignore | ||
*/ | ||
export declare type ItemTypes = typeof Video | typeof Channel | typeof Playlist | typeof YTComment | typeof Subscription | typeof VideoCategory | typeof GuideCategory | typeof ChannelSection | typeof Caption; | ||
export declare type ItemTypes = typeof Video | typeof Channel | typeof Playlist | typeof YTComment | typeof Subscription | typeof VideoCategory | typeof ChannelSection | typeof Caption; | ||
/** | ||
* @ignore | ||
*/ | ||
export declare type ItemReturns = Video | Channel | Playlist | YTComment | Subscription | VideoCategory | GuideCategory | ChannelSection | Caption; | ||
export declare type ItemReturns = Video | Channel | Playlist | YTComment | Subscription | VideoCategory | ChannelSection | Caption; |
@@ -1,9 +0,9 @@ | ||
import { Video, YTComment, Playlist, Subscription, VideoCategory, VideoAbuseReportReason, GuideCategory, Language, Region, ChannelSection, Caption } from '..'; | ||
import { Video, YTComment, Playlist, Subscription, VideoCategory, VideoAbuseReportReason, Language, Region, ChannelSection, Caption } from '..'; | ||
/** | ||
* @ignore | ||
*/ | ||
export declare type PaginatedItemsEndpoints = 'playlistItems' | 'playlists' | 'playlists:channel' | 'commentThreads' | 'commentThreads:video' | 'commentThreads:channel' | 'comments' | 'subscriptions' | 'videoCategories' | 'videoAbuseReportReasons' | 'guideCategories' | 'i18nLanguages' | 'i18nRegions' | 'channelSections' | 'captions'; | ||
export declare type PaginatedItemsEndpoints = 'playlistItems' | 'playlists' | 'playlists:channel' | 'commentThreads' | 'commentThreads:video' | 'commentThreads:channel' | 'comments' | 'subscriptions' | 'videoCategories' | 'videoAbuseReportReasons' | 'i18nLanguages' | 'i18nRegions' | 'channelSections' | 'captions'; | ||
/** | ||
* @ignore | ||
*/ | ||
export declare type PaginatedItemsReturns = Video[] | YTComment[] | Playlist[] | Subscription[] | VideoCategory[] | VideoAbuseReportReason[] | GuideCategory[] | Language[] | Region[] | ChannelSection[] | Caption[]; | ||
export declare type PaginatedItemsReturns = Video[] | YTComment[] | Playlist[] | Subscription[] | VideoCategory[] | VideoAbuseReportReason[] | Language[] | Region[] | ChannelSection[] | Caption[]; |
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
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
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
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
Sorry, the diff of this file is not supported yet
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
468859
28
100
5726
69