问题
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:
- Check the
videoIDs
of the items returned against what was requested. Those missing have been deleted from YouTube. - For the videos returned, you should still check fields like
privacyStatus
,embeddable
, andregionRestriction
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