How to use the spotdl.convert.song 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_download_with_metadata.py View on Github external
def test_convert_from_webm_to_mp3(self, filename_fixture, monkeypatch):
        expect_command = "ffmpeg -y -nostdin -hide_banner -nostats -v panic -i {0}.webm -codec:a libmp3lame -ar 44100 -b:a 192k -vn {0}.mp3".format(
            os.path.join(const.args.folder, filename_fixture)
        )
        monkeypatch.setattr("os.remove", lambda x: None)
        _, command = convert.song(
            filename_fixture + ".webm", filename_fixture + ".mp3", const.args.folder
        )
        assert " ".join(command) == expect_command
github ritiek / spotify-downloader / test / test_with_metadata.py View on Github external
def test_convert_from_webm_to_m4a(self):
        expect_return_code = 0
        return_code = convert.song(
            file_name + ".webm", file_name + ".m4a", const.args.folder
        )
        assert return_code == expect_return_code
github ritiek / spotify-downloader / test / test_with_metadata.py View on Github external
def test_convert_from_m4a_to_mp3(self):
        expect_return_code = 0
        return_code = convert.song(
            file_name + ".m4a", file_name + ".mp3", const.args.folder
        )
        assert return_code == expect_return_code
github ritiek / spotify-downloader / test / test_with_metadata.py View on Github external
def test_convert_from_m4a_to_flac(self):
        expect_return_code = 0
        return_code = convert.song(
            file_name + ".m4a", file_name + ".flac", const.args.folder
        )
        assert return_code == expect_return_code
github ritiek / spotify-downloader / test / test_with_metadata.py View on Github external
def test_convert_from_m4a_to_mp3(self):
        expect_return_code = 0
        return_code = convert.song(
            file_name + ".m4a", file_name + ".mp3", const.args.folder, avconv=True
        )
        assert return_code == expect_return_code
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):
        expect_command = "ffmpeg -y -nostdin -hide_banner -nostats -v panic -i {0}.m4a -codec:v copy -codec:a libmp3lame -ar 44100 -b:a 192k -vn {0}.mp3".format(
            os.path.join(const.args.folder, filename_fixture)
        )
        monkeypatch.setattr("os.remove", lambda x: None)
        _, command = convert.song(
            filename_fixture + ".m4a", filename_fixture + ".mp3", const.args.folder
        )
        assert " ".join(command) == expect_command
github ritiek / spotify-downloader / test / test_with_metadata.py View on Github external
def test_convert_from_webm_to_mp3(self):
        expect_return_code = 0
        return_code = convert.song(
            file_name + ".webm", file_name + ".mp3", const.args.folder
        )
        assert return_code == expect_return_code
github ritiek / spotify-downloader / spotdl / downloader.py View on Github external
def _download_single(self, songname):
        # deal with file formats containing slashes to non-existent directories
        songpath = os.path.join(const.args.folder, os.path.dirname(songname))
        os.makedirs(songpath, exist_ok=True)
        input_song = songname + const.args.input_ext
        output_song = songname + const.args.output_ext
        if youtube_tools.download_song(input_song, self.content):
            print("")
            try:
                convert.song(
                    input_song,
                    output_song,
                    const.args.folder,
                    avconv=const.args.avconv,
                    trim_silence=const.args.trim_silence,
                    delete_original=not const.args.no_remove_original,
                )
            except FileNotFoundError:
                encoder = "avconv" if const.args.avconv else "ffmpeg"
                log.warning("Could not find {0}, skip encoding".format(encoder))
                output_song = self.unconverted_filename(songname)

            if not const.args.no_metadata and self.meta_tags is not None:
                metadata.embed(
                    os.path.join(const.args.folder, output_song), self.meta_tags
                )