mirror of
http://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-22 01:01:27 +00:00
Copy from cache
This commit is contained in:
parent
ea4dc5eeca
commit
71ad1daf2b
11
src/utils.py
11
src/utils.py
|
@ -1,6 +1,7 @@
|
||||||
import src.fw_api
|
import src.fw_api
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import shutil
|
||||||
from urllib.parse import unquote
|
from urllib.parse import unquote
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,6 +14,10 @@ def get_remote_file_name(url):
|
||||||
|
|
||||||
|
|
||||||
def download_track(url, name=None):
|
def download_track(url, name=None):
|
||||||
|
if not url.startswith('http'):
|
||||||
|
copy_from_cache(url)
|
||||||
|
return
|
||||||
|
|
||||||
url = url.split('?')[0] # Stripe all params from url
|
url = url.split('?')[0] # Stripe all params from url
|
||||||
r = src.fw_api.current_instance.s.get(url, stream=True)
|
r = src.fw_api.current_instance.s.get(url, stream=True)
|
||||||
if not name:
|
if not name:
|
||||||
|
@ -39,6 +44,12 @@ def download_track(url, name=None):
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
|
||||||
|
def copy_from_cache(url_file):
|
||||||
|
uuid = url_file.split(r'/')[-1]
|
||||||
|
original_name = get_remote_file_name(f'https://{src.fw_api.current_instance.instance}/api/v1/listen/{uuid}')
|
||||||
|
shutil.copyfile(url_file, original_name)
|
||||||
|
|
||||||
|
|
||||||
def print_there(x, y, text):
|
def print_there(x, y, text):
|
||||||
'''Print at position x, y caption in terminal (? Linux only)'''
|
'''Print at position x, y caption in terminal (? Linux only)'''
|
||||||
sys.stdout.write("\x1b7\x1b[%d;%df%s\x1b8" % (x, y, text))
|
sys.stdout.write("\x1b7\x1b[%d;%df%s\x1b8" % (x, y, text))
|
||||||
|
|
Loading…
Reference in a new issue