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

better-youtube-api

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

better-youtube-api - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

41

out/index.js

@@ -209,30 +209,21 @@ "use strict";

}
let oldRes;
let oldRes = results;
let videos = [];
const totalResults = results.pageInfo.totalResults;
const perPage = 50;
const pages = Math.floor(totalResults / perPage);
results.items.forEach(item => {
videos.push(new entities_1.Video(this, item));
});
const interval = setInterval(() => __awaiter(this, void 0, void 0, function* () {
if (!results.nextPageToken || !oldRes.nextPageToken) {
clearInterval(interval);
}
let newResults;
if (!oldRes) {
newResults = (yield youtube.playlistItems.list({
playlistId,
part: 'snippet',
auth: this.token,
maxResults: 50,
pageToken: results.nextPageToken
})).data;
}
else {
newResults = (yield youtube.playlistItems.list({
playlistId,
part: 'snippet',
auth: this.token,
maxResults: 50,
pageToken: oldRes.nextPageToken
})).data;
}
if (pages === 0) {
return videos;
}
for (let i = 0; i < pages; i++) {
const { data: newResults } = yield youtube.playlistItems.list({
playlistId,
part: 'snippet',
auth: this.token,
maxResults: 50,
pageToken: oldRes.nextPageToken
});
oldRes = newResults;

@@ -242,3 +233,3 @@ newResults.items.forEach((item) => {

});
}), 1);
}
return videos;

@@ -245,0 +236,0 @@ });

{
"name": "better-youtube-api",
"version": "0.0.6",
"version": "0.0.7",
"description": "Better than simple ones.",

@@ -5,0 +5,0 @@ "main": "out/index.js",

@@ -226,4 +226,7 @@ import { google, youtube_v3 } from 'googleapis'

let oldRes: youtube_v3.Schema$PlaylistItemListResponse
let oldRes: youtube_v3.Schema$PlaylistItemListResponse = results
let videos: Video[] = []
const totalResults = results.pageInfo.totalResults
const perPage = 50
const pages = Math.floor(totalResults / perPage)

@@ -234,27 +237,15 @@ results.items.forEach(item => {

const interval = setInterval(async () => {
if (!results.nextPageToken || !oldRes.nextPageToken) {
clearInterval(interval)
}
if (pages === 0) {
return videos
}
let newResults: youtube_v3.Schema$PlaylistItemListResponse
for (let i = 0; i < pages; i++) {
const { data: newResults } = await youtube.playlistItems.list({
playlistId,
part: 'snippet',
auth: this.token,
maxResults: 50,
pageToken: oldRes.nextPageToken
})
if (!oldRes) {
newResults = (await youtube.playlistItems.list({
playlistId,
part: 'snippet',
auth: this.token,
maxResults: 50,
pageToken: results.nextPageToken
})).data
} else {
newResults = (await youtube.playlistItems.list({
playlistId,
part: 'snippet',
auth: this.token,
maxResults: 50,
pageToken: oldRes.nextPageToken
})).data
}
oldRes = newResults

@@ -264,3 +255,3 @@ newResults.items.forEach((item) => {

})
}, 1)
}

@@ -267,0 +258,0 @@ return videos

Sorry, the diff of this file is not supported yet

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