Skip to content

console

Module for holding console related actions.

check_for_updates() ¤

Check for updates to the current version.

Source code in spotdl/utils/console.py
81
82
83
84
85
86
87
88
def check_for_updates():
    """
    Check for updates to the current version.
    """

    version_message = get_update_status()

    print(version_message)

download_ffmpeg() ¤

Handle ffmpeg download process and print the result.

Source code in spotdl/utils/console.py
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
def download_ffmpeg():
    """
    Handle ffmpeg download process and print the result.
    """

    if get_local_ffmpeg() is not None or is_ffmpeg_installed():
        overwrite_ffmpeg = input(
            "FFmpeg is already installed. Do you want to overwrite it? (y/N): "
        )

        if overwrite_ffmpeg.lower() == "y":
            local_ffmpeg = ffmpeg_download()

            if local_ffmpeg.is_file():
                print(f"FFmpeg successfully downloaded to {local_ffmpeg.absolute()}")
            else:
                print("FFmpeg download failed")
    else:
        print("Downloading FFmpeg...")
        download_path = ffmpeg_download()

        if download_path.is_file():
            print(f"FFmpeg successfully downloaded to {download_path.absolute()}")
        else:
            print("FFmpeg download failed")

generate_config() ¤

Generate the config file if it doesn't exist This is done before the argument parser so it doesn't requires operation and query to be passed.

Source code in spotdl/utils/console.py
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
def generate_config():
    """
    Generate the config file if it doesn't exist
    This is done before the argument parser so it doesn't requires `operation`
    and `query` to be passed.
    """

    config_path = get_config_file()
    if config_path.exists():
        overwrite_config = input("Config file already exists. Overwrite? (y/N): ")

        if overwrite_config.lower() != "y":
            print("Exiting...")
            return None

    with open(config_path, "w", encoding="utf-8") as config_file:
        json.dump(DEFAULT_CONFIG, config_file, indent=4)

    print(f"Config file generated at {config_path}")

    return None

generate_initial_config() ¤

Generate the initial config file if it doesn't exist.

Source code in spotdl/utils/console.py
47
48
49
50
51
52
53
54
55
def generate_initial_config():
    """
    Generate the initial config file if it doesn't exist.
    """

    if get_config_file().is_file() is False:
        config_path = get_config_file()
        with open(config_path, "w", encoding="utf-8") as config_file:
            json.dump(DEFAULT_CONFIG, config_file, indent=4)

is_executable() ¤

Check if the application is an prebuilt executable. And has been launched with double click.

Returns¤
  • True if the application is an prebuilt executable, False otherwise.
Source code in spotdl/utils/console.py
35
36
37
38
39
40
41
42
43
44
def is_executable():
    """
    Check if the application is an prebuilt executable.
    And has been launched with double click.

    ### Returns
    - `True` if the application is an prebuilt executable, `False` otherwise.
    """

    return is_frozen() and len(sys.argv) == 1

is_frozen() ¤

Check if the application is frozen.

Returns¤
  • True if the application is frozen, False otherwise.
Source code in spotdl/utils/console.py
24
25
26
27
28
29
30
31
32
def is_frozen():
    """
    Check if the application is frozen.

    ### Returns
    - `True` if the application is frozen, `False` otherwise.
    """

    return getattr(sys, "frozen", False)