def id_and_search(limit=1): """services are defined in cc.audio_services, and request with map_service from main """ check_dir() rec_audio() acr_res = identify_audio() status_code = acr_res['status']['code'] if status_code == 1001: print('No result') return title = acr_res['metadata']['music'][0]['title'] title = re.sub(RE_BRACKETS, '', title) q = '{} {} {}'.format(title, acr_res['metadata']['music'][0]['album']['name'], acr_res['metadata']['music'][0]['artists'][0]['name']) print(f'Found: {q}') # get services and check login active_services = ci.map_service(cc.audio_services) master_login(**{str(s).lower(): s for s in active_services}, verbose=False) r_tracks = [] for service in active_services: r_tracks += service.search_track(q, limit=limit) dtq_cli.search_track(q=q, dtq_tracks=r_tracks, **{str(s).lower(): s for s in active_services})
def user_playlist_data(): """gets users playlist data uses dtq as service argument""" services = ci.map_service(request.args['service']) res = [] # qobuz does not work, no playlists to test! for service in services: res += service.get_user_playlists_data() return jsonify(res)
def track(): """ search for tracks on specified service Args: `q` Search argument `service` d = Deezer, t = Tidal, q = Qobuz Able to combine them however it is possible, so : tq = Tidal and Qobuz """ query = request.args['q'] limit = int(request.args.get('limit', 5)) services = ci.map_service(request.args['service']) q_tracks = [] for service in services: q_tracks += service.search_track(query, limit=limit) return jsonify(q_tracks)
def track_adv_search(): """ Advanced Search with ratios """ title = request.args['title'] artist = request.args['artist'] album = request.args.get('album', '') isrc = request.args.get('isrc', '') services = ci.map_service(request.args['service']) tracks = adv_search(**{str(s).lower(): s for s in services}, title=title, artist=artist, album=album, isrc=isrc) return jsonify(tracks)
def main(args, start): if cc.prod: opsystem = platform.system() if opsystem == 'Windows': os.system('cls') else: os.system('clear') end = time.time() if cc.prod == False: print(f'STARTUP TOOK: {end - start}') print(''' _____ __ __ ____ __ ___ ____ ___ ___ / ___/ / // / / _/ / |/ / / __/ / _ \\ / _ | / /__ / _ / _/ / / /|_/ / / _/ / , _/ / __ | \\___/ /_//_/ /___/ /_/ /_/ /___/ /_/|_| /_/ |_| h for help page ''') # get services in list from config if cc.auto_login != '' and cc.auto_login != None and args.noautologin == False: aservices = ci.map_service(cc.auto_login, _format='dict', check_login=False) master_login(**aservices) if args.sync: sync() if args.url: chimera_cli.guess_cmd(args.url, ci.deezer, ci.tidal, ci.qobuz, ci.soundcloud, ci.napster, ci.spotify_conversion) # won't work in concurrent mode sys.exit() while True: write_active() command = input('-> ').split(' ') if command[0].startswith('http'): chimera_cli.guess_cmd(command[0], ci.deezer, ci.tidal, ci.qobuz, ci.soundcloud, ci.napster, ci.spotify_conversion) # handel service switching elif command[0] == 'tidal': ci.active = ci.a_tidal elif command[0] == 'deezer': ci.active = ci.a_deezer elif command[0] == 'qobuz': ci.active = ci.a_qobuz elif command[0] == 'dtq': ci.active = ci.a_dtq elif command[0] == 'soundcloud': ci.active = ci.a_soundcloud elif command[0] == 'napster': ci.active = ci.a_napster elif command[0] == 'gpm': ci.active = ci.a_gpm elif command[0] == 'login': login() elif command[0] == 'loginall': login_all() elif command[0] == 'grab': if len(command) <= 1: print("missing argument for 'grab'") continue if command[1] == 'album': grab_album(command[2]) elif command[1] == 'track': grab_track(command[2]) elif command[1] == 'data': print(ci.deezer.get_track_data_public(command[2])) elif command[1] == 'discography': grab_discography(command[2]) elif command[1] == 'playlist': grab_playlist(command[2]) elif command[1] == 'saved': grab_saved() elif command[1] == 'video': grab_video(command[2]) elif command[1] == 'videos': grab_videos_from_artist(command[2]) elif command[1] == 'show': grab_show(command[2]) elif command[1] == 'episode': grab_episode(command[2]) elif command[1] == 'label': grab_label(command[2]) elif command[0] == 'search': if len(command) <= 1: print("missing argument for 'search'") continue if command[1] == 'isrc': search_isrc(command[2]) elif command[1] == 'track': search_track() elif command[1] == 'album': search_album() elif command[1] == 'video': search_video() elif command[1] == 'adv': chimera_search() elif command[0] == 'show': if len(command) <= 1: print("missing argument for 'show'") continue if command[1] == 'track': show_track(command[2]) elif command[1] == 'playlists': show_playlists() elif command[1] == 'video': show_video(command[2]) elif command[1] == 'status': chimera_cli.show_status() elif command[1] == 'queue': chimera_cli.show_queue(ci) elif command[0] == 'csv': read_csv() elif command[0] == 'config': if len(command) <= 1: print("missing argument for 'config'") continue if command[1] == 'show': chimera_cli.config_show() elif command[1] == 'export': chimera_cli.config_export() elif command[1] == 'import': chimera_cli.config_import() elif command[1] == 'default': chimera_cli.set_default() elif command[0] == 'spotify': if len(command) == 1: ci.active = ci.a_spotify else: if command[1] == ci.a_deezer: ci.spotify_conversion = ci.deezer ci.active = ci.a_spotify elif command[1] == ci.a_tidal: ci.spotify_conversion = ci.tidal ci.active = ci.a_spotify elif command[1] == ci.a_qobuz: ci.spotify_conversion = ci.qobuz ci.active = ci.a_spotify elif command[0] == 'h': print_help() elif command[0] == 'tag': tag_mp3_with_search( r"D:\temp\Musik_notabug\Eminem\Rap God\Eminem - 1 - Rap God.m4a", 'Tswhyxgv4dkxo5ikcwrz7qrtmiy') elif command[0] == 'test': test() elif command[0] == 'test2': test2() elif command[0] == 'test3': test3() elif command[0] == 'test4': test4() elif command[0] == 'exit': break elif command[0] == 'db': if command[1] == 'update': chimera.utils.update_tracks_in_db(ci.deezer) elif command[0] == 'validate': if len(command) == 2: chimera.utils.validate_music_archive(delete=True) else: chimera.utils.validate_music_archive() elif command[0] == 'proxy': ci.tidal.proxy_test() elif command[0] == 'appid': ci.qobuz.get_appid_and_secret() elif command[0] == 'seed': print(ci.qobuz.get_type_seed()) elif command[0] == 'listen': listen() elif command[0] == 'setup': if len(command) <= 1: print("missing argument for 'setup'") continue if command[1] == 'audio': setup_audio() elif command[1] == 'chimera': setup_chimera() elif command[1] == 'api': from db import create_api_token print('Add this token to your config: ' + create_api_token()) elif command[1] == 'reset-gpm': setup_reset_gpm() elif command[0] == 'track': if len(command) <= 1: print("missing argument for 'track'") continue if command[1] == 'quality': if len(command) > 2: test_track_quality(command[2]) else: print('unknown command...')
def login(): # """login with qobuz credentials from config""" services = ci.map_service(request.args['service'], _format='dict') master_login(**services) return jsonify('OK')