modal-video icon indicating copy to clipboard operation
modal-video copied to clipboard

All modals for youtube displaying "This video is unavailable."

Open dtotheram opened this issue 2 years ago • 18 comments

Even on the demo site the modals don't seem to be working. 2021 07 21 04 02 23PM--screenshot

dtotheram avatar Jul 21 '21 20:07 dtotheram

Troubleshooting this on a site, it appears that if you have the playlist variables in the embed url but are not loading a playlist it will error out. So the defaults simply need to remove playlist, list and listType variables and then it will load. Basically according to this - https://developers.google.com/youtube/player_parameters?hl=en you should either be providing a video id or playlist information not both. There was also some deprecations late last year in terms of playlists and assuming that their final updates were pushed today.

obj63mc avatar Jul 21 '21 23:07 obj63mc

To give an example - the URL that is generated for the embed is -

https://www.youtube.com/embed/L61p2uyiMSo?autoplay=1&cc_load_policy=1&color=null&controls=1&disablekb=0&enablejsapi=0&end=null&fs=1&h1=null&iv_load_policy=1&list=null&listType=null&loop=0&modestbranding=null&mute=0&origin=null&playlist=null&playsinline=null&rel=0&showinfo=1&start=0&wmode=transparent&theme=dark&nocookie=false

which won't work but the following link will simply removing &list=null and &playlist=null

https://www.youtube.com/embed/L61p2uyiMSo?autoplay=1&cc_load_policy=1&color=null&controls=1&disablekb=0&enablejsapi=0&end=null&fs=1&h1=null&iv_load_policy=1&listType=null&loop=0&modestbranding=null&mute=0&origin=null&playsinline=null&rel=0&showinfo=1&start=0&wmode=transparent&theme=dark&nocookie=false

obj63mc avatar Jul 21 '21 23:07 obj63mc

Thanks a lot!! You've just saved me hours of investigating.

eytanchen avatar Jul 22 '21 12:07 eytanchen

Thanks so much, @obj63mc! I was wondering why the modals often show a playlist option in the embed but it was empty when I clicked it.

dtotheram avatar Jul 22 '21 13:07 dtotheram

Anybody have any ideas when this is likely to be merged and released?

Thanks :)

OwenMelbz avatar Jul 23 '21 09:07 OwenMelbz

I'm having the exact same issue. I've tried to download the v2.4.4 tag but it doesn't seem to work. The js/ folder only contains files from v2.4.3, not the updated ones. I've also tried to build this myself, but I'm getting this error:

error An unexpected error occurred: "https://registry.yarnpkg.com/electron/-/electron-1.8.0.tgz: Request failed \"404 Not Found\""

And I can't continue anymore.

zietbukuel avatar Jul 23 '21 19:07 zietbukuel

https://github.com/appleple/modal-video/pull/74 Fixed this issue for me.

@zietbukuel The built JS & CSS files are also included in the repo, so just use this files (https://github.com/appleple/modal-video/archive/refs/heads/master.zip) till the next release?

thomasfrobieter avatar Jul 26 '21 13:07 thomasfrobieter

@zietbukuel Any suggestions for the easiest way for users to do this if they're using a package manager such as yarn/npm etc and not just downloading files directly?

OwenMelbz avatar Jul 26 '21 13:07 OwenMelbz

@thomasfrobieter thank you, now I see master contains v2.4.4

zietbukuel avatar Jul 26 '21 14:07 zietbukuel

Thank you, it works!

ABooooo avatar Aug 04 '21 08:08 ABooooo

The error on the video still exists on the Demo page https://appleple.github.io/modal-video/

b7-afonso avatar Aug 20 '21 12:08 b7-afonso

@b7-afonso Thanks! :) Now fixed demo page! https://appleple.github.io/modal-video/

mkasumi avatar Aug 26 '21 05:08 mkasumi

I'm having the same issue, except my video url doesn't have any playlists in url, the generated link simply has the video id, but the video is unavailable. Any suggestions?

eldorokhova avatar Sep 27 '21 14:09 eldorokhova

Issue for me too. Any idea when this will be released?

This is basically a non-working library presenting itself as if it were suitable for production use, when that is not the case.

CaelanStewart avatar Oct 12 '21 09:10 CaelanStewart

Got some time to look at this more, and I think I've found the issue, which fixes my case and doesn't seem to cause any issues...

I think there's a couple of things... 'null' is not a valid value to pass to YouTube, and when the query string built in src/core/index.js:ModalVideo.prototype.getQueryString, the default values are added to the query string, even if those default values contain null.

And because this library specifies playlist=null&list=null&listType=null as the default options, just trying to load a simple video fails because 'null' is not a list or playlist that exists et cetera.

So the simplest thing is to not add options with null or undefined values to the query string.

I downloaded master and imported directly into the build system, but with the following change:

src/core/index.js:78

Change:

getQueryString(obj) {
  let url = '';
  Object.keys(obj)
    .forEach((key) => {
      url += `${key}=${obj[key]}&`;
    });
  return url.substr(0, url.length - 1);
}
getQueryString(obj) {
  let url = '';
  Object.keys(obj)
    .forEach((key) => {
      if (obj[key] !== null && obj[key] !== undefined) {
        url += `${key}=${obj[key]}&`;
      }
    });
  return url.substr(0, url.length - 1);
}

CaelanStewart avatar Oct 12 '21 13:10 CaelanStewart

The pull request to resolve this has already been merged #74 you may just need to update your npm installation to the lastest version but should be working fine

obj63mc avatar Oct 12 '21 13:10 obj63mc

@obj63mc – I realised that when looking into it more, but I checked that earlier and I'm already on the latest version (2.4.6).

The issue was the resulting URL the library sets as the iframe's src has a query string has these values (where JS casts null to the string 'null'):

  • playlist=null
  • list=null
  • listType=null
  • etc.

There is no need to pass a bunch of query string params containing 'null' anyway.

CaelanStewart avatar Oct 12 '21 13:10 CaelanStewart

this is working for me now in version 2.4.6.

stevethorson avatar Dec 08 '21 23:12 stevethorson