0

I have a big list of embedded Youtube videos. Some of them are not available.

I am looking for a solution how to identify them in a big batch of URLs.

Manually it is possible to check in the following way:

E.g., embedded Youtube video - https://www.youtube.com/embed/GdGB0cv6i8I

view-source:https://www.youtube.com/embed/GdGB0cv6i8I

previewPlayabilityStatus - "Video unavailable"

I am trying to incorporate this with Google spreadsheets with the formula

Here is the link to the file: https://docs.google.com/spreadsheets/d/1fHB2UvCVxq4tgNrn_VWlmGyfpXyS-vhbWu57EjUaKsw/edit#gid=0

For some reasons it does not work.

Hanna
  • 137
  • 10
  • 2
    It seems that you just shared a Google Sheet URL providing write access to everyone. I don't recommend you to do so as anyone can that way trash your Google Sheet. – Benjamin Loison Sep 28 '22 at 10:48
  • Your question can be greatly improved if you add input table and expected output table to the question. [Tables](https://webapps.stackexchange.com/a/161855/) are a better alternative than spreadsheets to show your data structure. If you share spreadsheets, make sure to also add images of your sheet to avoid closure of your question, as questions here must be [self](https://meta.stackoverflow.com/a/260455) [contained](https://meta.stackexchange.com/a/149892). [Your email address can also be accessed by the public](https://meta.stackoverflow.com/questions/394304/), when you share Google files. – TheMaster Sep 29 '22 at 22:17

1 Answers1

1

Continuing your previous question, you can solve your problem by using my no-key service as follows with a Google Apps Script (see my modified Google Sheet example):

function fills_embeddable_associated_to_given_youtube_videos() {
  const A = 1, B = 2;
  var sheet = SpreadsheetApp.getActiveSheet();
  for(var row = 2; row <= sheet.getLastRow(); row++)
  {
    const videoId = sheet.getRange(row, A).getValue().toString().replace("https://www.youtube.com/embed/", "").replace("view-source:", "");
    const responseStr = UrlFetchApp.fetch(`https://yt.lemnoslife.com/videos?part=status&id=${videoId}`).getContentText();
    const response = JSON.parse(responseStr);
    sheet.getRange(row, B).setValue(response["items"][0]["status"]["embeddable"]);
  }
}

Related with this StackOverflow answer.

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
  • Benjamin, thanks a million. Working fine! – Hanna Sep 28 '22 at 17:43
  • Benjamin, thanks a million! Works perfectly. – Hanna Sep 28 '22 at 17:45
  • I spotted a weird thing: a private embeded youtube link (e.g. https://www.youtube.com/embed/qPNiIeKMHyg), which was previously public, is still visible on the blog post. How could it be? Does it mean the data is cached somewhere and within time this yourtube url will finally become invisible? – Hanna Sep 29 '22 at 07:02
  • What blog post do you refer to? I don't see any problem as [`qPNiIeKMHyg`](https://www.youtube.com/watch?v=qPNiIeKMHyg) has `snippet/privacyStatus`: `public` (according to YouTube Data API v3 [Videos: list](https://developers.google.com/youtube/v3/docs/videos/list) with `part=status`), https://www.youtube.com/embed/qPNiIeKMHyg displays `Video unavailable` and my Videos: list endpoint of YouTube operational API returns `status/embedabble`: `false` (https://yt.lemnoslife.com/videos?part=status&id=qPNiIeKMHyg). AFAIK public video authors can disable embedding and it seems to be the case here. – Benjamin Loison Sep 29 '22 at 10:51