Save file names using a custom format specifiers (#205)

* Use custom formats to generate file name

* Do not mess up search term

* Fix tests

* Fix conflicting names

* Fix subprocess call on file paths with spaces

* Create directories and keep spaces as defaults

* Fix config merge

* Remove underscores from default file format

* Remove debug info

* Show possible formats in usage help
This commit is contained in:
Ritiek Malhotra
2018-01-19 13:58:27 +05:30
committed by GitHub
parent ed235610ad
commit fcfebc55e6
11 changed files with 145 additions and 95 deletions

View File

@@ -69,7 +69,8 @@ def generate_youtube_url(raw_song, meta_tags, tries_remaining=5):
song = raw_song
query['q'] = song
else:
song = internals.generate_songname(meta_tags)
song = '{0} - {1}'.format(meta_tags['artists'][0]['name'],
meta_tags['name'])
query['q'] = song
log.debug('query: {0}'.format(query))
@@ -123,7 +124,7 @@ def generate_youtube_url(raw_song, meta_tags, tries_remaining=5):
the duration_tolerance has reached the max_duration_tolerance
'''
while len(possible_videos_by_duration) == 0:
possible_videos_by_duration = list(filter(lambda x: abs(x['seconds'] - (int(meta_tags['duration_ms'])/1000)) <= duration_tolerance, videos))
possible_videos_by_duration = list(filter(lambda x: abs(x['seconds'] - meta_tags['duration']) <= duration_tolerance, videos))
duration_tolerance += 1
if duration_tolerance > max_duration_tolerance:
log.error("{0} by {1} was not found.\n".format(meta_tags['name'], meta_tags['artists'][0]['name']))