Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is not working any more #945

Closed
yasahmed opened this issue Jun 23, 2021 · 24 comments
Closed

Is not working any more #945

yasahmed opened this issue Jun 23, 2021 · 24 comments

Comments

@yasahmed
Copy link

this dependecy is not working any more formats object is empty now

@TimeForANinja
Copy link
Collaborator

can this be a dupe of #939 ?
the library is having problems in general atm

@OGSkies
Copy link

OGSkies commented Jun 23, 2021

@TimeForANinja @yasahmed
YouTube has updated their API
which led to ytdl to not work
The only solution is to wait for ytdl to update their code for the new YouTube API
Thanks

@RisedSky
Copy link

How long does it usually take?
and How do we know that they did update their code for the new YouTube API?

Thanks

Just subscribe to release, they will do their update here.

@TentacleSama4254
Copy link

How long does it usually take?
and How do we know that they did update their code for the new YouTube API?
Thanks

Just subscribe to release, they will do their update here.

How to do that

@RisedSky
Copy link

How long does it usually take?
and How do we know that they did update their code for the new YouTube API?
Thanks

Just subscribe to release, they will do their update here.

How to do that

image

@RisedSky
Copy link

thanks, but still the question remains unanswered, does anyone know if it usually takes hours? weeks? centuries?

image

@konsumer
Copy link

konsumer commented Jun 23, 2021

@vincenzo882: I'm not a maintainer, and I don't mean to come off rude, but this project is totally open-source. It's pretty much instant if you make it, otherwise, you are dependent on unpaid volunteer's free time. Nobody owes you free development, we're all in it together, and it's not helpful to be like "when will it be done?" a bunch.

For people looking into this, here is a simplified function that also fails, but uses similar to current method:

export const getVideoInfo = async (id, options = {}) => {
  const url = new URL(`https://www.youtube.com/get_video_info`)
  url.searchParams.set('video_id', id)
  url.searchParams.set('eurl', `https://youtube.googleapis.com/v/${id}`)
  url.searchParams.set('ps', 'default')
  url.searchParams.set('gl', options.country || 'US')
  url.searchParams.set('hl', options.lang || 'en')
  url.searchParams.set('html5', '1')
  const u = url.toString()
  const r = await fetch(u)

  console.log('URL', u)
  console.log('REQUEST', r.status, await r.text())
}
URL https://www.youtube.com/get_video_info?video_id=K-281doxOMc&eurl=https%3A%2F%2Fyoutube.googleapis.com%2Fv%2FK-281doxOMc&ps=default&gl=US&hl=en&html5=1
REQUEST 404

In the context of a youtube player page, you can get lots of great info with this (including video URLS in streamingData.adaptiveFormats) from window.ytInitialPlayerResponse.

Here is a quick function exploiting those things, which currently works:

import fetch from 'node-fetch'

const regex = /var ytInitialPlayerResponse = (.+);<\/script>/gm

export async function getInfo (id) {
  const r = await fetch(`https://www.youtube.com/watch?v=${id}`)
  const str = await r.text()
  const m = regex.exec(str)
  if (m && m.length === 2){
    return JSON.parse(m[1])
  }
}

getInfo('K-281doxOMc')
  .then(console.log)

@fent if this seems like an ok direction, I can make a PR. It seems a bit fragile, like it will fail if they format their code some different way, but at least right this second, it seems to work.

@konsumer
Copy link

konsumer commented Jun 23, 2021

On further inspection, the not all of the video URLs it returns seem to actually open, so that might be a dead-path.

@TimeForANinja
Copy link
Collaborator

@konsumer no reason to excuse - you're not rude
the https://www.youtube.com/watch?v=xxx page is one of the pages we do already fetch
feel free to check out #938 for the current hotfix

@konsumer
Copy link

Ah yes, sorry, I looked closer at the code. It grabs getWatchHTMLPage, getWatchJSONPage, getVideoInfoPage, wheregetWatchHTMLPage is similar to my code, above. I wonder if for my purposes I need the other data (which is the problem, right?) I am trying to just get an array of video formats that work. Is the data from the other functions needed? I like the idea of only making 1 request, instead of a few. I have this running in a little video proxy that redirects to the raw URL, so the fastest path to the raw URL is probably best for my case, if it's not missing anything else I need.

@TimeForANinja
Copy link
Collaborator

TimeForANinja commented Jun 24, 2021

there is a reason we use multiple sources - just one is not reliable
the other's are mostly needed for stuff like age restricted and so on...

@kevin4dhd
Copy link

any solution?

@amitojsingh366
Copy link

any solution?

a fix has been implemented in #938, now you just gotta wait for the merger (or like me manually patch the lib)

@vincenzo882
Copy link

any solution?

a fix has been implemented in #938, now you just gotta wait for the merger (or like me manually patch the lib)

how do you "patch the lib"? and who is "lib"? where does he/she hang out?

@amitojsingh366
Copy link

any solution?

a fix has been implemented in #938, now you just gotta wait for the merger (or like me manually patch the lib)

how do you "patch the lib"? and who is "lib"? where does he/she hang out?

lol lib isn't a person, lib == library and i used patch-package to patch it

@rudgia
Copy link

rudgia commented Jun 24, 2021

Hi
i'm new to this how do you implement the "patch package " into app itself
can somone please explain this.
//Rg

@rudgia
Copy link

rudgia commented Jun 24, 2021

as i said new at this , but where to find "In node_modules/ytdl-core/lib/info.js"

and wher do i get the "origin package" Latest that was released.

@regales
Copy link

regales commented Jun 24, 2021

In node_modules/ytdl-core/lib/info.js
Line 254 replace

let jsonStr = body.split("ytInitialPlayerResponse = {")[1].split("}}};")[0] += "}}}";

Not me who found this out but it may be a temp fix until next version comes
Worked for me anyways

@rudgia
Copy link

rudgia commented Jun 24, 2021

as i said new at this , but where to find "In node_modules/ytdl-core/lib/info.js"
and where do i get the "origin package" Latest that was released.

in your code files, find file node_modules then find ytdl-core then find lib then find info.js

my "code files" don't under stand

@amitojsingh366
Copy link

amitojsingh366 commented Jun 24, 2021

Hi
i'm new to this how do you implement the "patch package " into app itself
can somone please explain this.
//Rg

it's pretty simple, just follow the steps below:

this will make it so every time you run a npm/yarn install it automatically patches ytdl-core for you (so it's like a one time hassle, you can forget about it until ytdl-core merges #938)

@konsumer
Copy link

konsumer commented Jun 24, 2021

@regales I think my regex above does essentially the same thing, but is maybe a tiny bit more efficient. As far as I understand it, the problem is in another place, though. It's because the lib combines data from several different sources, and one of them is failing, so looking for ytInitialPlayerResponse works well in getWatchHTMLPage (which is what these 2 snippets are for) but we are getting errors on getVideoInfoPage. @TimeForANinja points out that we need all the data-sources, because different video-types need more data.

As for patching, hand-editing your changes, and all that stuff, I personally would recommend against all this. npm install can work with git-repos, and as long as they don't need to be built before being published (ytdl-core is good), you can reference the changes directly. Here is an example of how to install the patched version:

npm i git://github.com/D3SOX/node-ytdl-core#fix-info-endpoint-404

That is where the PR comes from (user/repo#branch)

The bonus of this method is it's very easy to go back to the official version, once the changes are published on npm:

npm i ytdl-core@latest

Either one of those commands will save the version in your package.json, on modern versions of npm, so other users and your CI or whatever will have the changes. It's a way to record "it's working in this PR, so use that until it's published."

@konsumer
Copy link

This is a programming homework help session that I somehow entered

@vincenzo882 not sure I follow. This isn't anyone's homework we're helping with, it's a library that lots of other projects depend on. I am 43 years old, and have been programming professionally for about 25 years. (not in college, or highschool or wherever else people have homework assignments.) I think maybe you are trying to be funny, but the sarcasm isn't really translating in text form, in a github issue queue.

and that is why I am being ignored even tho I'm the family genius and made it to the seventh grade and memorized the whole multiplication table because I couldn't pay for a scientific calculator.

Again, nobody owes you support or development or anything else. If they feel like providing it, lucky you, if not, then maybe pay someone for support. We are just all trying to make a cool library work for our projects that depend on it, that is what github issue queues are for.

adon called "youtube video and audio downloader (Dev Edt)" stopped showing download options,

Why are you in this issue queue, if it's an issue with a firefox plugin? Maybe you should go talk to them.

I'll go look for a different adon.

Ok. That addon has nothing to do with this library, other than depending on it. Go take it up with them.

@amitojsingh366
Copy link

I think I get it now. This is a programming homework help session that I somehow entered while investigating why a firefox browser adon called "youtube video and audio downloader (Dev Edt)" stopped showing download options, but instead it shows "info.player_response is undefined" and that is why I am being ignored even tho I'm the family genius and made it to the seventh grade and memorized the whole multiplication table because I couldn't pay for a scientific calculator. I'll go look for a different adon.

this has barely anything to do with ytdl-core as @konsumer said. if you're trying to be funny this isn't the right place buddy

@TimeForANinja
Copy link
Collaborator

gonna close this as related to #939 and fixed with v4.8.3
feel free to open a new issue / write here / reopen this issue when i'm wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests