def FILEtoIMDB( file_name ): #Added function by nctiggy. This executes if the nzb does not have the IMDB id appended to the name #This does capture all of the movies info not just the IMDB id #Future can eliminate the calls to IMDB to use this data instead perhaps print "CouchPotatoServer did not append the IMDB id to the nzb, guessing instead" api_key = "45e408d2851e968e6e4d0353ce621c66" # You need to get this key from themoviedb.org # Guessing at the name of the movie using the filename movie_info = guessit.guess_movie_info(file_name) #configuring tmdb to use the supplied api key tmdb.configure(api_key) print "Guessed movie title as: %s" % (movie_info["title"]) #Creating a collection of movies from tmdb for the guess movie title movies = tmdb.Movies(movie_info["title"]) #parse through all movies found for movie in movies.iter_results(): #Identify the first movie in the collection that matches exactly the movie title if movie["title"].lower() == movie_info["title"].lower(): print "Matched movie title as: %s %s" % (movie["title"], movie["release_date"]) movie = tmdb.Movie(movie["id"]) break #return the imdb id of the movie identified return movie.get_imdb_id()[2:]
def compare(self, element, terms): if element.type != "Movie": log.info("i only work for Movies, i got a %s" % element.type) return terms tmdb_id = element.getIdentifier('tmdb') if not tmdb_id: log.info("no tmdb_id found for %s" % element) movies = tmdb.Movies(element.name, limit=True) for tmdb_movie in movies: movie = tmdb_movie break else: movie = tmdb.Movie(tmdb_id) if not movie: log.info("no movie found in themoviedb for %s" % element) return terms alts = movie.get_alternative_titles() for alternative in alts: langconfig = self.c.getConfig("title_language_%s" % alternative['lang'].lower()) if langconfig: if langconfig.value: terms.append(alternative['title']) return terms
def getElement(self, id, element=None): """we like tmdb ids""" mediaType = MediaType.get(MediaType.identifier == 'de.lad1337.movies') mtm = common.PM.getMediaTypeManager('de.lad1337.movies')[0] fakeRoot = mtm.getFakeRoot('tmdb ID: %s' % id) tmdbMovie = tmdb.Movie(id) self._createMovie(fakeRoot, mediaType, tmdbMovie) for ele in fakeRoot.decendants: # print ele, ele.getField('id', self.tag) if str(ele.getField('id', self.tag)) == str(id): return ele else: return False
def movie_details(movie_id): """ Fetch the details for a given movie id. This will prefer the cache, if its not in the cache tmdb is queried, which takes mutch more time. In that case it also donwloads all the relevant images, poster / backdrop / ... . You should run warm_cache() in a batch job beforhand if you can anticipate which movies will probably be queried for. """ r = movies.find_one({'_id': movie_id}) if r: print "cachte hit for movie details " + r['value']['title'] return r['value'] else: m = __movie_to_dict(tmdb.Movie(movie_id)) movies.insert({'_id': movie_id, 'value': m}) return m
def tmdb_get_meta(movie_id): import urllib if not g_tmdb: tmdb_init() tmdb_movie = tmdb.Movie(movie_id) meta = { 'title': tmdb_movie.get_title(), 'date': tmdb_movie.get_release_date(), 'description': tmdb_movie.get_overview(), } # get poster p_fd = urllib.urlopen(tmdb_movie.get_poster()) meta['cover'] = p_fd.read() p_fd.close() # get genres meta['genre'] = [] tmdb_genres = tmdb_movie.get_genres() for gdict in tmdb_genres: meta['genre'].append(gdict['name']) return meta
def _movie(self, id): movie = tmdb.Movie(id) body = movie.movies cast = movie.casts # print str(body) res = { 'icon': None, 'thumbnail': None, 'properties': { 'fanart_image': None, }, 'info': { 'count': int(id) } } timeout = True if not body: return timeout, res # год if body.get('release_date'): res['info']['year'] = int(body.get('release_date').split('-')[0]) # постер if body.get('poster_path'): res['icon'] = u'http://image.tmdb.org/t/p/original' + body.get( 'poster_path') res['thumbnail'] = u'http://image.tmdb.org/t/p/original' + body.get( 'poster_path') # фанарт if body.get('backdrop_path'): res['properties'][ 'fanart_image'] = u'http://image.tmdb.org/t/p/original' + body.get( 'backdrop_path') for tag, retag, typeof, targettype in ( ('plot', 'overview', None, None), ('title', 'title', None, None), ('originaltitle', 'original_title', None, None), ('tagline', 'tagline', None, None), ('premiered', 'release_date', None, None), ('code', 'imdb_id', None, None), ('studio', 'production_companies', list, unicode), ('runtime', 'runtime', int, unicode), ('votes', 'vote_count', int, unicode), ('rating', 'vote_average', float, None), ('genre', 'genres', list, unicode), ): r = body.get(retag) if r: if typeof == float: res['info'][tag] = float(r) elif typeof == list: if targettype == unicode: res['info'][tag] = u', '.join( [x for x in [x.get('name') for x in r] if x]) else: res['info'][tag] = [ x for x in [x.get('name') for x in r] if x ] elif typeof == int: if targettype == unicode: res['info'][tag] = unicode(r) else: res['info'][tag] = int(r) else: res['info'][tag] = r if cast and cast.get('cast'): info_cast, info_castandrole = [], [] for role_dict in cast.get('cast'): if role_dict.get('name') and role_dict.get('character'): role = role_dict['name'] + u'|' + role_dict['character'] info_cast.append(role_dict['name']) info_castandrole.append(role) res['info']['cast'] = info_cast res['info']['castandrole'] = info_castandrole if cast and cast.get('crew'): for role_dict in cast.get('crew'): if role_dict.get('name') and role_dict.get('job'): if role_dict.get('job') == 'Director': tag = 'director' elif role_dict.get('job') in ['Author', 'Story']: tag = 'writer' else: continue if tag in res['info']: res['info'][tag] = res['info'][ tag] + u', ' + role_dict.get('name') else: res['info'][tag] = role_dict.get('name') timeout = True # если фильм свежий, то кладем в кэш НЕ на долго (могут быть обновления на сайте) if 'year' not in res['info'] or not res['properties']['fanart_image'] \ or int(res['info']['year']) > time.gmtime(time.time()).tm_year: timeout = 7 * 24 * 60 * 60 * 4 #4 week return timeout, res
def setUp(self): tmdb.configure("3e7807c4a01f18298f64662b257d7059") self.movie = tmdb.Movie(24428)
j.append(t[i]['id']) except: print "ERROR %s" % i for i in j: try: print tv.show.summary(i)['title'] except: print i #### # tmdb # To install: pip install git+https://github.com/doganaydin/themoviedb.git fuzzywuzzy #### import tmdb tmdb.configure(api - key) movies = tmdb.Movies('Simpson') movies = tmdb.Movies('fantozzi') a = movies.get_best_match() m = tmdb.Movie(a[1]['id']) for m in movies.iter_results(): print m['title'].encode('utf-8') ##### # Mutagen ##### from mutagen.easyid3 import EasyID3 a = EasyID3( '/Volumes/Macintosh HD/andrea/JdownloaderScaricati/Violetta (2012)/08 Are you ready for the ride.mp3' ) print a