|
|
@ -3,8 +3,6 @@ from couchpotato.core.helpers.encoding import simplifyString, toUnicode, ss |
|
|
|
from couchpotato.core.helpers.variable import md5 |
|
|
|
from couchpotato.core.logger import CPLog |
|
|
|
from couchpotato.core.providers.info.base import MovieProvider |
|
|
|
from couchpotato.environment import Env |
|
|
|
import os |
|
|
|
import tmdb3 |
|
|
|
import traceback |
|
|
|
|
|
|
@ -20,7 +18,7 @@ class TheMovieDb(MovieProvider): |
|
|
|
|
|
|
|
# Configure TMDB settings |
|
|
|
tmdb3.set_key(self.conf('api_key')) |
|
|
|
tmdb3.set_cache(engine='file', filename=os.path.join(Env.get('cache_dir'), 'python', 'tmdb.cache')) |
|
|
|
tmdb3.set_cache('null') |
|
|
|
|
|
|
|
def search(self, q, limit = 12): |
|
|
|
""" Find movie by name """ |
|
|
@ -76,7 +74,7 @@ class TheMovieDb(MovieProvider): |
|
|
|
log.debug('Getting info: %s', cache_key) |
|
|
|
movie = tmdb3.Movie(identifier) |
|
|
|
result = self.parseMovie(movie) |
|
|
|
self.setCache(cache_key, result) |
|
|
|
self.setCache(md5(ss(cache_key)), result) |
|
|
|
except: |
|
|
|
pass |
|
|
|
|
|
|
@ -84,6 +82,11 @@ class TheMovieDb(MovieProvider): |
|
|
|
|
|
|
|
def parseMovie(self, movie, with_titles = True): |
|
|
|
|
|
|
|
cache_key = 'tmdb.cache.%s' % movie.id |
|
|
|
movie_data = self.getCache(cache_key) |
|
|
|
|
|
|
|
if not movie_data: |
|
|
|
|
|
|
|
# Images |
|
|
|
poster = self.getImage(movie, type = 'poster', size = 'poster') |
|
|
|
poster_original = self.getImage(movie, type = 'poster', size = 'original') |
|
|
@ -131,6 +134,9 @@ class TheMovieDb(MovieProvider): |
|
|
|
|
|
|
|
movie_data['titles'] = list(set(movie_data['titles'])) |
|
|
|
|
|
|
|
# Cache movie parsed |
|
|
|
self.setCache(md5(ss(cache_key)), movie_data) |
|
|
|
|
|
|
|
return movie_data |
|
|
|
|
|
|
|
def getImage(self, movie, type = 'poster', size = 'poster'): |
|
|
|