From efb38487739cb15149dd638201245b19fcd2b70e Mon Sep 17 00:00:00 2001 From: MrS0m30n3 Date: Wed, 30 Apr 2014 18:34:25 +0300 Subject: [PATCH] Change youtube-dl download path --- youtube_dl_gui/OptionsHandler.py | 2 +- youtube_dl_gui/UpdateThread.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/youtube_dl_gui/OptionsHandler.py b/youtube_dl_gui/OptionsHandler.py index 6b7c1b8..6e0a673 100644 --- a/youtube_dl_gui/OptionsHandler.py +++ b/youtube_dl_gui/OptionsHandler.py @@ -63,7 +63,7 @@ class OptionsHandler(): self.username = "" self.password = "" self.videoPass = "" - self.updatePath = abs_path(__file__) + self.updatePath = self.get_config_path() self.cmdArgs = "" self.enableLog = True self.writeTimeToLog = True diff --git a/youtube_dl_gui/UpdateThread.py b/youtube_dl_gui/UpdateThread.py index ff73504..b95f220 100644 --- a/youtube_dl_gui/UpdateThread.py +++ b/youtube_dl_gui/UpdateThread.py @@ -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) \ No newline at end of file