示例#1
0
def _reset_config(config_file):
    logging.info(f"{YELLOW}Creating config file: {config_file}")
    config = configparser.ConfigParser()
    config["DEFAULT"]["email"] = input("Enter your email:\n- ")
    password = input("Enter your password\n- ")
    config["DEFAULT"]["password"] = hashlib.md5(
        password.encode("utf-8")).hexdigest()
    config["DEFAULT"]["default_folder"] = (input(
        "Folder for downloads (leave empty for default 'Qobuz Downloads')\n- ")
                                           or "Qobuz Downloads")
    config["DEFAULT"]["default_quality"] = (input(
        "Download quality (5, 6, 7, 27) "
        "[320, LOSSLESS, 24B <96KHZ, 24B >96KHZ]"
        "\n(leave empty for default '6')\n- ") or "6")
    config["DEFAULT"]["default_limit"] = "20"
    config["DEFAULT"]["no_m3u"] = "false"
    config["DEFAULT"]["albums_only"] = "false"
    config["DEFAULT"]["no_fallback"] = "false"
    config["DEFAULT"]["og_cover"] = "false"
    config["DEFAULT"]["embed_art"] = "false"
    config["DEFAULT"]["no_cover"] = "false"
    config["DEFAULT"]["no_database"] = "false"
    logging.info(f"{YELLOW}Getting tokens. Please wait...")
    spoofer = spoofbuz.Spoofer()
    config["DEFAULT"]["app_id"] = str(spoofer.getAppId())
    config["DEFAULT"]["secrets"] = ",".join(spoofer.getSecrets().values())
    config["DEFAULT"]["folder_format"] = DEFAULT_FOLDER
    config["DEFAULT"]["track_format"] = DEFAULT_TRACK
    config["DEFAULT"]["smart_discography"] = "false"
    with open(config_file, "w") as configfile:
        config.write(configfile)
    logging.info(
        f"{GREEN}Config file updated. Edit more options in {config_file}"
        "\nso you don't have to call custom flags every time you run "
        "a qobuz-dl command.")
示例#2
0
def reset_config(config_file):
    print("Creating config file: " + config_file)
    config = configparser.ConfigParser()
    config["DEFAULT"]["email"] = input("\nEnter your email:\n- ")
    config["DEFAULT"]["password"] = base64.b64encode(
        input("\nEnter your password\n- ").encode()
    ).decode()
    config["DEFAULT"]["default_folder"] = (
        input("\nFolder for downloads (leave empy for default 'Qobuz Downloads')\n- ")
        or "Qobuz Downloads"
    )
    config["DEFAULT"]["default_quality"] = (
        input(
            "\nDownload quality (5, 6, 7, 27) "
            "[320, LOSSLESS, 24B <96KHZ, 24B >96KHZ]"
            "\n(leave empy for default '6')\n- "
        )
        or "6"
    )
    config["DEFAULT"]["default_limit"] = "10"
    print("Getting tokens. Please wait...")
    spoofer = spoofbuz.Spoofer()
    config["DEFAULT"]["app_id"] = str(spoofer.getAppId())
    config["DEFAULT"]["secrets"] = ",".join(spoofer.getSecrets().values())
    with open(config_file, "w") as configfile:
        config.write(configfile)
    print("Config file updated.")
示例#3
0
文件: cli.py 项目: fc7/qobuz-dl
def reset_config(config_file):
    logging.info(f"{YELLOW}Creating config file: {config_file}")
    config = configparser.ConfigParser()
    config["DEFAULT"]["email"] = input(f"{CYAN}Enter your email:\n-{DF} ")
    config["DEFAULT"]["password"] = base64.b64encode(
        input(f"{CYAN}Enter your password\n-{DF} ").encode()).decode()
    config["DEFAULT"]["default_folder"] = (input(
        f"{CYAN}Folder for downloads (leave empty for default 'Qobuz Downloads')\n-{DF} "
    ) or "Qobuz Downloads")
    config["DEFAULT"]["default_quality"] = (input(
        f"{CYAN}Download quality (5, 6, 7, 27) "
        "[320, LOSSLESS, 24B <96KHZ, 24B >96KHZ]"
        f"\n(leave empty for default '6')\n-{DF} ") or "6")
    config["DEFAULT"]["default_limit"] = "20"
    config["DEFAULT"]["no_m3u"] = "false"
    config["DEFAULT"]["albums_only"] = "false"
    config["DEFAULT"]["no_fallback"] = "false"
    config["DEFAULT"]["og_cover"] = "false"
    config["DEFAULT"]["embed_art"] = "false"
    config["DEFAULT"]["no_cover"] = "false"
    logging.info(f"{YELLOW}Getting tokens. Please wait...")
    spoofer = spoofbuz.Spoofer()
    config["DEFAULT"]["app_id"] = str(spoofer.getAppId())
    config["DEFAULT"]["secrets"] = ",".join(spoofer.getSecrets().values())
    with open(config_file, "w") as configfile:
        config.write(configfile)
    logging.info(
        f"{GREEN}Config file updated. Edit more options in {config_file}"
        "\nso you don't have to call custom flags every time you run "
        "a qobuz-dl command.")
示例#4
0
    def get_qobuz_app_id_and_secret(self, username, password):
        maybe_app = get_keyring("app_id")
        maybe_secret = get_keyring("app_secret")

        if (maybe_app and maybe_secret and self.secret_works(
                username, password, maybe_app, maybe_secret)):
            return [maybe_app, maybe_secret]
        else:
            spoofer = spoofbuz.Spoofer()
            maybe_app = spoofer.getAppId()
            logger.info(spoofer.getSecrets())
            maybe_secrets = [
                secret for secret in spoofer.getSecrets().values() if secret
            ]

            for secret in maybe_secrets:
                res = self.secret_works(username, password, maybe_app, secret)
                if res:
                    set_keying("app_id", maybe_app)
                    set_keying("app_secret", secret)
                    return [maybe_app, secret]
            raise MopidyQobuzConfigError("No secrets worked")
示例#5
0
 def get_tokens(self):
     spoofer = spoofbuz.Spoofer()
     self.app_id = spoofer.getAppId()
     self.secrets = [
         secret for secret in spoofer.getSecrets().values() if secret
     ]  # avoid empty fields