Created
November 15, 2015 17:48
-
-
Save dattaz/80c94db5d22b2bb5b96f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import youtube_dl | |
import time | |
import sys | |
url = "https://www.youtube.com/watch?v=fiore9Z5iUg" | |
with youtube_dl.YoutubeDL({'outtmpl': 'video.mp4'}) as ydl: | |
attempts = 0 | |
while attempts < 5: | |
try: | |
ydl.download([url]) | |
break | |
except: | |
e = sys.exc_info()[0] | |
attempts += 1 | |
print "error : " + str(e) | |
if attempts == 5: | |
sys.exit("Error during getting video") | |
print "We will re-try to get this video in 10s" | |
time_to_wait = 60 * attempts | |
time.sleep(time_to_wait) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment