|
|
@@ -1,10 +1,9 @@
|
|
|
-import console
|
|
|
-import os
|
|
|
-import sites.helper.tagging as tagging
|
|
|
-from sites.helper.item import Empty
|
|
|
+from helper import console
|
|
|
+import helper.tagging as tagging
|
|
|
+from helper.sites.item import Empty
|
|
|
from .request import RawRequest
|
|
|
from pyquery import PyQuery
|
|
|
-from settings import Settings
|
|
|
+from helper.settings import Settings
|
|
|
|
|
|
import math
|
|
|
import urllib.parse
|
|
|
@@ -51,44 +50,44 @@ def download(item, type='GET', parameters=None, headers=None, cookies=None, stre
|
|
|
|
|
|
console.output('Bitrate: {0}kbps'.format(int(item.bitrate)))
|
|
|
|
|
|
- ans = console.ask_input('Continue downloading? [y/n]')
|
|
|
+ if item.duration_seconds is not None and int(item.bitrate) < Settings.MinQuality:
|
|
|
+ ans = console.ask_input('Continue downloading? [y/n]')
|
|
|
|
|
|
- if ans != 'y':
|
|
|
- return
|
|
|
+ if ans != 'y':
|
|
|
+ return
|
|
|
|
|
|
savefileprogress(name, full_name, file, item)
|
|
|
|
|
|
|
|
|
def savefileprogress(name, full_name, file, item):
|
|
|
- os.path.abspath(full_name)
|
|
|
-
|
|
|
console.output('Saving to: {0}'.format(full_name), level=console.DBG_INFO)
|
|
|
with open(full_name, 'wb') as f:
|
|
|
progress = 0
|
|
|
if item.bytes is not None:
|
|
|
bar = console.ProgressBar(total=item.bytes)
|
|
|
|
|
|
- for chunk in file.iter_content(chunk_size=4096):
|
|
|
- progress += len(chunk)
|
|
|
- f.write(chunk)
|
|
|
- bar.report_progress(progress=progress)
|
|
|
+ for chunk in file.iter_content(chunk_size=1024):
|
|
|
+ if chunk:
|
|
|
+ progress += len(chunk)
|
|
|
+ f.write(chunk)
|
|
|
+ bar.report_progress(progress=progress)
|
|
|
+ bar.destroy()
|
|
|
|
|
|
else:
|
|
|
- bar = console.ProgressBar()
|
|
|
f.write(file.content)
|
|
|
|
|
|
- bar.destroy()
|
|
|
+ tags = tagging.search_tags(item)
|
|
|
|
|
|
- tags = tagging.search_tags(item)
|
|
|
+ if tags is not None:
|
|
|
+ item.link_tag_item(tags)
|
|
|
|
|
|
- if tags is not None:
|
|
|
- item.link_tag_item(tags)
|
|
|
+ tagging.download_artwork(tags)
|
|
|
|
|
|
- tagging.download_artwork(tags)
|
|
|
+ tagging.write_tags_to_file(full_name, item)
|
|
|
|
|
|
- tagging.write_tags_to_file(f, item)
|
|
|
+ name = urllib.parse.unquote('{x.artist} - {x.title}'.format(x=tags))
|
|
|
|
|
|
- full_save_name = os.path.abspath('{0}/{1}'.format(Settings.SaveDir, name))
|
|
|
+ full_save_name = '{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)
|
|
|
|