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
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
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).
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:
videoIDs
of the items returned against what was requested. Those missing have been deleted from YouTube.privacyStatus
, embeddable
, and regionRestriction
to see if video is still playable. It's not uncommon for those to change.Hope that helps.
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")