mirror of
https://github.com/yaronzz/Tidal-Media-Downloader.git
synced 2026-06-13 04:05:07 +03:00
Refactoring: Mainly removed unused imports.
This commit is contained in:
@@ -8,16 +8,14 @@
|
||||
@Contact : yaronhuang@foxmail.com
|
||||
@Desc :
|
||||
'''
|
||||
import aigpy
|
||||
import logging
|
||||
|
||||
from paths import *
|
||||
from printf import *
|
||||
from decryption import *
|
||||
from tidal import *
|
||||
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
from decryption import *
|
||||
from printf import *
|
||||
from tidal import *
|
||||
|
||||
|
||||
def __isSkip__(finalpath, url):
|
||||
if not SETTINGS.checkExist:
|
||||
return False
|
||||
@@ -164,7 +162,7 @@ def downloadTrack(track: Track, album=None, playlist=None, userProgress=None, pa
|
||||
tool.setPartSize(partSize)
|
||||
check, err = tool.start(SETTINGS.showProgress and not SETTINGS.multiThread)
|
||||
if not check:
|
||||
Printf.err(f"DL Track[{track.title}] failed.{str(err)}")
|
||||
Printf.err(f"DL Track '{track.title}' failed: {str(err)}")
|
||||
return False, str(err)
|
||||
|
||||
# encrypted -> decrypt and remove encrypted file
|
||||
@@ -187,9 +185,10 @@ def downloadTrack(track: Track, album=None, playlist=None, userProgress=None, pa
|
||||
|
||||
__setMetaData__(track, album, path, contributors, lyrics)
|
||||
Printf.success(track.title)
|
||||
|
||||
return True, ''
|
||||
except Exception as e:
|
||||
Printf.err(f"DL Track[{track.title}] failed.{str(e)}")
|
||||
Printf.err(f"DL Track '{track.title}' failed: {str(e)}")
|
||||
return False, str(e)
|
||||
|
||||
|
||||
|
||||
@@ -9,13 +9,6 @@
|
||||
@Desc :
|
||||
"""
|
||||
|
||||
import aigpy
|
||||
import time
|
||||
|
||||
from model import *
|
||||
from enums import *
|
||||
from tidal import *
|
||||
from printf import *
|
||||
from download import *
|
||||
|
||||
'''
|
||||
|
||||
@@ -8,15 +8,11 @@
|
||||
@Contact : yaronhuang@foxmail.com
|
||||
@Desc :
|
||||
"""
|
||||
import sys
|
||||
import aigpy
|
||||
import _thread
|
||||
import importlib
|
||||
import sys
|
||||
|
||||
from events import *
|
||||
from settings import *
|
||||
from printf import *
|
||||
from enums import *
|
||||
|
||||
|
||||
def enableGui():
|
||||
@@ -38,6 +34,7 @@ else:
|
||||
from PyQt5 import QtWidgets
|
||||
from qt_material import apply_stylesheet
|
||||
|
||||
|
||||
class SettingView(QtWidgets.QWidget):
|
||||
def __init__(self, ) -> None:
|
||||
super().__init__()
|
||||
@@ -55,12 +52,14 @@ else:
|
||||
self.mainGrid.addWidget(self.c_pathTrackFormat)
|
||||
self.mainGrid.addWidget(self.c_pathVideoFormat)
|
||||
|
||||
|
||||
class EmittingStream(QObject):
|
||||
textWritten = pyqtSignal(str)
|
||||
|
||||
def write(self, text):
|
||||
self.textWritten.emit(str(text))
|
||||
|
||||
|
||||
class MainView(QtWidgets.QWidget):
|
||||
s_downloadEnd = pyqtSignal(str, bool, str)
|
||||
|
||||
@@ -314,6 +313,7 @@ else:
|
||||
|
||||
self.set_table_search_results(tracks, Type.Track)
|
||||
|
||||
|
||||
def startGui():
|
||||
aigpy.cmd.enableColor(False)
|
||||
|
||||
@@ -327,7 +327,6 @@ else:
|
||||
|
||||
app.exec_()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
SETTINGS.read(getProfilePath())
|
||||
TOKEN.read(getTokenPath())
|
||||
|
||||
@@ -8,23 +8,18 @@
|
||||
@Contact : yaronhuang@foxmail.com
|
||||
@Desc : tidal api
|
||||
'''
|
||||
import json
|
||||
import random
|
||||
import re
|
||||
import time
|
||||
from typing import Union, List
|
||||
|
||||
import aigpy
|
||||
import base64
|
||||
import requests
|
||||
from xml.etree import ElementTree
|
||||
|
||||
from model import *
|
||||
from enums import *
|
||||
from settings import *
|
||||
|
||||
import requests
|
||||
import tidalapi
|
||||
|
||||
from model import *
|
||||
from settings import *
|
||||
|
||||
# SSL Warnings | retry number
|
||||
requests.packages.urllib3.disable_warnings()
|
||||
requests.adapters.DEFAULT_RETRIES = 5
|
||||
@@ -47,7 +42,8 @@ class TidalAPI(object):
|
||||
if respond.url.find("playbackinfopostpaywall") != -1 and SETTINGS.downloadDelay is not False:
|
||||
# random sleep between 0.5 and 5 seconds and print it
|
||||
sleep_time = random.randint(500, 5000) / 1000
|
||||
print(f"Sleeping for {sleep_time} seconds, to mimic human behaviour and prevent too many requests error")
|
||||
print(
|
||||
f"Sleeping for {sleep_time} seconds, to mimic human behaviour and prevent too many requests error")
|
||||
time.sleep(sleep_time)
|
||||
|
||||
if respond.status_code == 429:
|
||||
@@ -497,5 +493,6 @@ class TidalAPI(object):
|
||||
|
||||
return tracks
|
||||
|
||||
|
||||
# Singleton
|
||||
TIDAL_API = TidalAPI()
|
||||
|
||||
Reference in New Issue
Block a user