def getMovie(query): key = '79f8797f2c2e527e4e396dfe9816a3cd' set_key(key) #Movie url = 'https://api.themoviedb.org/3/search/movie?api_key=' url += key url += '&query=' + query url += '&include_adult=true' payload = "{}" response = requests.request("GET", url, data=payload) json1_data = json.loads(response.text) while (1): try: results = json1_data['results'] break except KeyError: pass if (len(results) == 0): return (0, results) pops = [] results = results[:3] for i in results: i = Movie(i['id']) mx = Movies() mx.set(movie=i) pops.append(mx) return (1, pops)
def movie(request, movieid): m = Movie(movieid) mx = Classes.Movies() mx.set(movie=m) mdict = {} mdict['movie'] = mx return render(request, 'moviestar/movie.html', mdict)
def getRecMov(ID): key = '79f8797f2c2e527e4e396dfe9816a3cd' set_key(key) #Movie url = 'https://api.themoviedb.org/3/movie/' url += str(ID) + '/recommendations?api_key=' url += key payload = "{}" response = requests.request("GET", url, data=payload) json1_data = json.loads(response.text) while (1): try: results = json1_data['results'] break except KeyError: pass results = results[0:2] pops = [] for i in results: m = Movie(i['id']) mx = Movies() mx.set(movie=m) pops.append(mx) return pops
def getNowPlayingMovies(limit = 10, offset = 0): movies = Movie.nowplaying()[offset : offset + limit] movieInfo = [] for movie in movies: movieInfo.append(getMinimalistMovieInfo(movie)) return {'now_playing' : movieInfo}
def movie(request, movieid): m = Movie(movieid) mx = Classes.Movies() mx.set(movie=m) mdict = {} mdict['movie'] = mx mdict['rec'] = recommend.getRecMov(movieid) return render(request, 'moviestar/movie.html', mdict)
def download_images(id): cur = g.db.execute( 'select tmdbid, location, filename from movies where id=? limit 1', [id]) record = cur.fetchone() movie = Movie(record[0]) downloadImages(record[1] + '/' + record[2], movie) return "downloaded images..."
def getUpcomingMovies(limit = 10, offset = 0): movies = Movie.upcoming()[offset : offset + limit] movieInfo = [] for movie in movies: movieInfo.append(getMinimalistMovieInfo(movie)) return {'upcoming' : movieInfo}
def getTopRatedMovies(limit = 10, offset = 0): movies = Movie.toprated()[offset : offset + limit] movieInfo = [] for movie in movies: movieInfo.append(getMinimalistMovieInfo(movie)) return {'top_rated' : movieInfo}
def getMostPopularMovies(limit = 10, offset = 0): movies = Movie.mostpopular()[offset : offset + limit] movieInfo = [] for movie in movies: movieInfo.append(getMinimalistMovieInfo(movie)) return {'most_popular' : movieInfo}
def mostpopular(): movies = Movie.mostpopular() res = movies[0:10] nom = "ruben" ##res = "" ##for m in movies[0:10]: ## res += m.title+'\n' ##return res return render_template('mostpopular.html', title='Most popular', pageActive='movies', movies=res)
def getPopular(): key = '79f8797f2c2e527e4e396dfe9816a3cd' set_key(key) #Movie url = 'https://api.themoviedb.org/3/movie/popular?api_key=' url += key payload = "{}" response = requests.request("GET", url, data=payload) json1_data = json.loads(response.text) while(1): try: results = json1_data['results'] break except KeyError: pass results = results[0:4] pops = [] for i in results: m = Movie(i['id']) mx = Movies() mx.set(movie=m) pops.append(mx) #TV url = 'https://api.themoviedb.org/3/tv/popular?api_key=' url += key payload = "{}" response = requests.request("GET", url, data=payload) json1_data = json.loads(response.text) while(1): try: results = json1_data['results'] break except KeyError: pass results = results[0:4] for i in results: m = Series(i['id']) mx = TV() mx.set(tv = m) pops.append(mx) return pops
def __init__(self, title, title_modifier, trailer_modifier): from tmdb3 import set_key from tmdb3 import set_cache from tmdb3 import searchMovie from tmdb3 import Movie, Collection, Person, Series set_cache('null') set_key('a7b2a24af9fbe91fc6003d4d111b3b37') self.search_results = searchMovie( title ) #self.search_results is a list returned by the searchMovie function after passing in the title variable. self.video_id = self.search_results[ title_modifier].id # to use any of the provided methods from tmdb3 we need to get the movie's ID. self.title = Movie( self.video_id).title # method to return movies title.
def acceptEdit(tmdbid, path, id): filename = os.path.basename(path) location = os.path.dirname(path) mov = Movie(tmdbid) if len(mov.youtube_trailers) is not 0: trailer = mov.youtube_trailers[0].geturl() else: trailer = None if len(str(mov.releasedate)) is not 0: year = mov.releasedate.year else: year = "0000" movieArr = [ mov.id, mov.title, year, mov.tagline, mov.overview, mov.runtime, mov.userrating, mov.homepage, trailer, location, filename, id ] updateDB(movieArr)
def processMovieUpdate(movie): m = movie if 'filename' not in m: return 'Error: Sadly, filename is a required field\n' file = os.path.realpath(m['filename']) title = getBasename(file) if ('movieId' in m): result = Movie(m['movieId']) else: search = searchForMovie(title) if (0 == len(search)): return 'No results found for "' + title + '"' result = search[0] movieStruct = getMovieStruct(result) if True == db.updateMovie(movieStruct): return 'Success importing (' + str(result.id) + ') ' + result.title + '\n' else: return 'Failed importing (' + str(result.id) + ') ' + result.title + '\n'
def __init__(self, title, title_modifier, trailer_modifier): Video.__init__(self, title, title_modifier, trailer_modifier) # was having trouble with inhereting the imported tmbd3 module from class video. So reimported it. from tmdb3 import set_key from tmdb3 import set_cache from tmdb3 import searchMovie from tmdb3 import Movie, Collection, Person, Series set_cache('null') set_key('a7b2a24af9fbe91fc6003d4d111b3b37') self.tagline = Movie( self.video_id ).tagline # returns short 'tagline' description of movie. self.storyline = Movie( self.video_id).overview # returns longer description of movie. self.runtime = Movie(self.video_id).runtime # total runtime in minutes self.poster_image_url = Movie(self.video_id).poster.geturl( ) # returns url of .jpg of the movie poster self.trailer_youtube_url = Movie( self.video_id).youtube_trailers[trailer_modifier].geturl( ) # youtube trailer. self.release_date = Movie(self.video_id).releasedate
for url_amazon in im_url: search = tmdb.Search() response = search.movie(query=title_amazon) for s in search.results: title_match=s['title'] uni_ignore=unicodedata.normalize('NFKD', title_match).encode('ascii','ignore') id=s['id'] Distance=distance.levenshtein(title_amazon,uni_ignore,normalized=True) if(id_amazon!=temp): if(title_match): if(Distance<0.045): p=Movie(id).poster if p is None: url_tmdb='http://www.designsbybethann.com/pictures/Flowers/none%20flowers.jpg' # print url # print (title_amazon,title_match,Distance,id_amazon,id,p) else: url_tmdb=p.geturl() # print url print (title_amazon,title_match,Distance,id_amazon,id,url_tmdb,url_amazon) temp=id_amazon cursor.execute("INSERT INTO public.image3_match1(amazon_id,tmdb_id,amazon_title,tmdb_title,tmdb_image,amazon_image) VALUES (%s,"'%s'",%s, %s,%s,%s)",(id_amazon,id,title_amazon,title_match,url_tmdb,url_amazon)) conn.commit()
def nowplaying(): res = Movie.nowplaying() return render_template('movies.html', title='Now playing | Movies', pageActive='movies', movies=res[0:15])
def mediabrowser_meta(tmdbid, path): import json movie = Movie(tmdbid) mbjson = {} mbjson["adult"] = movie.adult mbjson["budget"] = movie.budget castArr = [] for cast in movie.cast: actor = {} actor["character"] = cast.character actor["id"] = cast.id actor["name"] = cast.name actor["order"] = cast.order castArr.append(actor) mbjson["cast"] = castArr countriesArr = [] for key, value in movie.releases.iteritems(): country = {} country["certification"] = value.certification country["iso_3166_1"] = value.country country["release_date"] = value.releasedate.isoformat() countriesArr.append(country) mbjson["countries"] = countriesArr crewArr = [] for crew in movie.crew: mem = {} mem["department"] = crew.department mem["id"] = crew.id mem["job"] = crew.job mem["name"] = crew.name crewArr.append(mem) mbjson["crew"] = crewArr genreArr = [] for genre in movie.genres: gen = {} gen["id"] = genre.id gen["name"] = genre.name genreArr.append(gen) mbjson["genres"] = genreArr mbjson["homepage"] = movie.homepage mbjson["id"] = movie.id mbjson["imdb_id"] = movie.imdb mbjson["original_title"] = movie.originaltitle mbjson["overview"] = movie.overview mbjson["popularity"] = movie.popularity studiosArr = [] for studio in movie.studios: stdio = {} stdio["id"] = studio.id stdio["name"] = studio.name studiosArr.append(stdio) mbjson["production_companies"] = studiosArr mbjson["release_date"] = movie.releasedate.isoformat() mbjson["revenue"] = movie.revenue mbjson["runtime"] = movie.runtime langs = [] for language in movie.languages: lng = {} lng["iso_639_1"] = language.code lng["name"] = language.name langs.append(lng) mbjson["spoken_languages"] = langs mbjson["tagline"] = movie.tagline mbjson["title"] = movie.title mbjson["vote_average"] = movie.userrating mbjson["vote_count"] = movie.votes if os.path.isfile(path): location = os.path.dirname(path) else: location = path with open(location + '/MBMovie.json', 'w') as outfile: json.dump(mbjson, outfile)
def getGenreList(genresMovie, genresTV): key = '79f8797f2c2e527e4e396dfe9816a3cd' set_key(key) #Movie GenreMovieList = {} for genre in genresMovie: url = 'https://api.themoviedb.org/3/discover/movie?api_key=' extra = '&sort_by=popularity.desc&include_adult=true&with_genres=' url += key genreID = genreNameDict[genre] extra += str(genreID) url += extra payload = "{}" response = requests.request("GET", url, data=payload) json1_data = json.loads(response.text) while (1): try: results = json1_data['results'] break except KeyError: pass movie_list = [] spare = [] for i in results: if (i['genre_ids'][0] == genreID): try: m = Movie(i['id']) mx = Movies() mx.set(movie=m, spGenre=genre) movie_list.append(mx) except: pass else: try: if (i['genre_ids'][1] == genreID): try: m = Movie(i['id']) mx = Movies() mx.set(movie=m, spGenre=genre) movie_list.append(mx) except: pass else: try: m = Movie(i['id']) mx = Movies() mx.set(movie=m, spGenre=genre) spare.append(mx) except: pass except: pass movie_list += spare GenreMovieList[genre] = movie_list #TV GenreTVList = {} for genre in genresTV: url = 'https://api.themoviedb.org/3/discover/tv?api_key=' extra = '&sort_by=popularity.desc&with_genres=' url += key genreID = genreTVNameDict[genre] extra += str(genreID) url += extra payload = "{}" response = requests.request("GET", url, data=payload) json1_data = json.loads(response.text) while (1): try: results = json1_data['results'] break except KeyError: pass tv_list = [] spare = [] for i in results: if (i['genre_ids'][0] == genreID): try: m = Series(i['id']) mx = TV() mx.set(tv=m, spGenre=genre) tv_list.append(mx) except: pass else: try: if (i['genre_ids'][1] == genreID): try: m = Series(i['id']) mx = TV() mx.set(tv=m, spGenre=genre) tv_list.append(mx) except: pass else: try: m = Series(i['id']) mx = TV() mx.set(tv=m, spGenre=genre) spare.append(mx) except: pass except: pass tv_list += spare GenreTVList[genre] = tv_list return GenreMovieList, GenreTVList
j = 0 imdb_real = [] name = [] res = [] movyear = [] genre = [] director = [] descriptions = [] image = [] trailer = [] actor = [] for i in imdbid: try: res.append(Movie.fromIMDB(i)) except Exception as e: continue ''' try: res[j] except Exception as e: del res[-1] continue ''' name.append(res[j].title) tempString = '' for k in range(0, 10): try: tempString += res[j].posters[k].geturl() + '|'
def upcoming(): res = Movie.upcoming() return render_template('movies.html', title='Upcoming | Movies', pageActive='movies', movies=res[0:15])
def mostpopular(): res = Movie.mostpopular() return render_template('movies.html', title='Most popular | Movies', pageActive='movies', movies=res[0:15])
def toprated(): res = Movie.toprated() return render_template('movies.html', title='Top rated | Movies', pageActive='movies', movies=res[0:15])
from tmdb3 import Series try: from .Classes import genreIdDict, genreNameDict, genreTVIdDict, genreTVNameDict except: from Classes import genreIdDict, genreNameDict, genreTVIdDict, genreTVNameDict key = '79f8797f2c2e527e4e396dfe9816a3cd' set_key(key) #Movie url = 'https://api.themoviedb.org/3/movie/popular?api_key=' url += key payload = "{}" response = requests.request("GET", url, data=payload) json1_data = json.loads(response.text) while(1): try: results = json1_data['results'] break except KeyError: pass results = results[0]['id'] results = Movie(results) results = results.id print(results) for i in results: print(i)