James
James

Reputation: 1132

How to check if video has been deleted or removed in youtube using python

i have a csv file where i have 1000 videos links . I want to check whether these videos still exists or they have been removed or deleted from YouTube. How can i do that in python?

Please guide on this

Upvotes: 3

Views: 3459

Answers (3)

aminos cheddadi
aminos cheddadi

Reputation: 21

this is my code as a function.

    def getutl(a="youtubeurl"):
          a=str(a)
          for i in enumerate(a):
               if i[2]="v":
                  idy=a[:i[1]]
                  break
          b=requests.get("http://img.youtube.com/vi/{}/mqdefault.jpg".format(idy))
          if b==200:
               print("video exists")
          else:
              print("video doesn't exists")

Upvotes: 2

johnh10
johnh10

Reputation: 4185

I'm the author of the Video Link Checker plugin that does this for YouTube, DailyMotion, Vimeo, etc.

I can't help with Python code but I can tell you there are a few things to check for each video. 1st you'll need to query the YouTube API videos:list endpoint in batches of 50 videoIDs max, then check the results. Here are a couple of tips:

  1. Check the videoIDs of the items returned against what was requested. Those missing have been deleted from YouTube.
  2. For the videos returned, you should still check fields like privacyStatus, embeddable, and regionRestriction to see if video is still playable. It's not uncommon for those to change.

Hope that helps.

Upvotes: 2

frisinacho
frisinacho

Reputation: 160

You could use the Official Youtube API for Python.

There's a similar question for this problem in Stackoverflow, but meant for PHP (check this reference).

Upvotes: 3

Related Questions