mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Update youtube_tools.py
This commit is contained in:
@@ -132,13 +132,11 @@ class GenerateYouTubeURL:
|
|||||||
# filter out videos that do not have a similar length to the Spotify song
|
# filter out videos that do not have a similar length to the Spotify song
|
||||||
duration_tolerance = 10
|
duration_tolerance = 10
|
||||||
max_duration_tolerance = 20
|
max_duration_tolerance = 20
|
||||||
possible_videos_by_duration = list()
|
possible_videos_by_duration = []
|
||||||
|
|
||||||
'''
|
# start with a reasonable duration_tolerance, and increment duration_tolerance
|
||||||
start with a reasonable duration_tolerance, and increment duration_tolerance
|
# until one of the Youtube results falls within the correct duration or
|
||||||
until one of the Youtube results falls within the correct duration or
|
# the duration_tolerance has reached the max_duration_tolerance
|
||||||
the duration_tolerance has reached the max_duration_tolerance
|
|
||||||
'''
|
|
||||||
while len(possible_videos_by_duration) == 0:
|
while len(possible_videos_by_duration) == 0:
|
||||||
possible_videos_by_duration = list(filter(lambda x: abs(x['seconds'] - self.meta_tags['duration']) <= duration_tolerance, videos))
|
possible_videos_by_duration = list(filter(lambda x: abs(x['seconds'] - self.meta_tags['duration']) <= duration_tolerance, videos))
|
||||||
duration_tolerance += 1
|
duration_tolerance += 1
|
||||||
@@ -149,7 +147,7 @@ class GenerateYouTubeURL:
|
|||||||
result = possible_videos_by_duration[0]
|
result = possible_videos_by_duration[0]
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
url = "http://youtube.com/watch?v=" + result['link']
|
url = "http://youtube.com/watch?v={0}".format(result['link'])
|
||||||
else:
|
else:
|
||||||
url = None
|
url = None
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user