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.3 to 0.0.4

41

out/index.js

@@ -136,10 +136,43 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
const { data: results } = yield youtube.playlistItems.list({
let { data: results } = yield youtube.playlistItems.list({
playlistId,
part: 'snippet',
auth: this.token
auth: this.token,
maxResults: 50
});
let oldRes;
let videos = [];
for (let i = 0; i < results.items.length; i++) {
videos.push(new entities_1.Video(this, results.items[i]));
results.items.forEach(item => {
videos.push(new entities_1.Video(this, item));
});
while (true) {
if (!results.nextPageToken) {
break;
}
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;
}
oldRes = newResults;
newResults.items.forEach((item) => {
videos.push(new entities_1.Video(this, item));
});
if (!oldRes.nextPageToken) {
break;
}
}

@@ -146,0 +179,0 @@ return videos;

2

package.json
{
"name": "better-youtube-api",
"version": "0.0.3",
"version": "0.0.4",
"description": "Better than simple ones.",

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

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

import { google } from 'googleapis'
import { google, youtube_v3 } from 'googleapis'
import { Video, Channel, Playlist } from './entities'

@@ -138,12 +138,49 @@ import axios from 'axios'

public async getPlaylistItems (playlistId: string) {
const { data: results } = await youtube.playlistItems.list({
let { data: results } = await youtube.playlistItems.list({
playlistId,
part: 'snippet',
auth: this.token
auth: this.token,
maxResults: 50
})
let oldRes: youtube_v3.Schema$PlaylistItemListResponse
let videos: Video[] = []
for (let i = 0; i < results.items.length; i++) {
videos.push(new Video(this, results.items[i]))
results.items.forEach(item => {
videos.push(new Video(this, item))
})
while (true) {
if (!results.nextPageToken) {
break
}
let newResults: youtube_v3.Schema$PlaylistItemListResponse
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
newResults.items.forEach((item) => {
videos.push(new Video(this, item))
})
if (!oldRes.nextPageToken) {
break
}
}

@@ -150,0 +187,0 @@

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