Beispiel #1
0
def config(platform_flag: str, cwd: str) -> None:
    if platform_flag is None and cwd is None:
        print("""
Current settings:
    download dir -> {}
    music platform -> {} [{}]
""".format(conf.settings['download_dir'], conf.settings['music_platform'],
           conf.get_site(conf.settings['music_platform'])),
              end='')
        return

    if platform_flag is not None:
        platform_id = conf.get_platform(platform_flag)
        if platform_id is None:
            logging.critical(
                'Unexpected music platform: "{}"'.format(platform_flag))
            sys.exit(1)
        conf.settings['music_platform'] = platform_id

    if cwd is not None:
        try:
            conf.settings.make_download_dir(cwd)
        except exceptions.ClientError as e:
            logging.critical(e)
            sys.exit(1)
        conf.settings['download_dir'] = cwd

    conf.settings.save()
Beispiel #2
0
def _get_platform_id(platform_flag: str = None) -> typing.Optional[int]:
    if platform_flag is None:
        platform_id = conf.settings['music_platform']
    else:
        platform_id = conf.get_platform(platform_flag)
        if platform_id is None:
            return None
    return platform_id