From c27d8d8d947d6cc9ab7484d77c6852cef97c5bd1 Mon Sep 17 00:00:00 2001 From: kepoorhampond Date: Fri, 13 Oct 2017 23:03:32 -0700 Subject: [PATCH] Fixed getting stuck in an infinite loop while searching for yt link --- irs/ripper.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/irs/ripper.py b/irs/ripper.py index a369efb..8aa480b 100644 --- a/irs/ripper.py +++ b/irs/ripper.py @@ -174,7 +174,7 @@ init, or in method arguments.") results = list(filter(None, map(find_link, soup.find_all("a")))) garbage_phrases = "cover album live clean rare version full full \ -album row at @ session".split(" ") +album row at @ session how to npr music reimagined hr version".split(" ") self.code = None counter = 0 @@ -182,12 +182,15 @@ album row at @ session".split(" ") while self.code is None and counter <= 10: counter += 1 for link in results: - if first == True: + if first == True and tries >= 10: self.code = link break if ObjManip.check_garbage_phrases(garbage_phrases, link["title"], song): continue + if first == True: + self.code = link + break if ObjManip.blank_include(link["title"], song) and \ ObjManip.blank_include(link["title"], artist): self.code = link @@ -217,7 +220,9 @@ album row at @ session".split(" ") song = ObjManip.limit_song_name(song) if self.code is None and first is not True: - if additional_search == "lyrics": + if tries >= 5: + return self.find_yt_url(song, artist, additional_search, caught_by_google, first=True, tries=tries + 1) + elif additional_search == "lyrics": return self.find_yt_url(song, artist, additional_search, caught_by_google, first, tries=tries + 1) try: