Skip to content

Commit

Permalink
hotfix youtube-dl
Browse files Browse the repository at this point in the history
  • Loading branch information
DoyunShin committed Nov 2, 2020
1 parent 99e4f3f commit c8c75db
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions Server/youtubedl.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,36 @@ def __init__(self, storage):
def download(self, yturl, ip):
import youtube_dl
self.storage.debuglogger(ip=ip, desc="Import youtube_dl OK", code=200)
try:
self.storage.debuglogger(ip=ip, desc="Start to get video info", code=200)
turl = youtube_dl.YoutubeDL({}).extract_info("https://youtu.be/"+yturl, download=False)
except youtube_dl.utils.DownloadError:
try:
from time import sleep
sleep(1)
self.storage.debuglogger(ip=ip, desc="Start to get video info Retry", code=200)
turl = youtube_dl.YoutubeDL({}).extract_info("https://youtu.be/"+yturl, download=False)
except:
self.storage.logger(ip=ip, desc="Error to Download Thumbnail", code=503)
raise IndexError
except youtube_dl.utils.RegexNotFoundError:
#try:
# self.storage.debuglogger(ip=ip, desc="Start to get video info", code=200)
# turl = youtube_dl.YoutubeDL({}).extract_info("https://youtu.be/"+yturl, download=False)
#except youtube_dl.utils.DownloadError:
# try:
# from time import sleep
# sleep(1)
# self.storage.debuglogger(ip=ip, desc="Start to get video info Retry", code=200)
# turl = youtube_dl.YoutubeDL({}).extract_info("https://youtu.be/"+yturl, download=False)
# except:
# self.storage.logger(ip=ip, desc="Error to Download Thumbnail", code=503)
# raise IndexError
#except youtube_dl.utils.RegexNotFoundError:
# try:
# from time import sleep
# sleep(1)
# self.storage.debuglogger(ip=ip, desc="Start to get video info Retry", code=200)
# turl = youtube_dl.YoutubeDL({}).extract_info("https://youtu.be/"+yturl, download=False)
# except:
# self.storage.logger(ip=ip, desc="Error to Download Thumbnail", code=503)
# raise IndexError
#except:
# self.storage.logger(ip=ip, desc="Something Went Wrong!! youtubedl.py::29", code=503)
# raise SyntaxError
while True:
try:
from time import sleep
sleep(1)
self.storage.debuglogger(ip=ip, desc="Start to get video info Retry", code=200)
turl = youtube_dl.YoutubeDL({}).extract_info("https://youtu.be/"+yturl, download=False)
break
except:
self.storage.logger(ip=ip, desc="Error to Download Thumbnail", code=503)
raise IndexError
except:
self.storage.logger(ip=ip, desc="Something Went Wrong!! youtubedl.py::29", code=503)
raise SyntaxError
pass
self.storage.debuglogger(ip=ip, desc="Get video info OK", code=200)

print("\n\n")
Expand All @@ -57,9 +63,9 @@ def movie(self, yturl, turl, ip):
#f = open(yturl+".mp4", "wb")
#f.write(get(data["url"]).content)
#f.close()
self.storage.debuglogger(ip=ip, desc="Start to download video", code=200)
from os import system
from os.path import isfile
self.storage.debuglogger(ip=ip, desc="Start to download video", code=200)
while True:
try:
system("youtube-dl --no-warnings -f 134 -o %(id)s.%(ext)s {url}".format(url="https://youtu.be/"+yturl))
Expand Down

0 comments on commit c8c75db

Please sign in to comment.