|
|
@ -7,7 +7,11 @@ from wx.lib.pubsub import pub as Publisher |
|
|
|
from threading import Thread |
|
|
|
from urllib2 import urlopen, URLError, HTTPError |
|
|
|
|
|
|
|
from .Utils import fix_path |
|
|
|
from .Utils import ( |
|
|
|
fix_path, |
|
|
|
file_exist, |
|
|
|
makedir |
|
|
|
) |
|
|
|
|
|
|
|
LATEST_YOUTUBE_DL = 'https://yt-dl.org/latest/' |
|
|
|
PUBLISHER_TOPIC = 'update' |
|
|
@ -20,6 +24,7 @@ class UpdateThread(Thread): |
|
|
|
self.youtubeDLFile = youtubeDLFile |
|
|
|
self.updatePath = fix_path(updatePath) |
|
|
|
self.url = LATEST_YOUTUBE_DL + youtubeDLFile |
|
|
|
self.check_path() |
|
|
|
self.start() |
|
|
|
|
|
|
|
def run(self): |
|
|
@ -33,3 +38,7 @@ class UpdateThread(Thread): |
|
|
|
msg = 'Youtube-dl download failed ' + str(e) |
|
|
|
CallAfter(Publisher.sendMessage, PUBLISHER_TOPIC, msg) |
|
|
|
CallAfter(Publisher.sendMessage, PUBLISHER_TOPIC, 'finish') |
|
|
|
|
|
|
|
def check_path(self): |
|
|
|
if not file_exist(self.updatePath): |
|
|
|
makedir(self.updatePath) |