mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Message if audio stream not available on YouTube
This commit is contained in:
@@ -23,6 +23,7 @@ def input_link(links):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
print('Choose a valid number!')
|
print('Choose a valid number!')
|
||||||
|
|
||||||
|
# take input correctly for both python2 & 3
|
||||||
def user_input(string=''):
|
def user_input(string=''):
|
||||||
if sys.version_info > (3, 0):
|
if sys.version_info > (3, 0):
|
||||||
return input(string)
|
return input(string)
|
||||||
|
|||||||
23
spotdl.py
23
spotdl.py
@@ -137,17 +137,22 @@ def feed_playlist(username):
|
|||||||
misc.feed_tracks(file, tracks)
|
misc.feed_tracks(file, tracks)
|
||||||
|
|
||||||
def download_song(content):
|
def download_song(content):
|
||||||
music_file = misc.generate_filename(content.title)
|
|
||||||
if args.input_ext == '.webm':
|
if args.input_ext == '.webm':
|
||||||
# download best available audio in .webm
|
# best available audio in .webm
|
||||||
link = content.getbestaudio(preftype='webm')
|
link = content.getbestaudio(preftype='webm')
|
||||||
if link is not None:
|
elif args.input_ext == '.m4a':
|
||||||
link.download(filepath='Music/' + music_file + args.input_ext)
|
# best available audio in .webm
|
||||||
else:
|
|
||||||
# download best available audio in .webm
|
|
||||||
link = content.getbestaudio(preftype='m4a')
|
link = content.getbestaudio(preftype='m4a')
|
||||||
if link is not None:
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if link is None:
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
music_file = misc.generate_filename(content.title)
|
||||||
|
# download link
|
||||||
link.download(filepath='Music/' + music_file + args.input_ext)
|
link.download(filepath='Music/' + music_file + args.input_ext)
|
||||||
|
return True
|
||||||
|
|
||||||
# convert song from input_ext to output_ext
|
# convert song from input_ext to output_ext
|
||||||
def convert_song(music_file):
|
def convert_song(music_file):
|
||||||
@@ -304,12 +309,14 @@ def grab_single(raw_song, number=None):
|
|||||||
music_file = misc.generate_filename(content.title)
|
music_file = misc.generate_filename(content.title)
|
||||||
music_file = misc.fix_decoding(music_file)
|
music_file = misc.fix_decoding(music_file)
|
||||||
if not check_exists(music_file, raw_song, islist=islist):
|
if not check_exists(music_file, raw_song, islist=islist):
|
||||||
download_song(content)
|
if download_song(content):
|
||||||
print('')
|
print('')
|
||||||
convert_song(music_file)
|
convert_song(music_file)
|
||||||
meta_tags = generate_metadata(raw_song)
|
meta_tags = generate_metadata(raw_song)
|
||||||
if not args.no_metadata:
|
if not args.no_metadata:
|
||||||
metadata.embed(music_file, meta_tags, args.output_ext)
|
metadata.embed(music_file, meta_tags, args.output_ext)
|
||||||
|
else:
|
||||||
|
print('No audio streams available')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user