Skip to content

downloader

Module for functions related to downloading songs.

check_ytmusic_connection() ¤

Check if we can connect to YouTube Music API

Returns¤
  • True if we can connect to YouTube Music API
  • False if we can't connect to YouTube Music API
Source code in spotdl/utils/downloader.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
def check_ytmusic_connection() -> bool:
    """
    Check if we can connect to YouTube Music API

    ### Returns
    - `True` if we can connect to YouTube Music API
    - `False` if we can't connect to YouTube Music API
    """

    # Check if we are getting results from YouTube Music
    ytm = YouTubeMusic()
    test_results = ytm.get_results("a")
    if len(test_results) == 0:
        return False

    return True