How to use the spotdl.const.args.folder 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_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_dry_run.py View on Github external
def test_dry_download_list(tmpdir):
    const.args.folder = str(tmpdir)
    const.args.dry_run = True
    file_path = os.path.join(const.args.folder, "test_list.txt")
    with open(file_path, "w") as f:
        f.write(TRACK_URL)
    list_dl = downloader.ListDownloader(file_path)
    downloaded_song, *_ = list_dl.download_list()
    assert downloaded_song == TRACK_URL
github ritiek / spotify-downloader / test / test_dry_run.py View on Github external
def test_dry_download_list(tmpdir):
    const.args.folder = str(tmpdir)
    const.args.dry_run = True
    file_path = os.path.join(const.args.folder, "test_list.txt")
    with open(file_path, "w") as f:
        f.write(TRACK_URL)
    list_dl = downloader.ListDownloader(file_path)
    downloaded_song, *_ = list_dl.download_list()
    assert downloaded_song == TRACK_URL
github ritiek / spotify-downloader / test / test_with_metadata.py View on Github external
def test_embed_in_mp3(self):
        expect_embed = True
        global track_path
        track_path = os.path.join(const.args.folder, file_name)
        embed = metadata.embed(track_path + ".mp3", meta_tags)
        assert embed == expect_embed
github ritiek / spotify-downloader / test / test_download_with_metadata.py View on Github external
def test_convert_from_m4a_to_mp3(self, filename_fixture, monkeypatch):
        monkeypatch.setattr("os.remove", lambda x: None)
        expect_command = "avconv -loglevel 0 -i {0}.m4a -ab 192k {0}.mp3 -y".format(
            os.path.join(const.args.folder, filename_fixture)
        )
        _, command = convert.song(
            filename_fixture + ".m4a",
            filename_fixture + ".mp3",
            const.args.folder,
            avconv=True,
        )
        assert " ".join(command) == expect_command
github ritiek / spotify-downloader / test / test_download_with_metadata.py View on Github external
def test_convert_from_m4a_to_mp3(self, filename_fixture, monkeypatch):
        monkeypatch.setattr("os.remove", lambda x: None)
        expect_command = "avconv -loglevel 0 -i {0}.m4a -ab 192k {0}.mp3 -y".format(
            os.path.join(const.args.folder, filename_fixture)
        )
        _, command = convert.song(
            filename_fixture + ".m4a",
            filename_fixture + ".mp3",
            const.args.folder,
            avconv=True,
        )
        assert " ".join(command) == expect_command
github ritiek / spotify-downloader / test / test_download_with_metadata.py View on Github external
def trackpath_fixture(filename_fixture):
    trackpath = os.path.join(const.args.folder, filename_fixture)
    return trackpath
github ritiek / spotify-downloader / test / test_download_with_metadata.py View on Github external
def test_check_track_exists_before_download(tmpdir, metadata_fixture, filename_fixture):
    expect_check = False
    const.args.folder = str(tmpdir)
    # prerequisites for determining filename
    track_existence = downloader.CheckExists(filename_fixture, metadata_fixture)
    check = track_existence.already_exists(SPOTIFY_TRACK_URL)
    assert check == expect_check
github ritiek / spotify-downloader / spotdl / youtube_tools.py View on Github external
def download_song(file_name, content):
    """ Download the audio file from YouTube. """
    _, extension = os.path.splitext(file_name)
    if extension in (".webm", ".m4a"):
        link = content.getbestaudio(preftype=extension[1:])
    else:
        log.debug("No audio streams available for {} type".format(extension))
        return False

    if link:
        log.debug("Downloading from URL: " + link.url)
        filepath = os.path.join(const.args.folder, file_name)
        log.debug("Saving to: " + filepath)
        link.download(filepath=filepath)
        return True
    else:
        log.debug("No audio streams available")
        return False
github ritiek / spotify-downloader / spotdl / downloader.py View on Github external
def _force_overwrite_song(self, song):
        os.remove(os.path.join(const.args.folder, song))
        log.info('Overwriting "{}"'.format(song))
        return False