Browse Source

Merge branch 'windows_compatible' of DebenOldert/Music-Downloader into master

Deben Oldert 6 năm trước cách đây
mục cha
commit
79a554d0da
2 tập tin đã thay đổi với 6 bổ sung3 xóa
  1. 2 2
      helper/sites/download.py
  2. 4 1
      main.py

+ 2 - 2
helper/sites/download.py

@@ -36,7 +36,7 @@ def download(item, type='GET', parameters=None, headers=None, cookies=None, stre
         console.output('Assuming it\'s a mp3 file', console.DBG_INFO)
         name = name + '.mp3'
 
-    full_name = '{0}/{1}'.format(Settings.tmpDir, name)
+    full_name = os.path.abspath('{0}/{1}'.format(Settings.tmpDir, name))
 
     if item.bitrate is Empty and item.bytes is None:
         size = file.headers.get('content-length')
@@ -87,7 +87,7 @@ def savefileprogress(name, full_name, file, item):
 
         name = urllib.parse.unquote('{x.artist} - {x.title}'.format(x=tags))
 
-    full_save_name = '{0}/{1}'.format(Settings.SaveDir, name)
+    full_save_name = os.path.abspath('{0}/{1}'.format(Settings.SaveDir, name))
     os.rename(full_name, full_save_name)
     console.output('Moved to {0}'.format(full_save_name), level=console.DBG_INFO)
 

+ 4 - 1
main.py

@@ -14,7 +14,9 @@ def init():
 
     Settings.tmpDir = os.path.expanduser(os.getenv('MD_TMP', '/tmp'))
 
-    directory(os.getenv('MD_SAVEDIR', '~/Music/iTunes/iTunes Media/Automatically Add to iTunes'))
+    os.makedirs(Settings.tmpDir, exist_ok=True)
+
+    directory(os.getenv('MD_SAVEDIR', '~/Downloads'))
 
     quality(os.getenv('MD_QUALITY', '300'))
 
@@ -129,6 +131,7 @@ def directory(dir=None):
     if dir is None:
         dir = console.ask_input('Enter new save directory')
     Settings.SaveDir = os.path.expanduser(dir)
+    os.makedirs(Settings.SaveDir, exist_ok=True)
     console.output('New save directory: {0}'.format(Settings.SaveDir), level=console.DBG_INFO)
     return True