LonelyCpp / react-native-youtube-iframe

A wrapper of the Youtube-iframe API built for react native.
https://lonelycpp.github.io/react-native-youtube-iframe/
MIT License
604 stars 152 forks source link

This video is unavailable #167

Closed markus-dopp closed 3 years ago

markus-dopp commented 3 years ago

Describe the bug Since today i'm getting a "This video is unavailable" message from Youtube for all videos. I tried different videos (that have been working before) from multiple devices, networks and emulators.

I'm using the default hosted HTML page.

Additional context react-native-youtube-iframe v2.0.1

ghost commented 3 years ago

Same problem here

juddey commented 3 years ago

Experiencing this issue also.

oeduardoal commented 3 years ago

Same here!! I think youtube changed some policy!!

LonelyCpp commented 3 years ago

just woke up to this!! Are you all still experiencing this issue? since it works on my computer 😭

<YTP 
  height={200} 
  videoId={'tQ0yjYUFKAE'} 
  useLocalHTML={false} // try changing this prop to "true" if all else fails
/>
kosick commented 3 years ago

I updated version to latest 2.1.0 (I used 1.4.0 ver and having this issue.) And it's working now.

alanwjlu commented 3 years ago

I was also having the issue and was on 1.4.0. After updating to 2.1.0 it's working again.

nguyenvanphuc2203 commented 3 years ago

same problem here, any way fix it so no need update app?

murthy-klapz commented 3 years ago

Is there an underlying YouTube API changes that caused the earlier version to crack? Upgrading library isn't always a solution for an app that's already live.

If the YouTube API changed, there surely would have been a notice sort of thing.

Looking forward to hear from the lib authors or someone with more insights.

sriganesh-nagaraj commented 3 years ago

It is not working with our app as well. Upgrading the library isn't viable for us as well

murthy-klapz commented 3 years ago

It is not working with our app as well. Upgrading the library isn't viable for us as well

In the interest of time and not letting down customers, we are releasing the app in couple of hours. But would love to know the root cause.

LonelyCpp commented 3 years ago

Hi guys, here's what I found after a bit of debugging.

the cause

the "list" key somehow suddenly rejects empty values. https://github.com/LonelyCpp/react-native-youtube-iframe/blob/1ed92b576a8459f12e7f4eeb7fe9ffa64677f930/src/PlayerScripts.js#L162

why is it working on v2.1.0?

is there a way to fix this without an app update?

I don't think so.

The player code is controlled by YouTube itself. Maybe if they rollout a patch to fix this, it will work again - but I have no control over it

links

revision history

it looks like list and listType have received updates on Nov 2020, but hasn't changed since. Not sure why it would suddenly break on July 2021


whatever how do I fix this?

markus-dopp commented 3 years ago

Hi guys, here's what I found after a bit of debugging.

the cause

the "list" key somehow suddenly rejects empty values. https://github.com/LonelyCpp/react-native-youtube-iframe/blob/1ed92b576a8459f12e7f4eeb7fe9ffa64677f930/src/PlayerScripts.js#L162

  • this would be an empty string if there's no playlist
  • YouTube probably pushed an update to their iframe script that rejects empty "list" key

why is it working on v2.1.0?

  • v2 fetches the HTML script from a remote source and this does not seem to break. I honestly don't know why.
  • The useLocalHtml prop also works because of this commit 7750ab7 that was trying to fix an unrelated issue
  • there also seems to be a bug on iOS where useLocalHtml does not work. (this is false by default) I will be debugging this

is there a way to fix this without an app update?

I don't think so.

The player code is controlled by YouTube itself. Maybe if they rollout a patch to fix this, it will work again - but I have no control over it

links

revision history

it looks like list and listType have received updates on Nov 2020, but hasn't changed since. Not sure why it would suddenly break on July 2021

This 👆 was exactly my issue, once i upgraded and removed the playlist prop it started working again.

gabrielcowit commented 3 years ago

We had this problem when updated the module: node_modules/react-native-youtube-iframe/dist/index.js: Cannot read property 'cache' of undefined.

Does anyone know how to fix it?

aakashr143 commented 3 years ago

I updated my expo SDK for 41 to 42, but react-native-youtube-iframe hasn't updated, still 1.4.1. How do I update it.

"react-native-web": "~0.13.12", "react-native-webview": "^11.6.2", "react-native-youtube-iframe": "^1.4.1",

I tried making a new expo project with SDK 42 and it works but it has v2.1.0

LonelyCpp commented 3 years ago

@gabrielcowit remove node_modules, and reinstall packages

@aakashr143 not sure what's wrong, but you can manually update the version to "^2.1.0"

ghost commented 3 years ago

Works perfectely in v2.1.0

aakashr143 commented 3 years ago

I had to first install react-dom and then update the package, it change to v1.4.2 but it works

This is for Expo managed, SDK 42

vineelk8 commented 3 years ago

Hi guys, here's what I found after a bit of debugging.

the cause

the "list" key somehow suddenly rejects empty values. https://github.com/LonelyCpp/react-native-youtube-iframe/blob/1ed92b576a8459f12e7f4eeb7fe9ffa64677f930/src/PlayerScripts.js#L162

  • this would be an empty string if there's no playlist
  • YouTube probably pushed an update to their iframe script that rejects empty "list" key

why is it working on v2.1.0?

  • v2 fetches the HTML script from a remote source and this does not seem to break. This is because the list key is set as undefined and not an empty string.
  • The useLocalHtml prop also works because of this commit 7750ab7 that was trying to fix an unrelated issue
  • ~there also seems to be a bug on iOS where useLocalHtml does not work. (this is false by default) I will be debugging this~ (this is unrelated, and fixed 1ad8cec)

is there a way to fix this without an app update?

I don't think so.

The player code is controlled by YouTube itself. Maybe if they rollout a patch to fix this, it will work again - but I have no control over it

links

revision history

it looks like list and listType have received updates on Nov 2020, but hasn't changed since. Not sure why it would suddenly break on July 2021

whatever how do I fix this?

  • update yt-iframe to 2.1.1 in package.json (OR 1.4.2 if you're afraid of major version changes)
  • reinstall! (might require a node_modules nuke)
  • TEST
  • push an app update

@LonelyCpp Can you please let us know whether you can push this fix to earlier versions as well? Because we have live users who are facing this issue.

Please suggest any alternative to overcome this that works fine for live users.

FYKI: We are using version 1.4.1 in the live app.

LonelyCpp commented 3 years ago

There's no way I can fix this for 1.4.1

The the only people who can is youtube

vineelk8 commented 3 years ago

It is not working with our app as well. Upgrading the library isn't viable for us as well

In the interest of time and not letting down customers, we are releasing the app in couple of hours. But would love to know the root cause.

@murthy-klapz even though you give a new release existing users will still have the issue right. Do you have any workaround for that?

A7abhilash commented 3 years ago

just woke up to this!! Are you all still experiencing this issue? since it works on my computer 😭

<YTP 
  height={200} 
  videoId={'tQ0yjYUFKAE'} 
  useLocalHTML={false} // try changing this prop to "true" if all else fails
/>

Even I started facing this issue where the videos of the playlist were playing but the individual videos weren't playing at all...

Then this worked for me in the latest update(v2.1.1). Add useLocalHTML={true} props and videos got played properly.

Andrew-Chen-Wang commented 3 years ago

Perhaps to be a little more backwards compatible is to find the Google Groups Forum for YouTube API and tell them "Hey there's a prob." Unfortunately, I can't seem to find that group -- if it exists that is. But imo a post there would be helpful for existing devs who haven't released the upgrade yet.

Also is there a CHANGELOG.md here? Would be appreciated if one exists!

ddaaggeett commented 3 years ago

Ran into this problem too. Will attempt a fix when I can. Attempted the V2.1.1 update. Nothing yet.

New software using this package. Mobile YouTube clipper as you're watching. https://github.com/ddaaggeett/clipper

LonelyCpp commented 3 years ago

@ddaaggeett looks like you have your own copy of the library.

You might find it easier to use 1.4.2 from this branch - https://github.com/LonelyCpp/react-native-youtube-iframe/tree/v1.4.x

this is the exact commit - https://github.com/LonelyCpp/react-native-youtube-iframe/commit/07a54b158dd45411a15085e40b81ceb5f1518890

romsnowcode commented 3 years ago

only install 2.1.1 version

npm install react-native-youtube-iframe@2.1.1

ddaaggeett commented 3 years ago

@LonelyCpp After deleting node_modules and reinstalled I tested both 1.4.2 and 2.1.1 with the following:

I've been using a copy embedded in my code, yes, with import YoutubePlayer from "./react-native-youtube-iframe" but I tested with the NPM package with import YoutubePlayer from "react-native-youtube-iframe" which still doesn't work.

I don't mean to be a bug. I've fully detailed my issue here: https://github.com/ddaaggeett/clipper/issues/1. I just can't see how i'm doing anything different than those above whose upgrades made the fix.

eleonne commented 3 years ago

After updating to 2.1.1 it was still not working here. I had to go to node_modules/react-native-youtube-iframe/dist/PlayerScripts.js

Then I located this part: return{htmlString:htmlString,urlEncodedJSON:urlEncodedJSON};

Put a console.warn(htmlString) before and voilá, it works console.warn(htmlString);return{htmlString:htmlString,urlEncodedJSON:urlEncodedJSON};

I guess the log forced the component to update the html string. It was probably loading the previous version. Also, I removed the console.warn after it worked and all is good here

LonelyCpp commented 3 years ago

Probably a cache issue with the metro bundler

eleonne commented 3 years ago

Its cache for sure. I`m just sharing what worked for me. Started debugging and turns out it was cache. In case someone else is stuck, the console.warn in the right place forces the cache to update. Ugly, but works.

ddaaggeett commented 3 years ago

so, how would you recommend cache maintenance?

npm cache clean --force - this does not work.

how would you locate the issue with the react-native metro bundler? I'm starting with these troubleshoots

ddaaggeett commented 3 years ago

@eleonne the console.warn(htmlString) method is not working, though to me it doesn't make sense why that could possibly be a fix.

The aforementioned metro bundler troublshooting also does not work. Caveat: I cannot find the directory to properly perform the following command: rm -rf /tmp/metro-*

kartavyaparekh96 commented 3 years ago

Still not working

hugoh59 commented 3 years ago

I'm getting this error `node_modules/react-native-youtube-iframe/dist/index.js:


/Users/hugohouyez/code/.../node_modules/react-native-youtube-iframe/dist/index.js: Cannot read property 'cache' of undefined

RCTFatal
__28-[RCTCxxBridge handleError:]_block_invoke
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_main_queue_callback_4CF
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
__CFRunLoopRun
CFRunLoopRunSpecific
GSEventRunModal
-[UIApplication _run]
UIApplicationMain
main
start
``` not sure if it's related.