Comparing version 4.0.0 to 4.1.0
@@ -207,2 +207,59 @@ "use strict"; | ||
} | ||
/** | ||
* Updates the channel's branding settings. | ||
* Must be using an access token with correct scopes. | ||
*/ | ||
/* istanbul ignore next */ | ||
updateBranding(branding) { | ||
return this.youtube.oauth.updateChannelBranding(this.id, branding); | ||
} | ||
/** | ||
* Updates the channel's localizations. | ||
* Must be using an access token with correct scopes. | ||
*/ | ||
/* istanbul ignore next */ | ||
updateLocalizations(localizations) { | ||
return this.youtube.oauth.updateChannelLocalizations(this.id, localizations); | ||
} | ||
/** | ||
* Sets whether or not the channel is made for kids. | ||
* Must be using an access token with correct scopes. | ||
*/ | ||
/* istanbul ignore next */ | ||
setMadeForKids(madeForKids) { | ||
return this.youtube.oauth.setChannelMadeForKids(this.id, madeForKids); | ||
} | ||
/** | ||
* Sets the channel's watermark. | ||
* Must be using an access token with correct scopes. | ||
*/ | ||
/* istanbul ignore next */ | ||
setWatermark(type, offset, duration, image, imageType) { | ||
return this.youtube.oauth.setChannelWatermark(this.id, type, offset, duration, image, imageType); | ||
} | ||
/** | ||
* Unsets the channel's watermark. | ||
* Must be using an access token with correct scopes. | ||
*/ | ||
/* istanbul ignore next */ | ||
unsetWatermark() { | ||
return this.youtube.oauth.unsetChannelWatermark(this.id); | ||
} | ||
/** | ||
* Uploads and sets the channel's banner. | ||
* Must be using an access token with correct scopes. | ||
*/ | ||
/* istanbul ignore next */ | ||
setBanner(image) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this.data.brandingSettings) { | ||
yield this.fetch(); | ||
} | ||
if (!this.data.brandingSettings) { | ||
return Promise.reject('Unable to fetch channel branding settings'); | ||
} | ||
this.data.brandingSettings.image.bannerExternalUrl = yield this.youtube.oauth.uploadChannelBanner(image); | ||
return this.youtube.oauth.updateChannelBranding(this.id, this.data.brandingSettings); | ||
}); | ||
} | ||
} | ||
@@ -209,0 +266,0 @@ exports.Channel = Channel; |
@@ -80,2 +80,21 @@ "use strict"; | ||
/** | ||
* Edits the playlist. | ||
* Must be using an access token with correct scopes. | ||
* **If your request does not specify a value for a property that already has a value, | ||
* the property's existing value will be deleted.** | ||
* @param title A title for the playlist. | ||
* @param description A description of the playlist. | ||
* @param privacy Whether the video is private, public, or unlisted. | ||
* @param tags Tags pertaining to the playlist. | ||
* @param language The language of the playlist's default title and description. | ||
* @param localizations Translated titles and descriptions. | ||
*/ | ||
/* istanbul ignore next */ | ||
update(title, description, privacy, tags, language, localizations) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const newPlaylist = yield this.youtube.oauth.updatePlaylist(this.id, title, description, privacy, tags, language, localizations); | ||
return Object.assign(this, Object.assign(Object.assign({}, newPlaylist), { full: true })); | ||
}); | ||
} | ||
/** | ||
* Adds a [[Video]] to the playlist. | ||
@@ -139,2 +158,10 @@ * Must be using an access token with correct scopes. | ||
} | ||
/** | ||
* Deletes the playlist. | ||
* Must be using an access token with correct scopes. | ||
*/ | ||
/* istanbul ignore next */ | ||
delete() { | ||
return this.youtube.oauth.deletePlaylist(this.id); | ||
} | ||
} | ||
@@ -141,0 +168,0 @@ exports.Playlist = Playlist; |
@@ -588,3 +588,3 @@ "use strict"; | ||
/** | ||
* Adds a [[ChannelSection]] to a [[Channel]]. | ||
* Adds a [[ChannelSection]] to the authorized user's [[Channel]]. | ||
* Last tested 05/24/2020 10:11. PASSING | ||
@@ -591,0 +591,0 @@ * @param type The type of channel section. |
@@ -163,3 +163,4 @@ "use strict"; | ||
} | ||
results.items.forEach(item => { | ||
for (let i = 0; i < results.items.length; i++) { | ||
const item = results.items[i]; | ||
let comment; | ||
@@ -179,3 +180,3 @@ if (item.snippet.topLevelComment) { | ||
} | ||
}); | ||
} | ||
if (results.nextPageToken && !shouldReturn) { | ||
@@ -182,0 +183,0 @@ options.pageToken = results.nextPageToken; |
@@ -15,56 +15,38 @@ "use strict"; | ||
api(subUrl, params, token, accessToken) { | ||
const url = this.baseUrl + (subUrl.startsWith('/') ? '' : '/') + subUrl + this.parseParams(params) + | ||
(!accessToken ? (params ? `&key=${token}` : `?key=${token}`) : ''); | ||
const url = this.formUrl(subUrl, params, token, accessToken); | ||
return this.get(url, accessToken); | ||
} | ||
post(subUrl, params, data, token, accessToken) { | ||
const url = this.baseUrl + (subUrl.startsWith('/') ? '' : '/') + subUrl + this.parseParams(params) + | ||
(!accessToken ? (params ? `&key=${token}` : `?key=${token}`) : ''); | ||
const url = this.formUrl(subUrl, params, token, accessToken); | ||
return this._post(url, data, accessToken); | ||
} | ||
put(subUrl, params, data, token, accessToken) { | ||
const url = this.baseUrl + (subUrl.startsWith('/') ? '' : '/') + subUrl + this.parseParams(params) + | ||
(!accessToken ? (params ? `&key=${token}` : `?key=${token}`) : ''); | ||
const url = this.formUrl(subUrl, params, token, accessToken); | ||
return this._put(url, data, accessToken); | ||
} | ||
delete(subUrl, params, token, accessToken) { | ||
const url = this.baseUrl + (subUrl.startsWith('/') ? '' : '/') + subUrl + this.parseParams(params) + | ||
(!accessToken ? (params ? `&key=${token}` : `?key=${token}`) : ''); | ||
const url = this.formUrl(subUrl, params, token, accessToken); | ||
return this._delete(url, accessToken); | ||
} | ||
imagePost(subUrl, image, imageType, params, token, accessToken) { | ||
const url = this.baseUrl + (subUrl.startsWith('/') ? '' : '/') + subUrl + this.parseParams(params) + | ||
(!accessToken ? (params ? `&key=${token}` : `?key=${token}`) : ''); | ||
const url = this.formUrl(subUrl, params, token, accessToken); | ||
return this._post(url, image, accessToken, `image/${imageType}`); | ||
} | ||
streamPut(subUrl, stream, params, token, accessToken) { | ||
const url = this.baseUrl + (subUrl.startsWith('/') ? '' : '/') + subUrl + this.parseParams(params) + | ||
(!accessToken ? (params ? `&key=${token}` : `?key=${token}`) : ''); | ||
const url = this.formUrl(subUrl, params, token, accessToken); | ||
return this._put(url, stream, accessToken, 'application/octet-stream'); | ||
} | ||
multipartStreamPost(subUrl, data, extraData, params, token, accessToken) { | ||
const url = this.baseUrl + (subUrl.startsWith('/') ? '' : '/') + subUrl + this.parseParams(params) + | ||
(!accessToken ? (params ? `&key=${token}` : `?key=${token}`) : ''); | ||
let boundary = '--------------------------'; | ||
for (let i = 0; i < 24; i++) { | ||
boundary += Math.floor(Math.random() * 10).toString(16); | ||
} | ||
const url = this.formUrl(subUrl, params, token, accessToken); | ||
const boundary = this.generateBoundary(); | ||
return this._postMultipart(url, data, extraData, accessToken, 'application/json', 'application/octet-stream', boundary); | ||
} | ||
multipartImagePost(subUrl, data, image, imageType, params, token, accessToken) { | ||
const url = this.baseUrl + (subUrl.startsWith('/') ? '' : '/') + subUrl + this.parseParams(params) + | ||
(!accessToken ? (params ? `&key=${token}` : `?key=${token}`) : ''); | ||
let boundary = '--------------------------'; | ||
for (let i = 0; i < 24; i++) { | ||
boundary += Math.floor(Math.random() * 10).toString(16); | ||
} | ||
const url = this.formUrl(subUrl, params, token, accessToken); | ||
const boundary = this.generateBoundary(); | ||
return this._postMultipart(url, data, image, accessToken, 'application/json', `image/${imageType}`, boundary); | ||
} | ||
multipartStreamPut(subUrl, data, extraData, params, token, accessToken) { | ||
const url = this.baseUrl + (subUrl.startsWith('/') ? '' : '/') + subUrl + this.parseParams(params) + | ||
(!accessToken ? (params ? `&key=${token}` : `?key=${token}`) : ''); | ||
let boundary = '--------------------------'; | ||
for (let i = 0; i < 24; i++) { | ||
boundary += Math.floor(Math.random() * 10).toString(16); | ||
} | ||
const url = this.formUrl(subUrl, params, token, accessToken); | ||
const boundary = this.generateBoundary(); | ||
return this._putMultipart(url, data, extraData, accessToken, 'application/json', 'application/octet-stream', boundary); | ||
@@ -114,2 +96,5 @@ } | ||
} | ||
formUrl(subUrl, params, token, accessToken) { | ||
return this.baseUrl + (subUrl.startsWith('/') ? '' : '/') + subUrl + this.parseParams(params) + (!accessToken ? (params ? `&key=${token}` : `?key=${token}`) : ''); | ||
} | ||
parseUrlToOptions(url, type, contentType) { | ||
@@ -128,2 +113,9 @@ const parsed = url_1.parse(url); | ||
} | ||
generateBoundary() { | ||
let boundary = '--------------------------'; | ||
for (let i = 0; i < 24; i++) { | ||
boundary += Math.floor(Math.random() * 10).toString(16); | ||
} | ||
return boundary; | ||
} | ||
req(options, reqFunction) { | ||
@@ -130,0 +122,0 @@ return new Promise((resolve, reject) => { |
{ | ||
"name": "popyt", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "A very easy to use promise-based Youtube Data v3 API.", | ||
@@ -36,10 +36,10 @@ "homepage": "https://bbothell.me/popyt", | ||
"@types/node": "13.13.12", | ||
"@typescript-eslint/eslint-plugin": "3.2.0", | ||
"@typescript-eslint/parser": "3.2.0", | ||
"@typescript-eslint/eslint-plugin": "3.3.0", | ||
"@typescript-eslint/parser": "3.3.0", | ||
"chai": "4.2.0", | ||
"coveralls": "3.1.0", | ||
"dotenv": "8.2.0", | ||
"eslint": "7.2.0", | ||
"eslint": "7.3.0", | ||
"eslint-plugin-import": "2.21.2", | ||
"eslint-plugin-jsdoc": "27.0.6", | ||
"eslint-plugin-jsdoc": "27.1.2", | ||
"fs-nextra": "0.5.1", | ||
@@ -46,0 +46,0 @@ "gulp": "4.0.2", |
@@ -1,2 +0,3 @@ | ||
import { YouTube, Playlist, Thumbnail, Banners, YTComment, Subscription, ChannelSection } from '..'; | ||
/// <reference types="node" /> | ||
import { YouTube, Playlist, Thumbnail, Banners, YTComment, Subscription, ChannelSection, ChannelBrandingSettings } from '..'; | ||
/** | ||
@@ -186,2 +187,40 @@ * A YouTube channel. | ||
unsubscribe(): Promise<void>; | ||
/** | ||
* Updates the channel's branding settings. | ||
* Must be using an access token with correct scopes. | ||
*/ | ||
updateBranding(branding: ChannelBrandingSettings): Promise<Channel>; | ||
/** | ||
* Updates the channel's localizations. | ||
* Must be using an access token with correct scopes. | ||
*/ | ||
updateLocalizations(localizations: { | ||
[key: string]: { | ||
title: string; | ||
description: string; | ||
}; | ||
}): Promise<Channel>; | ||
/** | ||
* Sets whether or not the channel is made for kids. | ||
* Must be using an access token with correct scopes. | ||
*/ | ||
setMadeForKids(madeForKids: boolean): Promise<Channel>; | ||
/** | ||
* Sets the channel's watermark. | ||
* Must be using an access token with correct scopes. | ||
*/ | ||
setWatermark(type: 'fromStart' | 'fromEnd', offset: number, duration: number, image: Buffer, imageType: 'png' | 'jpeg'): Promise<void>; | ||
/** | ||
* Unsets the channel's watermark. | ||
* Must be using an access token with correct scopes. | ||
*/ | ||
unsetWatermark(): Promise<void>; | ||
/** | ||
* Uploads and sets the channel's banner. | ||
* Must be using an access token with correct scopes. | ||
*/ | ||
setBanner(image: { | ||
data: Buffer; | ||
type: 'png' | 'jpeg'; | ||
}): Promise<Channel>; | ||
} |
@@ -96,2 +96,20 @@ import { YouTube, Video, Thumbnail } from '..'; | ||
/** | ||
* Edits the playlist. | ||
* Must be using an access token with correct scopes. | ||
* **If your request does not specify a value for a property that already has a value, | ||
* the property's existing value will be deleted.** | ||
* @param title A title for the playlist. | ||
* @param description A description of the playlist. | ||
* @param privacy Whether the video is private, public, or unlisted. | ||
* @param tags Tags pertaining to the playlist. | ||
* @param language The language of the playlist's default title and description. | ||
* @param localizations Translated titles and descriptions. | ||
*/ | ||
update(title: string, description?: string, privacy?: 'private' | 'public' | 'unlisted', tags?: string[], language?: string, localizations?: { | ||
[language: string]: { | ||
title: string; | ||
description: string; | ||
}; | ||
}): Promise<Playlist>; | ||
/** | ||
* Adds a [[Video]] to the playlist. | ||
@@ -120,2 +138,7 @@ * Must be using an access token with correct scopes. | ||
removeVideo(videoResolvable?: string, itemId?: string): Promise<never>; | ||
/** | ||
* Deletes the playlist. | ||
* Must be using an access token with correct scopes. | ||
*/ | ||
delete(): Promise<void>; | ||
} |
@@ -282,3 +282,3 @@ /// <reference types="node" /> | ||
/** | ||
* Adds a [[ChannelSection]] to a [[Channel]]. | ||
* Adds a [[ChannelSection]] to the authorized user's [[Channel]]. | ||
* Last tested 05/24/2020 10:11. PASSING | ||
@@ -285,0 +285,0 @@ * @param type The type of channel section. |
@@ -23,3 +23,5 @@ /// <reference types="node" /> | ||
private _putMultipart; | ||
private formUrl; | ||
private parseUrlToOptions; | ||
private generateBoundary; | ||
private req; | ||
@@ -26,0 +28,0 @@ private reqCallback; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
474614
5852