Search code examples
youtube-data-api

"This video is unavailable" when putting music videos in iFrame


So I developed an app that fetches the youtube video for songs. 2 months ago this worked without fail. Came back to my app and suddenly getting the static-y error "This video is unavailable".

Double checked that the video on Youtube is actually there and plays, and I also checked to see if the uploader allows embedding by using https://www.googleapis.com/youtube/v3/videos?id=l-EdCNjumvI&key=[MYKEY]&part=snippet,contentDetails,status

I got the status response as follows: "status" : { "embeddebable" : true }

So I know I should be able to embed that particular video. Any advice?

I am able to put other non-music videos into the iframe without fail.

Works: <iframe width="560" height="315" src="https://www.youtube.com/embed/PUvWR0HdQmg" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

Doesn't work: <iframe width="560" height="315" src="https://www.youtube.com/embed/l- EdCNjumvI" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen> </iframe>

Edit: it seems music videos need a server to be running in order to play. I don't know why this is, but I started a simple http server using python -m http.server 80 and for some reason that is above my expertise, that worked


Solution

  • After testing your two pieces of code, it seems that the spaces in the second example may be the problem.

    Instead of

    <iframe width="560" height="315" src="https://www.youtube.com/embed/l- 
    EdCNjumvI" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen> 
    </iframe>
    

    consider using

    <iframe width="560" height="315" src="https://www.youtube.com/embed/l-EdCNjumvI" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen> 
    </iframe>
    

    where there are no spaces after the hyphen.

    This may be due to the fact that the spaces in your example are WITHIN the src string, meaning that in your original example, the src string was

    src="https://www.youtube.com/embed/l- EdCNjumvI"

    rather than

    src="https://www.youtube.com/embed/l-EdCNjumvI"