How to use spotdl - 10 common examples

To help you get started, we’ve selected a few spotdl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ritiek / spotify-downloader / test / test_list.py View on Github external
def test_m3u(tmpdir):
    expect_m3u = (
        "#EXTM3U\n\n"
        "#EXTINF:31,Eminem - 01 - Eminem - Curtains Up (Skit)\n"
        "http://www.youtube.com/watch?v=qk13SFlwG9A\n"
        "#EXTINF:226,Alan Walker - Spectre [NCS Release]\n"
        "http://www.youtube.com/watch?v=AOeY-nDp7hI\n"
    )
    m3u_track_file = os.path.join(str(tmpdir), "m3u_test.txt")
    with open(m3u_track_file, "w") as track_file:
        track_file.write("\nhttps://open.spotify.com/track/2nT5m433s95hvYJH4S7ont")
        track_file.write("\nhttp://www.youtube.com/watch?v=AOeY-nDp7hI")
    youtube_tools.generate_m3u(m3u_track_file)
    m3u_file = "{}.m3u".format(m3u_track_file.split(".")[0])
    with open(m3u_file, "r") as m3u_in:
        m3u = m3u_in.readlines()
    assert "".join(m3u) == expect_m3u
github ritiek / spotify-downloader / test / test_youtube_tools.py View on Github external
youtube_tools.GenerateYouTubeURL,
        "_fetch_response",
        loader.monkeypatch_youtube_search_page,
    )
    expect_m3u = (
        "#EXTM3U\n\n"
        "#EXTINF:208,Janji - Heroes Tonight (feat. Johnning) [NCS Release]\n"
        "http://www.youtube.com/watch?v=3nQNiWdeH2Q\n"
        "#EXTINF:226,Alan Walker - Spectre [NCS Release]\n"
        "http://www.youtube.com/watch?v=AOeY-nDp7hI\n"
    )
    m3u_track_file = os.path.join(str(tmpdir), "m3u_test.txt")
    with open(m3u_track_file, "w") as track_file:
        track_file.write("\nhttps://open.spotify.com/track/3SipFlNddvL0XNZRLXvdZD")
        track_file.write("\nhttp://www.youtube.com/watch?v=AOeY-nDp7hI")
    youtube_tools.generate_m3u(m3u_track_file)
    m3u_file = "{}.m3u".format(m3u_track_file.split(".")[0])
    with open(m3u_file, "r") as m3u_in:
        m3u = m3u_in.readlines()
    assert "".join(m3u) == expect_m3u
github ritiek / spotify-downloader / test / test_youtube_tools.py View on Github external
def test_generate_m3u(tmpdir, monkeypatch):
    monkeypatch.setattr(youtube_tools.GenerateYouTubeURL, "_fetch_response", loader.monkeypatch_youtube_search_page)
    expect_m3u = (
        "#EXTM3U\n\n"
        "#EXTINF:208,Janji - Heroes Tonight (feat. Johnning) [NCS Release]\n"
        "http://www.youtube.com/watch?v=3nQNiWdeH2Q\n"
        "#EXTINF:226,Alan Walker - Spectre [NCS Release]\n"
        "http://www.youtube.com/watch?v=AOeY-nDp7hI\n"
    )
    m3u_track_file = os.path.join(str(tmpdir), "m3u_test.txt")
    with open(m3u_track_file, "w") as track_file:
        track_file.write("\nhttps://open.spotify.com/track/3SipFlNddvL0XNZRLXvdZD")
        track_file.write("\nhttp://www.youtube.com/watch?v=AOeY-nDp7hI")
    youtube_tools.generate_m3u(m3u_track_file)
    m3u_file = "{}.m3u".format(m3u_track_file.split(".")[0])
    with open(m3u_file, "r") as m3u_in:
        m3u = m3u_in.readlines()
    assert "".join(m3u) == expect_m3u
github ritiek / spotify-downloader / test / loader.py View on Github external
def load_defaults():
    const.args = handle.get_arguments(raw_args="", to_group=False, to_merge=False)
    const.args.overwrite = "skip"

    spotdl.args = const.args
    spotdl.log = const.logzero.setup_logger(
        formatter=const._formatter, level=const.args.log_level
    )
github ritiek / spotify-downloader / test / test_youtube_tools.py View on Github external
def test_custom(self):
        const.args.youtube_api_key = EXPECTED_YT_API_KEY_CUSTOM
        youtube_tools.set_api_key()
        key = youtube_tools.pafy.g.api_key
        assert key == EXPECTED_YT_API_KEY_CUSTOM
github ritiek / spotify-downloader / test / test_youtube_tools.py View on Github external
def test_custom(self):
        const.args.youtube_api_key = EXPECTED_YT_API_KEY_CUSTOM
        youtube_tools.set_api_key()
        key = youtube_tools.pafy.g.api_key
        assert key == EXPECTED_YT_API_KEY_CUSTOM
github ritiek / spotify-downloader / test / test_with_metadata.py View on Github external
def test_check_track_exists_before_download(tmpdir):
    expect_check = False
    const.args.folder = str(tmpdir)
    # prerequisites for determining filename
    songname = internals.format_string(const.args.file_format, meta_tags)
    global file_name
    file_name = internals.sanitize_title(songname)
    track_existence = downloader.CheckExists(file_name, meta_tags)
    check = track_existence.already_exists(TRACK_URL)
    assert check == expect_check
github ritiek / spotify-downloader / test / test_youtube_tools.py View on Github external
def test_download_from_list_without_youtube_api(
        self, metadata_fixture, content_fixture
    ):
        const.args.youtube_api_key = None
        youtube_tools.set_api_key()
        content_fixture = youtube_tools.go_pafy(TRACK_SEARCH, metadata_fixture)
        title = youtube_tools.get_youtube_title(content_fixture, 1)
        assert title == "1. {0}".format(EXPECTED_TITLE)
github ritiek / spotify-downloader / test / test_youtube_tools.py View on Github external
def test_custom(self):
        const.args.youtube_api_key = EXPECTED_YT_API_KEY_CUSTOM
        youtube_tools.set_api_key()
        key = youtube_tools.pafy.g.api_key
        assert key == EXPECTED_YT_API_KEY_CUSTOM
github ritiek / spotify-downloader / test / test_youtube_tools.py View on Github external
def test_default(self):
        const.args.youtube_api_key = None
        youtube_tools.set_api_key()
        key = youtube_tools.pafy.g.api_key
        assert key == EXPECTED_YT_API_KEY