ytdl-js / react-native-ytdl

A YouTube downloader for React Native
121 stars 46 forks source link

URIError: URI malformed #89

Open fullerlee opened 3 years ago

fullerlee commented 3 years ago

I'm unable to get any URLs on iOS SImulator.

const youtubeURL = 'http://www.youtube.com/watch?v=04GiqLjRO3A';
const urls = await ytdl(youtubeURL, { quality: 'highestaudio' });
console.log(urls);

Getting:

ERROR URIError: URI malformed
    at decodeURIComponent (<anonymous>)
    at Object.module.exports (decode.js:68)
    at _callee9$ (info.js:340)
    at tryCatch (runtime.js:63)
    at Generator.invoke [as _invoke] (runtime.js:294)
    at Generator.next (runtime.js:119)
    at tryCatch (runtime.js:63)
    at invoke (runtime.js:155)
    at runtime.js:165
    at tryCallOne (core.js:37)
fullerlee commented 3 years ago

I've fixed this. Will put a PR up shortly

fullerlee commented 3 years ago

I've fixed this in my fork here: https://github.com/fullerlee/react-native-ytdl

I found that the miniget polyfill wasn't handling redirects in a suitable way. This meant my initial request wasn't getting past a particular warning screen (I've forgotten the exact content) displayed by youtube.

I've changed the miniget polyfill to use axios instead of fetch and it seems to work now. However, I'm not sure if adding a new dependency is acceptable to people using this library, so haven't raised a PR yet.