Skip to content

Commit

Permalink
FilmtipsetInserter: Introduce guard when no movies where found
Browse files Browse the repository at this point in the history
  • Loading branch information
StegSchreck committed Oct 17, 2020
1 parent 003a710 commit 23e7767
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions RatS/filmtipset/filmtipset_ratings_inserter.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ def _check_movie_details(self, movie):
return True

def _compare_external_links(self, movie):
movie_detail_page = BeautifulSoup(self.site.browser.page_source, 'html.parser')
parsed_imdb_id = movie_detail_page.find_all('span', class_='postmeta')[3].find('a')['href'].split('/')[-1]
normalized_parsed_imdb_id = self.normalize_imdb_id(parsed_imdb_id)
return normalized_parsed_imdb_id == self.normalize_imdb_id(movie['imdb']['id'])
try:
movie_detail_page = BeautifulSoup(self.site.browser.page_source, 'html.parser')
parsed_imdb_id = movie_detail_page.find_all('span', class_='postmeta')[3].find('a')['href'].split('/')[-1]
normalized_parsed_imdb_id = self.normalize_imdb_id(parsed_imdb_id)
return normalized_parsed_imdb_id == self.normalize_imdb_id(movie['imdb']['id'])
except IndexError:
return True

@staticmethod
def normalize_imdb_id(imdb_id):
Expand Down

0 comments on commit 23e7767

Please sign in to comment.