Esempio n. 1
0
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})
Esempio n. 2
0
def guess_cmd(url, deezer, tidal, qobuz, soundcloud, napster, spotify):
    import cli.deezer_cli
    import cli.tidal_cli
    import cli.qobuz_cli
    import cli.soundcloud_cli
    import cli.napster_cli
    import cli.spotify_cli

    RE_DE_ALBUM = r'deezer\..*/\w{2,}/album/(?P<id>\d{1,})'
    RE_DE_TRACK = r'deezer\..*/track/(?P<id>\d{1,})'
    RE_DE_PLAYLIST = r'deezer\..*\w{2,}/playlist/(?P<id>\d{1,})'

    RE_QO_ALBUM = r'(play|open).qobuz\..*/album/(?P<id>\w{1,})'
    RE_QO_TRACK = r'(play|open).qobuz\..*/track/(?P<id>\d{1,})'
    RE_QO_PLAYLIST = r'(play|open).qobuz\..*/playlist/(?P<id>\d{1,})'

    RE_TI_ALBUM = r'listen.tidal\..*/album/(?P<id>\d{1,})'
    RE_TI_TRACK = r'tidal\..*/browse/track/(?P<id>\d{1,})'
    RE_TI_PLAYLIST = r'(listen.)?tidal\..*/playlist/(?P<id>[a-z0-9-]{1,})'

    RE_SP_TRACK = r'open.spotify.com/track/(?P<id>\w{1,})?'

    smart_cli = {
        'deezer_album': [RE_DE_ALBUM, cli.deezer_cli.grab_album, deezer],
        'deezer_track': [RE_DE_TRACK, cli.deezer_cli.grab_track, deezer],
        'deezer_playlist': [RE_DE_PLAYLIST, cli.deezer_cli.grab_playlist, deezer],
        'qobuz_album': [RE_QO_ALBUM, cli.qobuz_cli.grab_album, qobuz],
        'qobuz_track': [RE_QO_TRACK, cli.qobuz_cli.grab_track, qobuz],
        'qobuz_playlist': [RE_QO_PLAYLIST, cli.qobuz_cli.grab_playlist, qobuz],
        'tidal_album': [RE_TI_ALBUM, cli.tidal_cli.grab_album, tidal],
        'tidal_track': [RE_TI_TRACK, cli.tidal_cli.grab_track, tidal],
        'tidal_playlist': [RE_TI_PLAYLIST, cli.tidal_cli.grab_playlist, tidal],
        'spotify_track': [RE_SP_TRACK, cli.spotify_cli.grab_track, spotify]
    }

    # maybe add regex for napster
    if 'napster' in url:
        # check track first => napster.com/artist/name/album/name/track/name
        if 'track' in url:
            _login_napster(napster)
            cli.napster_cli.grab_track_from_url(url, napster)
        elif 'album' in url:
            _login_napster(napster)
            cli.napster_cli.grab_album_from_url(url, napster)

    for name, group in smart_cli.items():
        reg, func, session = group
        re_search = re.search(reg, url)

        if re_search:
            re_search = re_search.groupdict()
            if not session.logged_in:
                master_login(**{str(session).lower(): session})
            func(re_search['id'], session)
Esempio n. 3
0
 def setUp(self):
     self.deezer = Deezer()
     master_login(deezer=self.deezer, verbose=False)
Esempio n. 4
0
 def setUp(self):
     self.gpm = GPM(cc.gpm_device_id)
     master_login(gpm=self.gpm, verbose=False)
Esempio n. 5
0
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...')
Esempio n. 6
0
def login_all():
    master_login(deezer=ci.deezer,
                 tidal=ci.tidal,
                 qobuz=ci.qobuz,
                 napster=ci.napster,
                 gpm=ci.gpm)
Esempio n. 7
0
def _login_napster(napster):
    if not napster.logged_in:
        master_login(napster=napster)
Esempio n. 8
0
 def setUp(self):
     self.qobuz = Qobuz()
     master_login(qobuz=self.qobuz, verbose=False)
Esempio n. 9
0
 def check_service(self, service):
     """checks if services is logged in"""
     if not service.logged_in:
         master_login(**{str(service).lower(): service}, verbose=False)
Esempio n. 10
0
def login():
    # """login with qobuz credentials from config"""
    services = ci.map_service(request.args['service'], _format='dict')
    master_login(**services)
    return jsonify('OK')
Esempio n. 11
0
 def setUp(self):
     self.napster = Napster(cc.napster_api_token)
     master_login(napster=self.napster, verbose=False)
Esempio n. 12
0
 def setUp(self):
     self.tidal = Tidal()
     master_login(tidal=self.tidal, verbose=False)