How to use the spotdl.youtube_tools.generate_m3u function in spotdl

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 / spotdl / spotdl.py View on Github external
def match_args():
    if const.args.song:
        for track in const.args.song:
            track_dl = downloader.Downloader(raw_song=track)
            track_dl.download_single()
    elif const.args.list:
        if const.args.write_m3u:
            youtube_tools.generate_m3u(track_file=const.args.list)
        else:
            list_dl = downloader.ListDownloader(
                tracks_file=const.args.list,
                skip_file=const.args.skip,
                write_successful_file=const.args.write_successful,
            )
            list_dl.download_list()
    elif const.args.playlist:
        spotify_tools.write_playlist(playlist_url=const.args.playlist)
    elif const.args.album:
        spotify_tools.write_album(album_url=const.args.album)
    elif const.args.all_albums:
        spotify_tools.write_all_albums_from_artist(artist_url=const.args.all_albums)
    elif const.args.username:
        spotify_tools.write_user_playlist(username=const.args.username)
github ritiek / spotify-downloader / spotdl / spotdl.py View on Github external
def match_args():
    if const.args.song:
        for track in const.args.song:
            track_dl = downloader.Downloader(raw_song=track)
            track_dl.download_single()
    elif const.args.list:
        if const.args.write_m3u:
            youtube_tools.generate_m3u(track_file=const.args.list,
                                       text_file=const.args.write_to)
        else:
            list_dl = downloader.ListDownloader(
                tracks_file=const.args.list,
                skip_file=const.args.skip,
                write_successful_file=const.args.write_successful,
            )
            list_dl.download_list()
    elif const.args.playlist:
        spotify_tools.write_playlist(playlist_url=const.args.playlist,
                                     text_file=const.args.write_to)
    elif const.args.album:
        spotify_tools.write_album(album_url=const.args.album,
                                  text_file=const.args.write_to)
    elif const.args.all_albums:
        spotify_tools.write_all_albums_from_artist(artist_url=const.args.all_albums,