Skip to content
This repository has been archived by the owner on Mar 11, 2022. It is now read-only.

Unable to retrieve metadata from link #49

Open
DrEdwardPCB opened this issue Nov 2, 2020 · 12 comments
Open

Unable to retrieve metadata from link #49

DrEdwardPCB opened this issue Nov 2, 2020 · 12 comments

Comments

@DrEdwardPCB
Copy link

When I tried to use the
ytdl.getInfo(url).then(res=>console.log(res))
it just output a json string
)]}' {"reload":"now"} [Error: Unable to retrieve video metadata]
When I dig deep into the source code, I think it is probably the problem of miniget. the miniget method GET request simply cannot return anything of the video metadata But fixing it is already out of my ability.

test on
react-native-ytdl 4.0.2
IOS 14.2
react native 0.63.0

@DrEdwardPCB
Copy link
Author

MORE INFO
exact code to reproduce should be

if (ytdl.validateURL(props.url)) {
          ytdl.getInfo(props.url).then((info) => {
                        setMetaInfo(info)
                    })
                        .catch(error => {
                            //setMetaInfo(error)
                            console.log(error)
                            setState({ type: 'FAIL' })
                        })
                } else {
                    setState({ type: 'FAIL' })
                }

@AbelTesfaye
Copy link
Collaborator

Could you provide a video id that's causing this?

@DrEdwardPCB
Copy link
Author

Nearly all video I encountered have this problem.
E.g.
https://m.youtube.com/watch?v=J0bUGAkfutk

@Sanorf
Copy link

Sanorf commented Nov 2, 2020

Hello, I have the same problem with a real device Huawei P20 Lite, Android 9, react-native-ytdl 3.4.2, react-native 0.63.3
100% calls to ytdl(URL), ytdl.getBasicInfo(URL), whatever the URL i use -> Error parsing info: Unable to retrieve video metadata

I tested other real devices Samsung Galaxy S8 android 9, iPhone 8 iOS 12, I don't have the problem on these devices.
Even on simulator iPhone 11 ios 14.1, emulator android 8.1 -> no problem

@achigo16
Copy link

This bug is from node-ytdl-core (fent/node-ytdl-core#751) and it already fixed. So, update node-ytdl-core version is the best way to fix it

@Sanorf
Copy link

Sanorf commented Nov 11, 2020

Yes I think this port just needs to be rebased to latest node-ytdl-core

@AbelTesfaye
Copy link
Collaborator

Should be fixed in the latest version. If not, try passing a high maxRetries like the following:

ytdl.getInfo(YOUR_URL, {
        requestOptions: { maxRetries: 100 }
      });

You are experiencing a network error, the above option will retry failed functions until they succeed.

Note: You might want to keep maxRetries under 10,000 since the retry function is implemented recursively and higher values will blow up your call stack

@Sanorf
Copy link

Sanorf commented Nov 12, 2020

Unfortunatly it's still the same for me with the last version and until 100 retries :/
Even I had one device which didn't have this problem before and now always "Unable to retrieve video metadata".
Yes it's clearly a network problem, it's not my speciality but i will dig and let you know if I find something, at least a workaround.

@Sanorf
Copy link

Sanorf commented Nov 13, 2020

I didn't find the origin of my problem but i solved it by "homemade" sources modification.

I discovered it exists two main methods to get YT video informations:

  • by the watch page video URL (like in this library, with the function getJSONWatchPage)
  • by the get_video_info URL

The first method doesn't work on some devices for me, I don't know why (response blob is empty).
The problem in this library inherited from node-ytdl-core is we don't try the second method if the first fails, we just throw an error. I removed the error handling and added a call to the second method and it solved my problem.

@deepak-jha-kgp
Copy link

Hey, @Sanorf can you please share your modified files?

@deepak-jha-kgp
Copy link

@AbelTesfaye does this suggestion sound good? Can we have this please?

@AbelTesfaye
Copy link
Collaborator

The above suggestion was implemented on the latest node-ytdl-core. I've rebased this library so it should be available now

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

No branches or pull requests

5 participants