def __init__(self, query, song_filter=None): self.query = str.strip(query) self.query_string = "%s %s" % (query['track_name'], query['artists']) if isinstance( query, dict) else str.strip(query) self.song_filter = song_filter self.log = Logger.get_logger() self.search_result = { 'query': self.query_string, 'track_name': None, 'artists': None, 'similarity_ratio': None, 'source': None, 'files': [] }
# -*- coding: utf-8 -*- import json from json import JSONDecodeError import requests # from requests.adapters import HTTPAdapter # from requests.exceptions import RetryError from urllib3.exceptions import MaxRetryError from urllib3.util.retry import Retry import urllib3 from src import Logger log = Logger.get_logger() # headers = { # 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', # 'Accept-Encoding': 'gzip, deflate', # 'Accept-Language': 'zh-CN,zh;q=0.9', # 'Cache-Control': 'max-age=0', # 'Connection': 'keep-alive', # 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) ' # 'Chrome/63.0.3239.132 Safari/537.36', # } # # # def _init_retry_session(retries=3, backoff_factor=0.3, # status_forcelist=(500, 502, 503, 504), session=None): # session = session or requests.Session() # retry = Retry(
Config = Config.Config() # Need to do this first. if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'): runningInfo = ('running in a PyInstaller bundle') DBpath = Path(Config.DB_LOCATION + Config.DB_NAME) LGpath = Config.NAME +".log" # Must be a string for a logger path. icon = "" # icon used by notifications else: runningInfo = ('running in a normal Python process') DBpath = Path("data", Config.DB_LOCATION + Config.DB_NAME) LGpath = "data\\" +Config.NAME +".log" # Must be a string for a logger path. icon = "resources\\tea.ico" # icon used by notifications songLibrary = Library.Library(DBpath, Config.DB_FORMAT) # Create the song library. logger = Logger.get_logger(LGpath) # Create the logger. timer = Timer.Timer() sourceDir, duplicateFile, noLoad, noSave, build, difference, noPrint, zap, checkThe, checkDB = args.parseArgs(Config.NAME, Config.VERSION, logger) if checkDB == 1: duplicateUtils.checkDatabase(songLibrary, "test", DBpath, logger, Config.NAME, Config.VERSION, icon, timeout, Config.NOTIFICATION) # Run data integrity check in test mode on library. elif checkDB == 2: duplicateUtils.checkDatabase(songLibrary, "delete", DBpath, logger, Config.NAME, Config.VERSION, icon, timeout, Config.NOTIFICATION) # Run data integrity check in delete mode on library. timer.Start if Config.SOUNDEX: mode = f"Using Soundex for {Config.TAGS} matching" else: mode = f"Using Strings for {Config.TAGS} matching"