Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

popyt

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

popyt - npm Package Compare versions

Comparing version 6.0.2 to 6.1.0

.eslintrc.json

129

out/index.js

@@ -21,7 +21,7 @@ "use strict";

exports.YouTube = void 0;
const entities_1 = require("./entities");
const util_1 = require("./util");
const types_1 = require("./types");
const services_1 = require("./services");
const oauth_1 = require("./oauth");
const services_1 = require("./services");
const types_1 = require("./types");
const entities_1 = require("./entities");
__exportStar(require("./entities"), exports);

@@ -53,2 +53,14 @@ __exportStar(require("./types"), exports);

_upload = new util_1.Request('https://www.googleapis.com/upload/youtube/v3');
/**
* @ignore
*/
_searchService = new services_1.SearchService(this);
/**
* @ignore
*/
_subscriptionService = new services_1.SubscriptionService(this);
/**
* @ignore
*/
_genericService = new services_1.GenericService(this);
token;

@@ -104,10 +116,9 @@ accessToken;

* Search supported entities on YouTube.
* @param types An array of types to search for. May be a single type or multiple types.
* @param searchTerm What to search for on YouTube.
* @param maxResults The maximum amount of results to find. Defaults to 10. Max 50.
* @param fields The fields to include in the response. Includes all by default.
* @param pageToken The page token to start at. Provide this if you have received it as output from a call to a search method.
* @param searchOptions Options related to the search including search filters,
* the number of pages, maximum number of results per page, and starting page token.
* Defaults to the maximum 50 items per page, as well as 1 page. Increase pages as high as you'd like.
*/
search(types, searchTerm, maxResults = 10, pageToken, fields) {
return services_1.SearchService.search(this, types, searchTerm, maxResults, pageToken, null, fields);
async search(searchTerm, searchOptions) {
return this._searchService.search({ searchTerm, ...searchOptions?.searchFilters, ...searchOptions?.pageOptions });
}

@@ -117,11 +128,8 @@ /**

* @param searchTerm What to search for on YouTube.
* @param maxResults The maximum amount of results to find. Defaults to 10. Max 50.
* @param pageToken The page token to start at. Provide this if you have received it as output from a call to a search method.
* @param channelId The channel ID that you want to specifically search for.
* @param category The category ID that you want to specifically search for.
* @param onlyEmbeddable Whether or not to return only embeddable videos.
* @param eventType The type of event you want to search for. Searches for everything by default.
* @param searchOptions Options related to the search including search filters,
* the number of pages, maximum number of results per page, and starting page token.
* Defaults to the maximum 50 items per page, as well as 1 page. Increase pages as high as you'd like.
*/
searchVideos(searchTerm, maxResults = 10, pageToken, category, channelId, onlyEmbeddable = false, eventType, type = 'any') {
return services_1.SearchService.search(this, [entities_1.Video], searchTerm, maxResults, pageToken, channelId, null, category, onlyEmbeddable, eventType, type);
async searchVideos(searchTerm, searchOptions) {
return this.search(searchTerm, { searchFilters: { ...searchOptions?.searchFilters, types: [entities_1.Video] }, pageOptions: searchOptions?.pageOptions });
}

@@ -131,7 +139,8 @@ /**

* @param searchTerm What to search for on YouTube.
* @param maxResults The maximum amount of results to find. Defaults to 10. Max 50.
* @param pageToken The page token to start at. Provide this if you have received it as output from a call to a search method.
* @param searchOptions Options related to the search including search filters,
* the number of pages, maximum number of results per page, and starting page token.
* Defaults to the maximum 50 items per page, as well as 1 page. Increase pages as high as you'd like.
*/
searchChannels(searchTerm, maxResults = 10, pageToken) {
return this.search([entities_1.Channel], searchTerm, maxResults, pageToken);
async searchChannels(searchTerm, searchOptions) {
return this.search(searchTerm, { searchFilters: { ...searchOptions?.searchFilters, types: [entities_1.Channel] }, pageOptions: searchOptions?.pageOptions });
}

@@ -141,7 +150,8 @@ /**

* @param searchTerm What to search for on YouTube.
* @param maxResults The maximum amount of results to find. Defaults to 10. Max 50.
* @param pageToken The page token to start at. Provide this if you have received it as output from a call to a search method.
* @param searchOptions Options related to the search including search filters,
* the number of pages, maximum number of results per page, and starting page token.
* Defaults to the maximum 50 items per page, as well as 1 page. Increase pages as high as you'd like.
*/
searchPlaylists(searchTerm, maxResults = 10, pageToken) {
return this.search([entities_1.Playlist], searchTerm, maxResults, pageToken);
async searchPlaylists(searchTerm, searchOptions) {
return this.search(searchTerm, { searchFilters: { ...searchOptions?.searchFilters, types: [entities_1.Playlist] }, pageOptions: searchOptions?.pageOptions });
}

@@ -155,4 +165,4 @@ /**

async getVideo(videoResolvable, parts) {
const id = await services_1.GenericService.getId(this, videoResolvable, entities_1.Video);
return services_1.GenericService.getItem(this, entities_1.Video, false, id, parts);
const id = await this._genericService.getId(videoResolvable, entities_1.Video);
return this._genericService.getItem(entities_1.Video, false, id, parts);
}

@@ -167,4 +177,4 @@ /**

async getChannel(channelResolvable, parts) {
const id = await services_1.GenericService.getId(this, channelResolvable, entities_1.Channel);
return services_1.GenericService.getItem(this, entities_1.Channel, false, id, parts);
const id = await this._genericService.getId(channelResolvable, entities_1.Channel);
return this._genericService.getItem(entities_1.Channel, false, id, parts);
}

@@ -178,4 +188,4 @@ /**

async getPlaylist(playlistResolvable, parts) {
const id = await services_1.GenericService.getId(this, playlistResolvable, entities_1.Playlist);
return services_1.GenericService.getItem(this, entities_1.Playlist, false, id, parts);
const id = await this._genericService.getId(playlistResolvable, entities_1.Playlist);
return this._genericService.getItem(entities_1.Playlist, false, id, parts);
}

@@ -187,4 +197,4 @@ /**

*/
getComment(commentId, parts) {
return services_1.GenericService.getItem(this, entities_1.YTComment, false, commentId, parts);
async getComment(commentId, parts) {
return this._genericService.getItem(entities_1.YTComment, false, commentId, parts);
}

@@ -196,4 +206,4 @@ /**

*/
getSubscription(subscriptionId, parts) {
return services_1.GenericService.getItem(this, entities_1.Subscription, false, subscriptionId, parts);
async getSubscription(subscriptionId, parts) {
return this._genericService.getItem(entities_1.Subscription, false, subscriptionId, parts);
}

@@ -204,4 +214,4 @@ /**

*/
getCategory(categoryId) {
return services_1.GenericService.getItem(this, entities_1.VideoCategory, false, categoryId);
async getCategory(categoryId) {
return this._genericService.getItem(entities_1.VideoCategory, false, categoryId);
}

@@ -213,4 +223,4 @@ /**

*/
getChannelSection(sectionId, parts) {
return services_1.GenericService.getItem(this, entities_1.ChannelSection, false, sectionId, parts);
async getChannelSection(sectionId, parts) {
return this._genericService.getItem(entities_1.ChannelSection, false, sectionId, parts);
}

@@ -224,5 +234,5 @@ /**

async getSubscriptionByChannels(subscriberResolvable, channelResolvable, parts) {
const subscriberId = await services_1.GenericService.getId(this, subscriberResolvable, entities_1.Channel);
const channelId = await services_1.GenericService.getId(this, channelResolvable, entities_1.Channel);
return services_1.SubscriptionService.getSubscriptionByChannels(this, subscriberId, channelId, parts);
const subscriberId = await this._genericService.getId(subscriberResolvable, entities_1.Channel);
const channelId = await this._genericService.getId(channelResolvable, entities_1.Channel);
return this._subscriptionService.getSubscriptionByChannels(subscriberId, channelId, parts);
}

@@ -239,4 +249,4 @@ /**

async getPlaylistItems(playlistResolvable, pageOptions, parts) {
const playlistId = await services_1.GenericService.getId(this, playlistResolvable, entities_1.Playlist);
return (await services_1.GenericService.getPaginatedItems({ youtube: this, type: types_1.PaginatedItemType.PlaylistItems, id: playlistId, ...pageOptions, parts })).results;
const playlistId = await this._genericService.getId(playlistResolvable, entities_1.Playlist);
return (await this._genericService.getPaginatedItems({ type: types_1.PaginatedItemType.PlaylistItems, id: playlistId, ...pageOptions, parts })).items;
}

@@ -253,4 +263,4 @@ /**

async getVideoComments(videoResolvable, pageOptions, parts) {
const videoId = await services_1.GenericService.getId(this, videoResolvable, entities_1.Video);
return (await services_1.GenericService.getPaginatedItems({ youtube: this, type: types_1.PaginatedItemType.VideoComments, id: videoId, ...pageOptions, parts })).results;
const videoId = await this._genericService.getId(videoResolvable, entities_1.Video);
return (await this._genericService.getPaginatedItems({ type: types_1.PaginatedItemType.VideoComments, id: videoId, ...pageOptions, parts })).items;
}

@@ -269,4 +279,4 @@ /**

async getChannelComments(channelResolvable, pageOptions, parts) {
const channelId = await services_1.GenericService.getId(this, channelResolvable, entities_1.Channel);
return (await services_1.GenericService.getPaginatedItems({ youtube: this, type: types_1.PaginatedItemType.ChannelComments, id: channelId, ...pageOptions, parts })).results;
const channelId = await this._genericService.getId(channelResolvable, entities_1.Channel);
return (await this._genericService.getPaginatedItems({ type: types_1.PaginatedItemType.ChannelComments, id: channelId, ...pageOptions, parts })).items;
}

@@ -283,4 +293,4 @@ /**

async getChannelPlaylists(channelResolvable, pageOptions, parts) {
const channelId = await services_1.GenericService.getId(this, channelResolvable, entities_1.Channel);
return (await services_1.GenericService.getPaginatedItems({ youtube: this, type: types_1.PaginatedItemType.Playlists, id: channelId, ...pageOptions, parts })).results;
const channelId = await this._genericService.getId(channelResolvable, entities_1.Channel);
return (await this._genericService.getPaginatedItems({ type: types_1.PaginatedItemType.Playlists, id: channelId, ...pageOptions, parts })).items;
}

@@ -297,4 +307,4 @@ /**

async getChannelSubscriptions(channelResolvable, pageOptions, parts) {
const channelId = await services_1.GenericService.getId(this, channelResolvable, entities_1.Channel);
return (await services_1.GenericService.getPaginatedItems({ youtube: this, type: types_1.PaginatedItemType.Subscriptions, id: channelId, ...pageOptions, parts })).results;
const channelId = await this._genericService.getId(channelResolvable, entities_1.Channel);
return (await this._genericService.getPaginatedItems({ type: types_1.PaginatedItemType.Subscriptions, id: channelId, ...pageOptions, parts })).items;
}

@@ -311,3 +321,3 @@ /**

async getCommentReplies(commentId, pageOptions, parts) {
return (await services_1.GenericService.getPaginatedItems({ youtube: this, type: types_1.PaginatedItemType.CommentReplies, id: commentId, ...pageOptions, parts })).results;
return (await this._genericService.getPaginatedItems({ type: types_1.PaginatedItemType.CommentReplies, id: commentId, ...pageOptions, parts })).items;
}

@@ -321,4 +331,4 @@ /**

async getChannelSections(channelResolvable, parts) {
const channelId = await services_1.GenericService.getId(this, channelResolvable, entities_1.Channel);
return (await services_1.GenericService.getPaginatedItems({ youtube: this, type: types_1.PaginatedItemType.ChannelSections, id: channelId, parts })).results;
const channelId = await this._genericService.getId(channelResolvable, entities_1.Channel);
return (await this._genericService.getPaginatedItems({ type: types_1.PaginatedItemType.ChannelSections, id: channelId, parts })).items;
}

@@ -329,3 +339,3 @@ /**

async getCategories() {
return (await services_1.GenericService.getPaginatedItems({ youtube: this, type: types_1.PaginatedItemType.VideoCategories })).results;
return (await this._genericService.getPaginatedItems({ type: types_1.PaginatedItemType.VideoCategories })).items;
}

@@ -336,3 +346,3 @@ /**

async getLanguages() {
return (await services_1.GenericService.getPaginatedItems({ youtube: this, type: types_1.PaginatedItemType.Languages })).results;
return (await this._genericService.getPaginatedItems({ type: types_1.PaginatedItemType.Languages })).items;
}

@@ -343,3 +353,3 @@ /**

async getRegions() {
return (await services_1.GenericService.getPaginatedItems({ youtube: this, type: types_1.PaginatedItemType.Regions })).results;
return (await this._genericService.getPaginatedItems({ type: types_1.PaginatedItemType.Regions })).items;
}

@@ -349,3 +359,2 @@ }

exports.default = YouTube;
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map
{
"name": "popyt",
"version": "6.0.2",
"version": "6.1.0",
"description": "A very easy to use promise-based Youtube Data v3 API.",

@@ -9,7 +9,11 @@ "homepage": "https://brandonbothell.github.io/popyt/",

"scripts": {
"test": "mocha --exit --require ts-node/register/transpile-only --require source-map-support/register --parallel --recursive \"./test/!(oauth).spec.ts\" --timeout 10000",
"test": "mocha --exit --require ts-node/register/transpile-only --require source-map-support/register --recursive \"./test/!(oauth).spec.ts\" --timeout 10000",
"coverage": "tsc && cross-env NODE_ENV=test nyc --reporter=json yarn test",
"coverage:html": "tsc && cross-env NODE_ENV=test nyc --reporter=lcov yarn test",
"docs:build": "yarn workspace docusaurus build",
"docs:publish": "yarn workspace docusaurus deploy",
"lint": "eslint src/**/*.ts test/**/*.ts"
"docs:serve": "yarn workspace docusaurus serve",
"docs:test": "yarn workspace docusaurus start",
"lint": "eslint src/**/*.ts test/**/*.ts",
"build": "tsc"
},

@@ -43,7 +47,6 @@ "nyc": {

"@types/node": "20.3.1",
"@typescript-eslint/eslint-plugin": "5.59.11",
"@typescript-eslint/parser": "5.59.11",
"@typescript-eslint/eslint-plugin": "5.60.0",
"@typescript-eslint/parser": "5.60.0",
"chai": "4.3.7",
"cross-env": "7.0.3",
"docusaurus-plugin-typedoc": "^0.19.2",
"dotenv": "16.3.1",

@@ -53,7 +56,3 @@ "eslint": "8.43.0",

"eslint-plugin-jsdoc": "46.2.6",
"fs-nextra": "0.5.1",
"gulp": "4.0.2",
"gulp-sourcemaps": "3.0.0",
"gulp-typescript": "6.0.0-alpha.1",
"merge2": "1.4.1",
"eslint-plugin-unused-imports": "^2.0.0",
"mocha": "10.2.0",

@@ -63,4 +62,2 @@ "nyc": "15.1.0",

"ts-node": "10.9.1",
"typedoc": "0.24.8",
"typedoc-plugin-markdown": "^3.15.3",
"typescript": "5.1.3"

@@ -67,0 +64,0 @@ },

@@ -1,2 +0,2 @@

# popyt
# Popyt
Want to access data from the YouTube Data v3 API? Want a Node.js YouTube API wrapper with typings, promises, and caching? No problem! We've got ya covered. `npm i popyt`

@@ -14,4 +14,4 @@

# Examples
## See the [main class documentation](https://brandonbothell.github.io/popyt/docs/api/classes/Library_Exports.YouTube).
Here are some basic methods:
## See the [5-minute tutorial](https://brandonbothell.github.io/popyt/docs/tutorial/intro).
Here are some basic methods ([try it on RunKit](https://runkit.com/brandonbothell/fetch-a-video)):

@@ -58,4 +58,4 @@ Instantiate the object:

```js
const videos = await youtube.searchVideos('never gonna give you up', 12)
console.log(videos) // array of 12 partial video objects
const search = await youtube.searchVideos('never gonna give you up')
console.log(search.results.map(v => v.title).join('\n')) // titles of 50 beautiful videos
```

@@ -62,0 +62,0 @@

@@ -16,3 +16,2 @@ {

"include": [
"./gulpfile.ts",
"./test/**/*.ts",

@@ -19,0 +18,0 @@ "docusaurus/**/*.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc