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

安稳与你 提交于 2021-01-27 20:53:43

问题


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


回答1:


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).




回答2:


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.




回答3:


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")


来源:https://stackoverflow.com/questions/49752459/how-to-check-if-video-has-been-deleted-or-removed-in-youtube-using-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!