TMDB: Check to see if movie exists on TMDB before adding.

pull/105/head
desimaniac 5 years ago
parent 9cef58564f
commit 9dcbe44f90

@ -0,0 +1,29 @@
from helpers import str as misc_str
from misc.log import logger
import requests
log = logger.get_logger(__name__)
def does_movie_exist_on_tmdb(sorted_movie):
try:
movie_title = sorted_movie['movie']['title']
movie_year = str(sorted_movie['movie']['year']) \
if sorted_movie['movie']['year'] else '????'
movie_tmdbid = sorted_movie['movie']['ids']['tmdb']
req = requests.get('https://www.themoviedb.org/movie/%s' % movie_tmdbid)
if req.status_code == 200:
log.debug("\'%s (%s)\' [TMDb ID: %s] exists on TMDb.", movie_title, movie_year, movie_tmdbid)
return True
log.debug("SKIPPING: \'%s (%s)\' [TMDb ID: %s] because it does not exist on TMDb.", movie_title, movie_year,
movie_tmdbid)
return False
except Exception:
log.exception("Exception validating TMDb ID: ")
return False

@ -574,6 +574,7 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen
from helpers import radarr as radarr_helper
from helpers import trakt as trakt_helper
from helpers import rating as rating_helper
from helpers import tmdb as tmdb_helper
added_movies = 0
@ -716,6 +717,10 @@ def movies(list_type, add_limit=0, add_delay=2.5, sort='votes', rating=None, gen
if sorted_movie['movie']['genres'] else 'N/A'
try:
# check if movie exists on TMDb website
if not tmdb_helper.does_movie_exist_on_tmdb(sorted_movie):
continue
# check if genre matches genre supplied via argument
if genre and not misc_helper.allowed_genres(genre, 'movie', sorted_movie):
log.debug("SKIPPING: \'%s (%s)\' because it was not from genre: %s", sorted_movie['movie']['title'],

Loading…
Cancel
Save