|
@@ -11,7 +11,7 @@ import json
|
|
|
import os
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
-def download(item, type='GET', parameters=None, headers=None, cookies=None, stream=True):
|
|
|
|
|
|
|
+def download(item, type='GET', parameters=None, headers=None, cookies=None, stream=True, automode=False, tags=None):
|
|
|
console.output('Requesting dl: {0}'.format(item.download_url), level=console.DBG_INFO)
|
|
console.output('Requesting dl: {0}'.format(item.download_url), level=console.DBG_INFO)
|
|
|
try:
|
|
try:
|
|
|
if type == 'GET':
|
|
if type == 'GET':
|
|
@@ -28,7 +28,7 @@ def download(item, type='GET', parameters=None, headers=None, cookies=None, stre
|
|
|
stream=stream)
|
|
stream=stream)
|
|
|
except:
|
|
except:
|
|
|
notExist(item)
|
|
notExist(item)
|
|
|
- return
|
|
|
|
|
|
|
+ return False
|
|
|
|
|
|
|
|
name = urllib.parse.unquote('{x.artist} - {x.title}'.format(x=item))
|
|
name = urllib.parse.unquote('{x.artist} - {x.title}'.format(x=item))
|
|
|
|
|
|
|
@@ -51,15 +51,18 @@ def download(item, type='GET', parameters=None, headers=None, cookies=None, stre
|
|
|
console.output('Bitrate: {0}kbps'.format(int(item.bitrate)))
|
|
console.output('Bitrate: {0}kbps'.format(int(item.bitrate)))
|
|
|
|
|
|
|
|
if item.duration_seconds is not None and int(item.bitrate) < Settings.MinQuality.get():
|
|
if item.duration_seconds is not None and int(item.bitrate) < Settings.MinQuality.get():
|
|
|
- ans = console.ask_input('Continue downloading? [y/n]')
|
|
|
|
|
-
|
|
|
|
|
- if ans != 'y':
|
|
|
|
|
|
|
+ if automode:
|
|
|
return
|
|
return
|
|
|
|
|
+ else:
|
|
|
|
|
+ ans = console.ask_input('Continue downloading? [y/n]')
|
|
|
|
|
+
|
|
|
|
|
+ if ans != 'y':
|
|
|
|
|
+ return False
|
|
|
|
|
|
|
|
- savefileprogress(name, full_name, file, item)
|
|
|
|
|
|
|
+ return savefileprogress(name, full_name, file, item, tags=tags)
|
|
|
|
|
|
|
|
|
|
|
|
|
-def savefileprogress(name, full_name, file, item):
|
|
|
|
|
|
|
+def savefileprogress(name, full_name, file, item, tags=None):
|
|
|
console.output('Saving to: {0}'.format(full_name), level=console.DBG_INFO)
|
|
console.output('Saving to: {0}'.format(full_name), level=console.DBG_INFO)
|
|
|
with open(full_name, 'wb') as f:
|
|
with open(full_name, 'wb') as f:
|
|
|
progress = 0
|
|
progress = 0
|
|
@@ -76,7 +79,8 @@ def savefileprogress(name, full_name, file, item):
|
|
|
else:
|
|
else:
|
|
|
f.write(file.content)
|
|
f.write(file.content)
|
|
|
|
|
|
|
|
- tags = tagging.search_tags(item)
|
|
|
|
|
|
|
+ if tags is None:
|
|
|
|
|
+ tags = tagging.search_tags(item)
|
|
|
|
|
|
|
|
if tags is not None:
|
|
if tags is not None:
|
|
|
item.link_tag_item(tags)
|
|
item.link_tag_item(tags)
|
|
@@ -85,7 +89,7 @@ def savefileprogress(name, full_name, file, item):
|
|
|
|
|
|
|
|
tagging.write_tags_to_file(full_name, item)
|
|
tagging.write_tags_to_file(full_name, item)
|
|
|
|
|
|
|
|
- name = urllib.parse.unquote('{x.artist} - {x.title}'.format(x=tags)) + '.mp3'
|
|
|
|
|
|
|
+ name = urllib.parse.unquote('{x.artist} - {x.title}.mp3'.format(x=tags))
|
|
|
|
|
|
|
|
full_save_name = os.path.abspath('{0}/{1}'.format(Settings.SaveDir.get(), name))
|
|
full_save_name = os.path.abspath('{0}/{1}'.format(Settings.SaveDir.get(), name))
|
|
|
os.rename(full_name, full_save_name)
|
|
os.rename(full_name, full_save_name)
|
|
@@ -93,6 +97,8 @@ def savefileprogress(name, full_name, file, item):
|
|
|
|
|
|
|
|
console.output('Download of {0} completed!'.format(name))
|
|
console.output('Download of {0} completed!'.format(name))
|
|
|
|
|
|
|
|
|
|
+ return True
|
|
|
|
|
+
|
|
|
|
|
|
|
|
def notExist(item):
|
|
def notExist(item):
|
|
|
console.output('{x.title} at {x.download_url} does not exist'.format(x=item))
|
|
console.output('{x.title} at {x.download_url} does not exist'.format(x=item))
|