Copy from cache

This commit is contained in:
localhost_frssoft 2023-01-31 15:23:56 +03:00
parent ea4dc5eeca
commit 71ad1daf2b

View File

@ -1,6 +1,7 @@
import src.fw_api
import sys
import shutil
from urllib.parse import unquote
@ -13,6 +14,10 @@ def get_remote_file_name(url):
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
r = src.fw_api.current_instance.s.get(url, stream=True)
if not name:
@ -39,6 +44,12 @@ def download_track(url, name=None):
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):
'''Print at position x, y caption in terminal (? Linux only)'''
sys.stdout.write("\x1b7\x1b[%d;%df%s\x1b8" % (x, y, text))