diff --git a/YouTube.py b/YouTube.py index 47c3d0d..e23630a 100644 --- a/YouTube.py +++ b/YouTube.py @@ -26,7 +26,7 @@ def get_best_fit_song_id(self, results, song): continue durationMatch = None - if res['duration']: + if 'duration' in res and res['duration']: durationItems = res['duration'].split(':') duration = int(durationItems[0]) * 60 + int(durationItems[1]) durationMatch = 1 - abs(duration - song['duration']) * 2 / song['duration']