mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-12-29 13:21:22 +00:00
Increase coverage (#218)
* Monkeypatch fetch user and use pytest.tempdir * Cover spotify_tools.grab_album() * Cover avconv conversion * Cover grab_single() * Reduce code repetition * Move grab_playlist() to spotify_tools.py * Move Spotify specific functions to spotify_tools.py * Refactoring * Return track list from write_tracks() * Fix tests * Cover more cases in generate_youtube_url() * Test for unavailable audio streams * Test for filename without spaces * handle.py 100% coverage * Improve config tests * Speed up tests * Install avconv and libfdk-aac * Some cleaning * FFmpeg with libfdk-aac, libopus * Some refactoring * Convert tmpdir to string * Cover YouTube title when downloading from list * Explicitly cover some internals.py functions
This commit is contained in:
@@ -35,19 +35,21 @@ def get_youtube_title(content, number=None):
|
||||
|
||||
def download_song(file_name, content):
|
||||
""" Download the audio file from YouTube. """
|
||||
if const.args.input_ext in (".webm", ".m4a"):
|
||||
link = content.getbestaudio(preftype=const.args.input_ext[1:])
|
||||
_, 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 = '{0}{1}'.format(os.path.join(const.args.folder, file_name),
|
||||
const.args.input_ext)
|
||||
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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user