Code Monkey home page Code Monkey logo

node-ytpl's Introduction

DEPRECATED

This repo is no longer supported, please consider using the official api instead.

node-ytpl

NPM version NPM downloads codecov Known Vulnerabilities Discord

Simple js only package to resolve YouTube Playlists. Does not require any login or Google-API-Key.

Support

You can contact us for support on our chat server

Usage

const ytpl = require('ytpl');

const playlist = await ytpl('UU_aEa8K-EOJ3D6gOs7HcyNg');

API

ytpl(id, [options])

Attempts to resolve the given playlist id

  • id

    • id of the yt-playlist
    • or a playlist url
    • or a user url (resolves to uploaded playlist)
    • or a channel url (resolves to uploaded playlist)
  • options

    • object with options
    • possible settings:
    • gl[String] -> 2-Digit Code of a Country, defaults to US - Allows for localisation of the request
    • hl[String] -> 2-Digit Code for a Language, defaults to en - Allows for localisation of the request
    • limit[Number] -> limits the pulled items, defaults to 100, set to Infinity to get the whole playlist - numbers <1 result in the default being used
    • pages[Number] -> limits the pulled pages, pages contain 100 items, set to Infinity to get the whole playlist - numbers <1 result in the default limit being used - overwrites limit
    • requestOptions[Object] -> Additional parameters to passed to miniget, which is used to do the https requests
  • returns a Promise

  • Example response

ytpl.continueReq(continuationData)

Continues a previous request by pulling yet another page.
The previous request had to be done using pages limitation.

Usage

const ytpl = require('ytpl');

const firstResultBatch = await ytpl('UU_aEa8K-EOJ3D6gOs7HcyNg', { pages: 1 });
const secondResultBatch = ytpl.continueReq(firstResultBatch.continuation);
const thirdResultBatch = ytpl.continueReq(secondResultBatch.continuation);

// You can now use the .items property of all result batches e.g.:
console.log(firstResultBatch.items);
console.log(secondResultBatch.items);
console.log(thirdResultBatch.items);
  • returns a Promise resolving into { continuation, items }

ytpl.validateID(string)

Returns true if able to parse out a (formally) valid playlist ID.

ytpl.getPlaylistID(string)

Returns a playlist ID from a YouTube URL. Can be called with the playlist ID directly, in which case it just resolves.

  • returns a promise resolving into a string containing the id

Related / Works well with

Install

npm install --save ytpl

License

MIT

node-ytpl's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

node-ytpl's Issues

An in-range update of eslint is breaking the build 🚨

The devDependency eslint was updated from 6.5.1 to 6.6.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Release Notes for v6.6.0
  • 39dfe08 Update: false positives in function-call-argument-newline (fixes #12123) (#12280) (Scott O'Hara)
  • 4d84210 Update: improve report location for no-trailing-spaces (fixes #12315) (#12477) (Milos Djermanovic)
  • c6a7745 Update: no-trailing-spaces false negatives after comments (fixes #12479) (#12480) (Milos Djermanovic)
  • 0bffe95 Fix: no-misleading-character-class crash on invalid regex (fixes #12169) (#12347) (Milos Djermanovic)
  • c6a9a3b Update: Add enforceForIndexOf option to use-isnan (fixes #12207) (#12379) (Milos Djermanovic)
  • 364877b Update: measure plugin loading time and output in debug message (#12395) (Victor Homyakov)
  • 1744fab Fix: operator-assignment removes and duplicates comments (#12485) (Milos Djermanovic)
  • 52ca11a Fix: operator-assignment invalid autofix with adjacent tokens (#12483) (Milos Djermanovic)
  • 0f6d0dc Fix: CLIEngine#addPlugin reset lastConfigArrays (fixes #12425) (#12468) (Toru Nagashima)
  • 923a8cb Chore: Fix lint failure in JSDoc comment (#12489) (Brandon Mills)
  • aac3be4 Update: Add ignored prop regex no-param-reassign (#11275) (Luke Bennett)
  • e5382d6 Chore: Remove unused parameter in dot-location (#12464) (Milos Djermanovic)
  • 49faefb Fix: no-obj-calls false positive (fixes #12437) (#12467) (Toru Nagashima)
  • b3dbd96 Fix: problematic installation issue (fixes #11018) (#12309) (Toru Nagashima)
  • cd7c29b Sponsors: Sync README with website (ESLint Jenkins)
  • 8233873 Docs: Add note about Node.js requiring SSL support (fixes #11413) (#12475) (Nicholas C. Zakas)
  • 89e8aaf Fix: improve report location for no-tabs (#12471) (Milos Djermanovic)
  • 7dffe48 Update: Enable function string option in comma-dangle (fixes #12058) (#12462) (YeonJuan)
  • e15e1f9 Docs: fix doc for no-unneeded-ternary rule (fixes #12098) (#12410) (Sam Rae)
  • b1dc58f Sponsors: Sync README with website (ESLint Jenkins)
  • 61749c9 Chore: Provide debug log for parser errors (#12474) (Brad Zacher)
  • 7c8bbe0 Update: enforceForOrderingRelations no-unsafe-negation (fixes #12163) (#12414) (Sam Rae)
  • 349ed67 Update: improve report location for no-mixed-operators (#12328) (Chiawen Chen)
  • a102eaa Fix: prefer-numeric-literals invalid autofix with adjacent tokens (#12387) (Milos Djermanovic)
  • 6e7c18d Update: enforceForNewInMemberExpressions no-extra-parens (fixes #12428) (#12436) (Milos Djermanovic)
  • 51fbbd7 Fix: array-bracket-newline consistent error with comments (fixes #12416) (#12441) (Milos Djermanovic)
  • e657d4c Fix: report full dot location in dot-location (#12452) (Milos Djermanovic)
  • 2d6e345 Update: make isSpaceBetweenTokens() ignore newline in comments (#12407) (YeonJuan)
  • 84f71de Update: remove default overrides in keyword-spacing (fixes #12369) (#12411) (YeonJuan)
  • 18a0b0e Update: improve report location for no-space-in-parens (#12364) (Chiawen Chen)
  • d61c8a5 Update: improve report location for no-multi-spaces (#12329) (Chiawen Chen)
  • 561093f Upgrade: bump inquirer to ^7.0.0 (#12440) (Joe Graham)
  • fb633b2 Chore: Add a script for testing with more control (#12444) (Eric Wang)
  • 012ec51 Sponsors: Sync README with website (ESLint Jenkins)
  • 874fe16 New: pass cwd from cli engine (#12389) (Eric Wang)
  • b962775 Update: no-self-assign should detect member expression with this (#12279) (Tibor Blenessy)
  • 02977f2 Docs: Clarify eslint:recommended semver policy (#12429) (Kevin Partington)
  • 97045ae Docs: Fixes object type for rules in "Use a Plugin" (#12409) (Daisy Develops)
  • 24ca088 Docs: Fix typo in v6 migration guide (#12412) (Benjamim Sonntag)
  • b094008 Chore: update version parameter name (#12402) (Toru Nagashima)
  • e5637ba Chore: enable jsdoc/require-description (#12365) (Kai Cataldo)
  • d31f337 Sponsors: Sync README with website (ESLint Jenkins)
  • 7ffb22f Chore: Clean up inline directive parsing (#12375) (Jordan Eldredge)
  • 84467c0 Docs: fix wrong max-depth example (fixes #11991) (#12358) (Gabriel R Sezefredo)
  • 3642342 Docs: Fix minor formatting/grammar errors (#12371) (cherryblossom000)
  • c47fa0d Docs: Fix missing word in sentence (#12361) (Dan Boulet)
  • 8108f49 Chore: enable additional eslint-plugin-jsdoc rules (#12336) (Kai Cataldo)
  • b718d2e Chore: update issue template with --eslint-fix flag (#12352) (James George)
  • 20ba14d Sponsors: Sync README with website (ESLint Jenkins)
  • 566a947 Sponsors: Sync README with website (ESLint Jenkins)
  • 070cbd0 Sponsors: Sync README with website (ESLint Jenkins)
Commits

The new version differs by 53 commits.

  • 879c373 6.6.0
  • c8ba30a Build: changelog update for 6.6.0
  • 39dfe08 Update: false positives in function-call-argument-newline (fixes #12123) (#12280)
  • 4d84210 Update: improve report location for no-trailing-spaces (fixes #12315) (#12477)
  • c6a7745 Update: no-trailing-spaces false negatives after comments (fixes #12479) (#12480)
  • 0bffe95 Fix: no-misleading-character-class crash on invalid regex (fixes #12169) (#12347)
  • c6a9a3b Update: Add enforceForIndexOf option to use-isnan (fixes #12207) (#12379)
  • 364877b Update: measure plugin loading time and output in debug message (#12395)
  • 1744fab Fix: operator-assignment removes and duplicates comments (#12485)
  • 52ca11a Fix: operator-assignment invalid autofix with adjacent tokens (#12483)
  • 0f6d0dc Fix: CLIEngine#addPlugin reset lastConfigArrays (fixes #12425) (#12468)
  • 923a8cb Chore: Fix lint failure in JSDoc comment (#12489)
  • aac3be4 Update: Add ignored prop regex no-param-reassign (#11275)
  • e5382d6 Chore: Remove unused parameter in dot-location (#12464)
  • 49faefb Fix: no-obj-calls false positive (fixes #12437) (#12467)

There are 53 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Add author

Can we add an author prop please?

Adding author: UTIL.parseText(info.shortBylineText), to the object returned by parseItem seems to do the trick

Not able to fetch playlist

I'm getting this error

We’ll stop supporting this browser soon. For the best experience please <a href="/supported_browsers">update your browser</a>

I believe because you have disable_polymer=true, they will no more support this browser.

Chance of encountering HTTP error 429?

Hello,

Looking at your code, it seems that results are fetched in iterations until limit is reached. To my knowledge, YouTube checks for bot-like requests and responds with HTTP error 429 if too many requests are made within a short period. I recently encountered this while playing with various YouTube scraping libraries and my IP address got 429ed by Google :( ...had to wait a couple of hours for Google to unblock me.

In your experience, what is the chance of getting 429ed if I set a limit of, say, 500? Would it make a difference if a slight delay (say 1-2 seconds) is added before each request?

The same goes for your ytsr library ;)

Regards,
Patrick

Playlists Links no longer working

Hi there I have noticed that my playlist functionality using this no longer works.

I have found out that the issue lies in the following piece of code in ytpl\lib\util.js:

`exports.getGeneralInfo = (body, plistId) => {
const importantTxt = exports.between(body, 'branded-page-box clearfix', '

');
const authorMatch = importantTxt.match(AUTHOR_REFLINK_REGEXP);
const description = exports.removeHtml(exports.between(
importantTxt,
'',
'
',
).replace(/<button class="yt-uix-button[\s\S]+/, ''));

return {
id: plistId,
url: PLAYLIST_URL + plistId,
title: exports.removeHtml(importantTxt.match(PLAYLIST_NAME_REGEXP)[1]),
visibility: importantTxt.includes('data-tooltip-text="') ? 'link only' : 'everyone',
description: description ? exports.removeHtml(description) : null,
total_items: Number(authorMatch[2].replace(/\D/g, '')),
views: Number(authorMatch[3].replace(/\D/g, '')),
last_updated: authorMatch[4],
author: {
id: exports.between(importantTxt, 'data-all-playlists-url="/channel/', '/playlists"'),
name: exports.removeHtml(exports.between(authorMatch[1], '>', '')),
avatar: exports.between(body, '<img class="channel-header-profile-image" src="', '" title="'),
user: importantTxt.includes('/user/') ? exports.between(authorMatch[1], 'href="/user/', '"') : null,
channel_url: URL.resolve(
PLAYLIST_URL,
/channel/${exports.between(importantTxt, 'data-all-playlists-url="/channel/', '/playlists"')},
),
user_url: importantTxt.includes('/user/') ?
URL.resolve(PLAYLIST_URL, exports.between(authorMatch[1], 'href="', '"')) :
null,
},
nextpage: null,
items: [],
};
};
`

Currently, importantTxt is not getting populated when I send a playlist
Example:
https://www.youtube.com/playlist?list=PLhrG05fbuPKdFR8dBbGPa2k3H3y3rspPS

This is the error I get:
`title: exports.removeHtml(importantTxt.match(PLAYLIST_NAME_REGEXP)[1]),
^

TypeError: Cannot read property '1' of null
at Object.exports.getGeneralInfo (c:\Users\Manny\Documents\Crescendo\node_modules\ytpl\lib\util.js:22:71)
at IncomingMessage. (c:\Users\Manny\Documents\Crescendo\node_modules\ytpl\lib\firstpage.js:30:29)
at IncomingMessage.emit (events.js:322:22)
at endReadableNT (_stream_readable.js:1187:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Process exited with code 1`

Incorrect total_items count

Hi, the API returns wrong total_items count if there're more than 1k videos in playlist.

Steps to reproduce:

  • Open any channel with more than 1k videos on it
  • Try to get videos from it (channel/user uploaded videos playlist)
  • It returns only the first number from total count (i.e. 1234 video in total, but it returns "1").

I'm currently preparing a PR to fix it. Created this issue to get id reference.

Add Other Video Thumbnails to Items List

Hello!

It would be nice if this module could include an array of the other video thumbnail qualities that are available for the items within a playlist Specifically I'd like to use the thumbnails provided by YouTube that don't have the black bars surrounding the thumbnail.

Thank you!

Cannot read property 'indexOf' of undefined

When calling ytpl with a limit option greater than or equal to the number of videos in a given playlist, it throws this error:

pos = haystack.indexOf(left);
^

TypeError: Cannot read property 'indexOf' of undefined
at Object.exports.between (C:\Users\Jacob's PC\node_modules\ytpl\lib\util.js:148:18)
at IncomingMessage.resp.on (C:\Users\Jacob's PC\node_modules\ytpl\lib\nonfirstpage.js:22:45)
at IncomingMessage.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1094:12)
at process._tickCallback (internal/process/next_tick.js:63:19)

Also, although this isn't directly related to the issue, but it appears that setting limit to infinity (Math.max) or 0, the default limit is still applied to the operation.

Error: Some playlist features are going away soon.

invoking ytpl on any playlist gives this result:

Some playlist features are going away soon. Learn more

used default snippet:

var ytpl = require('ytpl');

ytpl('UU_aEa8K-EOJ3D6gOs7HcyNg').then(playlist => {
  dosth(playlist);
}).catch(err => {
  console.error(err);
});

(wip) Error: continueReq only allowed for paged requests

Hello,

Just did a bit of testing with the wip branch (sorry, couldn't wait).. I got an error with continueReq():

Error: continueReq only allowed for paged requests

I just fed the continuation object returned by ytpl to continueReq(), like the example in the Readme.

Looking at the line that throws this error:

if (!isNaN(args[3].limit)) throw new Error('continueReq only allowed for paged requests');

But then, args[3].limit (i.e. opts.limit) is always Infinity when continuation is returned. That means !isNaN(args[3].limit) will always be true (hence the error)?

I haven't tested ytsr yet, but glancing at the code I suppose it's going to be the same ;) ?

Thanks,
Patrick

Cannot read property '1' of null

Hello, i've been getting this issue latelly 100% of the time i try to use your lib

TypeError: Cannot read property '1' of null
    at Object.exports.getGeneralInfo ({INSERT_PROJECT_FOLDER_HERE}/node_modules/ytpl/lib/util.js:22:71)
    at IncomingMessage.<anonymous> ({INSERT_PROJECT_FOLDER_HERE}/node_modules/ytpl/lib/firstpage.js:30:29)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1221:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

this is the piece of code where i use your lib:

ytpl(playlistId, (err, result) => {
	if(err) {
		console.log(err);
	}else {
		...{DATA_PROCESSING_FOR_WHAT_COMES_INSIDE_THE_result_VAR}...
	}
});

the variable playlistId contains the id of the playlist found on every youtube playlist URL GET parameter "list".

Support YouTube Music Playlist

Support YouTube Music playlist or at least remove it from the regular expressions.
YouTube Music is not available in my country so I haven't tried parsing it but I think it is similar to a YouTube playlist.

Cannot retrieve a playlist page that has no author information

When trying to retrieve the following playlist https://www.youtube.com/playlist?list=OLAK5uy_msBpY2-SQoKH1j156gHSF_x551BIlrqlY the following error is thrown:

    total_items: Number(authorMatch[2].replace(/\D/g, '')),
                                   ^

TypeError: Cannot read property '2' of null
    at Object.exports.getGeneralInfo (D:\Projects\Kissa\discord-bot\node_modules\ytpl\lib\util.js:25:36)
    at IncomingMessage.<anonymous> (D:\Projects\Kissa\discord-bot\node_modules\ytpl\lib\firstpage.js:30:29)
    at IncomingMessage.emit (events.js:228:7)
    at endReadableNT (_stream_readable.js:1185:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)

The issue seems to be because the playlist page does not contain information about the author/channel. Should these types of playlists be supported?

TypeError "listener" arguement must be a function (nodejs v8.17.0)

I'm trying to use the module but I always get the error below. This isn't the case when I use nodejs v12.16.3, but unfortunately I have to use 8.17.0 due to some other dependencies.
Your other node module "ytsr" for searching YouTube videos has the exact same issue.

Steps to reproduce:

  • switch to nodejs v8.17.0 (npm install -g n && n 8.17.0)
  • paste the example code from the readme into a js file
  • install the ytpl node module
  • run the js file

Error message:

events.js:340
    throw new TypeError('"listener" argument must be a function');
    ^

TypeError: "listener" argument must be a function
    at ClientRequest.once (events.js:340:11)
    at new ClientRequest (_http_client.js:174:10)
    at Object.request (http.js:39:10)
    at Object.request (https.js:245:15)
    at Object.get (https.js:249:21)
    at module.exports (/Users/user/Documents/Coding/test/node_modules/ytpl/lib/firstpage.js:11:25)
    at util.getPlaylistId (/Users/user/Documents/Coding/test/node_modules/ytpl/lib/main.js:38:5)
    at Object.exports.getPlaylistId (/Users/user/Documents/Coding/test/node_modules/ytpl/lib/util.js:90:12)
    at module.exports (/Users/user/Documents/Coding/test/node_modules/ytpl/lib/main.js:35:8)
    at Object.<anonymous> (/Users/user/Documents/Coding/test/test.js:3:1)

Album id as argument

Any reason why ytpl(id) can accept a plain list ID (PLAYLIST_REGEX) but not an album ID (ALBUM_REGEX)?

e.g. ytpl('?list=OLAK5uy_kAVbBOLaBZPmxyy3OP0aEAwA-87MgV004') works, but ytpl('OLAK5uy_kAVbBOLaBZPmxyy3OP0aEAwA-87MgV004') throws:

Error: Unable to find a id in OLAK5uy_kAVbBOLaBZPmxyy3OP0aEAwA-87MgV004

(wip) TypeError: Cannot read property 'map' of undefined

Hello,

I have found that, for some playlists, such as this one, ytpl fails when trying to parse the description text.

Dumping the playlist info to console shows this:

{ thumbnailRenderer: { playlistVideoThumbnailRenderer: { thumbnail: [Object] } },
title: { runs: [ [Object] ] },
stats:
[ { runs: [Array] },
{ simpleText: '4,413 views' },
{ runs: [Array] } ],
menu:
{ menuRenderer:
{ items: [Array],
trackingParams: 'CAEQk-8CIhMIqNmJ-azG7QIVBQZgCh1XKgeS',
topLevelButtons: [Array],
accessibility: [Object] } },
thumbnailOverlays: [ { thumbnailOverlaySidePanelRenderer: [Object] } ],
navigationEndpoint:
{ clickTrackingParams: 'CAEQk-8CIhMIqNmJ-azG7QIVBQZgCh1XKgeSWiRWTFBMR3pDNGdUY2Viel9EdEVyQlVLTmRaWmRQd2tiNWUtcHKaAQMQ-iw=',
commandMetadata: { webCommandMetadata: [Object] },
watchEndpoint:
{ videoId: 'HvJ21S5qEjQ',
playlistId: 'PLGzC4gTcebz_DtErBUKNdZZdPwkb5e-pr' } },
description: {},
showMoreText: { runs: [ [Object] ] } }
...

Instead of null, the description field is an empty object, so parseText() in utils fails to get the 'simpleText' or 'runs' property from it.

I am able to bypass the error by changing the following line in utils.js from:

const parseText = exports.parseText = txt => txt.simpleText || txt.runs.map(a => a.text).join('');

to this:

const parseText = exports.parseText = txt => txt.simpleText || (txt.runs ? txt.runs.map(a => a.text).join('') : null);

I'm not sure if this is the correct way to this, though.

Btw, is it fine with you to raise issues on the wip branch since I know you're still working on it? I just thought it might be more appropriate to point out issues as I find them, rather than seeing them committed to the master branch.

-Patrick

Error: We'll stop supporting this browser soon.

Whenever I use YTPL to grab a playlist from YouTube, I get this error message.

Error: We’ll stop supporting this browser soon. For the best experience please <a href="/supported_browsers">update your browser</a>.
    at IncomingMessage.resp.on (/home/pi/.djsbots/Nookbot/node_modules/ytpl/lib/firstpage.js:26:49)
    at IncomingMessage.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1143:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)

TypeError: Cannot read property '4' of null

TypeError: Cannot read property '4' of null

    async function getPlaylistHandler(req, res) {
    const playlist = await ytpl(req.body.playlist);
  at Object.<anonymous>.exports.getGeneralInfo (node_modules/ytpl/lib/util.js:39:31)
  at Object.<anonymous>.module.exports (node_modules/ytpl/lib/firstpage.js:29:25)
  at Object.<anonymous>.module.exports (node_modules/ytpl/lib/main.js:13:20)
  at getPlaylistHandler (lib/server.js:56:20)

version installed: 1.0.1

counter new design

may enforce &disable_polymer=true to counter new design and even error messages related to it

Problem with Video Name outputs

image
As you can see in this image, the basic function no longer works. I have tried several different playlists and I get this same error.

Error: Status code: 302

Hello there. It gets the following error. It was working normally but now it gives this error.

Error: Status code: 302
at ClientRequest. (C:\Users\gani_ipek\Desktop\bot_v2\node_modules\ytpl\lib\firstpage.js:14:23)
at Object.onceWrapper (events.js:417:26)
at ClientRequest.emit (events.js:310:20)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:603:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
at TLSSocket.socketOnData (_http_client.js:476:22)
at TLSSocket.emit (events.js:310:20)
at addChunk (_stream_readable.js:286:12)
at readableAddChunk (_stream_readable.js:268:9)
at TLSSocket.Readable.push (_stream_readable.js:209:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:186:23)

[solution included] Youtube channels with /c/ChannelName URL format not handled

Hi,

I tried to use the package with this type of URL : https://www.youtube.com/c/SoundofArman/
But I get Unable to find a id in https://www.youtube.com/c/SoundofArman

After research I saw it's possible to have the channel ID from the HTML source of a youtube channel page so I implemented this in my app (removed some parts of my code for clarity). I'm not a javascript expert so any feedback is appreciated :

var ytpl = require('ytpl');
const fs = require('fs');
const cheerio = require('cheerio');
const got = require('got');

exports.handler = async event => {
  var channelUrl = event.queryStringParameters.channel_url
  const validUrl = ytpl.validateURL(channelUrl)

  if (!validUrl) {
    var newChannelUrl = got(channelUrl).then(response => {
      const $ = cheerio.load(response.body);
      var link = $('link[title="RSS"]').prop('href');
      var url = new URL(link);
      var channelId = url.searchParams.get("channel_id");
      return channelId
    }
}

Would be nice to implement a similar solution in the package natively.

TypeScript support for the helper functions

Hello! I've realized you have typings only for the main ytpl functions. Is there any possibility you'll add the other functions (getPlaylistID and validateURL) in the typings? Thanks

crash

My app crashed because of ytpl, logs as below:

/app/node_modules/ytpl/lib/util.js:22
    title: exports.removeHtml(importantTxt.match(PLAYLIST_NAME_REGEXP)[1]),
                                                                      ^

TypeError: Cannot read property '1' of null
    at Object.exports.getGeneralInfo (/app/node_modules/ytpl/lib/util.js:22:71)
    at IncomingMessage.<anonymous> (/app/node_modules/ytpl/lib/firstpage.js:30:29)
    at IncomingMessage.emit (events.js:214:15)
    at endReadableNT (_stream_readable.js:1178:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)

Problem with ytpl not working on any playlists.

Every time I try and use ytpl it errors out saying :
D:\Stuff\TetTicket\node_modules\ytpl\lib\util.js:22
title: exports.removeHtml(importantTxt.match(PLAYLIST_NAME_REGEXP)[1]),
^

TypeError: Cannot read property '1' of null
    at Object.exports.getGeneralInfo (D:\Stuff\TetTicket\node_modules\ytpl\lib\util.js:22:71)
    at IncomingMessage.<anonymous> (D:\Stuff\TetTicket\node_modules\ytpl\lib\firstpage.js:30:29)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1221:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: node server.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\theco\AppData\Roaming\npm-cache_logs\2020-07-16T07_06_35_026Z-debug.log

Add `ytpl.getPlaylistID` function

Here is already util.getPlaylistId function, but it is not public and doesn't support Promise.
An ideal option would be to make it synchronous, like ytdl.getVideoID, but it doesn't seem to be possible.

TypeScript definitions

In the TypeScript world, it's nice to have definitons, and it's great to see what can I use / what do I get without searching for it.
There is an example regarding the result, and the API is documented, so it wouldn't be hard to make typings.
Would you accept a pull request?

Only getting first 100 videos of a playlist

I am using the module to get playlist info for music commands in my discord bot. The module will only return the first 100 items of a playlist. I've tried multiple playlists of varying sizes over 100 but the result is always the same. I've used the latest available npm version and the rework branch version.

In the case of the npm version I'm using limit=0 and with the rework branch version im using limit=Infinity. If I use it the way it's written in the documentation limit[Number] it just results in ReferenceError: limit is not defined So what am I doing wrong? 🥴

Error message - Update Browser

When trying to fetch playlist information you get this error:
Error: We’ll stop supporting this browser soon. For the best experience please <a href="/supported_browsers">update your browser</a>.
Any solutions for this?

I'm currently running this in an express server.

Cannot send requests?

Just started to try out this module, but I cannot even get the example code to run proper?

I am getting a TypeError "Cannot read property 'splice' of null at ytpl\lib\firstpage.js:20:50

Thought it was just me so I tried runkit and same thing?
https://runkit.com/593239ab2a105b001274636c/593246e004544700129567cf

edit: in order to get around this for NOW, I just put if (resp_string.match(error_regexp_g) !== null) before trying to splice and find any errors.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

Add durationSeconds in the video object

Add durationSeconds to the video object that gives video duration in seconds.

I currently have to take the regular duration and convert it into the seconds and I thought it being included in the response would be really nice to have

Cannot read property 'split' of null

Function.main.validateURL (C:\Users\Karlis\Desktop\co\node\receptionist\node_modules\ytpl\lib\main.js:94:29)

The TypeError: Cannot read property 'split' of null occurs when argument link of main.validateURL is an empty string or whitespace, since the property pathname will always be null when such circumstances occur.
Can be solved outside the package checking if parsed.pathname === null beforehand, however it is good practice to do that in the package too.

How can I use proxy?

Hi, can you add an example that shows how to use ytpl with proxy? I tried doing it the same way as node-ytdl-core but it didn't work.

ytpl throwing an error on playlists with more than 100 items

Since about 30 minutes, ytpl fails to retrieve any playlist, even perfectly working ones used today
Here are the logs :

TypeError: Cannot read property 'indexOf' of undefined
    at Object.exports.between (D:\Projets\discord-jukebox\node_modules\ytpl\lib\util.js:148:18)
    at IncomingMessage.<anonymous> (D:\Projets\discord-jukebox\node_modules\ytpl\lib\nonfirstpage.js:22:45)
    at IncomingMessage.emit (events.js:323:22)
    at endReadableNT (_stream_readable.js:1204:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

After debugging a little bit, seems like parsedString in nonfirstpage.js only contains { restart: 'now' }.
Did YouTube release an update breaking the lib ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.