def get_movie(self, id): params = [('partner', self.PARTNER_KEY), ('code', id), ('profile', 'large'), ('mediafmt', 'mp4-lc'), ('filter', 'movie'), ('striptags', 'synopsis,synopsisshort'), ('format', 'json')] res = self.__do_request('movie', params) if res is not None: jres = json.loads(res) if 'movie' in jres: jres = jres['movie'] else: return None else: return None title = NotAvailable duration = NotAvailable release_date = NotAvailable pitch = NotAvailable country = NotAvailable note = NotAvailable short_description = NotAvailable thumbnail_url = NotAvailable other_titles = [] genres = [] roles = {} if 'originalTitle' not in jres: return title = unicode(jres['originalTitle'].strip()) if 'poster' in jres: thumbnail_url = unicode(jres['poster']['href']) if 'genre' in jres: for g in jres['genre']: genres.append(g['$']) if 'runtime' in jres: nbsecs = jres['runtime'] duration = nbsecs / 60 if 'release' in jres: dstr = str(jres['release']['releaseDate']) tdate = dstr.split('-') day = 1 month = 1 year = 1901 if len(tdate) > 2: year = int(tdate[0]) month = int(tdate[1]) day = int(tdate[2]) release_date = datetime(year, month, day) if 'nationality' in jres: country = u'' for c in jres['nationality']: country += '%s, ' % c['$'] country = country.strip(', ') if 'synopsis' in jres: pitch = unicode(jres['synopsis']) if 'statistics' in jres and 'userRating' in jres['statistics']: note = u'%s/10 (%s votes)' % (jres['statistics']['userRating'], jres['statistics']['userReviewCount']) if 'castMember' in jres: for cast in jres['castMember']: if cast['activity']['$'] not in roles: roles[cast['activity']['$']] = [] roles[cast['activity']['$']].append(cast['person']['name']) movie = Movie(id, title) movie.other_titles = other_titles movie.release_date = release_date movie.duration = duration movie.genres = genres movie.pitch = pitch movie.country = country movie.note = note movie.roles = roles movie.short_description = short_description movie.all_release_dates = NotLoaded movie.thumbnail_url = thumbnail_url return movie
def get_movie(self, id): res = self.open( 'http://www.omdbapi.com/?apikey=b7c56eb5&i=%s&plot=full' % id) if res is not None: jres = res.json() else: return None htmlparser = HTMLParser() title = NotAvailable duration = NotAvailable release_date = NotAvailable pitch = NotAvailable country = NotAvailable note = NotAvailable short_description = NotAvailable thumbnail_url = NotAvailable other_titles = [] genres = [] roles = {} if 'Title' not in jres: return title = htmlparser.unescape(unicode(jres['Title'].strip())) if 'Poster' in jres: thumbnail_url = unicode(jres['Poster']) if 'Director' in jres: short_description = unicode(jres['Director']) if 'Genre' in jres: for g in jres['Genre'].split(', '): genres.append(g) if 'Runtime' in jres: m = re.search('(\d+?) min', jres['Runtime']) if m: duration = int(m.group(1)) if 'Released' in jres: released_string = str(jres['Released']) if released_string == 'N/A': release_date = NotAvailable else: months = { 'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06', 'Jul': '07', 'Aug': '08', 'Sep': '09', 'Oct': '10', 'Nov': '11', 'Dec': '12', } for st in months: released_string = released_string.replace(st, months[st]) release_date = datetime.strptime(released_string, '%d %m %Y') if 'Country' in jres: country = u'' for c in jres['Country'].split(', '): country += '%s, ' % c country = country[:-2] if 'Plot' in jres: pitch = unicode(jres['Plot']) if 'imdbRating' in jres and 'imdbVotes' in jres: note = u'%s/10 (%s votes)' % (jres['imdbRating'], jres['imdbVotes']) for r in ['Actors', 'Director', 'Writer']: if '%s' % r in jres.keys(): roles['%s' % r] = [('N/A', e) for e in jres['%s' % r].split(', ')] movie = Movie(id, title) movie.other_titles = other_titles movie.release_date = release_date movie.duration = duration movie.genres = genres movie.pitch = pitch movie.country = country movie.note = note movie.roles = roles movie.short_description = short_description movie.all_release_dates = NotLoaded movie.thumbnail_url = thumbnail_url return movie
def get_movie(self, id): res = self.readurl( 'http://imdbapi.org/?id=%s&type=json&plot=simple&episode=1&lang=en-US&aka=full&release=simple&business=0&tech=0' % id) if res is not None: jres = json.loads(res) else: return None htmlparser = HTMLParser() title = NotAvailable duration = NotAvailable release_date = NotAvailable pitch = NotAvailable country = NotAvailable note = NotAvailable short_description = NotAvailable thumbnail_url = NotAvailable other_titles = [] genres = [] roles = {} if 'title' not in jres: return title = htmlparser.unescape(unicode(jres['title'].strip())) if 'poster' in jres: thumbnail_url = unicode(jres['poster']) if 'directors' in jres: short_description = unicode(', '.join(jres['directors'])) if 'genres' in jres: for g in jres['genres']: genres.append(g) if 'runtime' in jres: dur_str = jres['runtime'][0].split(':') if len(dur_str) == 1: duration = int(dur_str[0].split()[0]) else: duration = int(dur_str[1].split()[0]) if 'also_known_as' in jres: for other_t in jres['also_known_as']: if 'country' in other_t and 'title' in other_t: other_titles.append('%s : %s' % (other_t['country'], htmlparser.unescape(other_t['title']))) if 'release_date' in jres: dstr = str(jres['release_date']) year = int(dstr[:4]) if year == 0: year = 1 month = int(dstr[4:5]) if month == 0: month = 1 day = int(dstr[-2:]) if day == 0: day = 1 release_date = datetime(year, month, day) if 'country' in jres: country = u'' for c in jres['country']: country += '%s, ' % c country = country[:-2] if 'plot_simple' in jres: pitch = unicode(jres['plot_simple']) if 'rating' in jres and 'rating_count' in jres: note = u'%s/10 (%s votes)' % (jres['rating'], jres['rating_count']) for r in ['actor', 'director', 'writer']: if '%ss' % r in jres: roles['%s' % r] = list(jres['%ss' % r]) movie = Movie(id, title) movie.other_titles = other_titles movie.release_date = release_date movie.duration = duration movie.genres = genres movie.pitch = pitch movie.country = country movie.note = note movie.roles = roles movie.short_description = short_description movie.all_release_dates = NotLoaded movie.thumbnail_url = thumbnail_url return movie
def get_movie(self, id): params = [('partner', self.PARTNER_KEY), ('code', id), ('profile', 'large'), ('mediafmt', 'mp4-lc'), ('filter', 'movie'), ('striptags', 'synopsis,synopsisshort'), ('format', 'json')] jres = self.__do_request('movie', params) if jres is not None: if 'movie' in jres: jres = jres['movie'] else: return None else: return None title = NotAvailable duration = NotAvailable release_date = NotAvailable pitch = NotAvailable country = NotAvailable note = NotAvailable short_description = NotAvailable thumbnail_url = NotAvailable other_titles = [] genres = [] roles = {} if 'originalTitle' not in jres: return title = unicode(jres['originalTitle'].strip()) if 'poster' in jres: thumbnail_url = unicode(jres['poster']['href']) if 'genre' in jres: for g in jres['genre']: genres.append(g['$']) if 'runtime' in jres: nbsecs = jres['runtime'] duration = nbsecs / 60 if 'release' in jres: dstr = str(jres['release']['releaseDate']) tdate = dstr.split('-') day = 1 month = 1 year = 1901 if len(tdate) > 2: year = int(tdate[0]) month = int(tdate[1]) day = int(tdate[2]) release_date = datetime(year, month, day) if 'nationality' in jres: country = u'' for c in jres['nationality']: country += '%s, ' % c['$'] country = country.strip(', ') if 'synopsis' in jres: pitch = unicode(jres['synopsis']) if 'statistics' in jres and 'userRating' in jres['statistics']: note = u'%s/5 (%s votes)' % (jres['statistics']['userRating'], jres['statistics']['userReviewCount']) if 'castMember' in jres: for cast in jres['castMember']: if cast['activity']['$'] not in roles: roles[cast['activity']['$']] = [] person_to_append = (u'%s' % cast['person']['code'], cast['person']['name']) roles[cast['activity']['$']].append(person_to_append) movie = Movie(id, title) movie.other_titles = other_titles movie.release_date = release_date movie.duration = duration movie.genres = genres movie.pitch = pitch movie.country = country movie.note = note movie.roles = roles movie.short_description = short_description movie.all_release_dates = NotLoaded movie.thumbnail_url = thumbnail_url return movie
def get_movie(self, id): res = self.open('http://www.omdbapi.com/?apikey=b7c56eb5&i=%s&plot=full' % id) if res is not None: jres = res.json() else: return None htmlparser = HTMLParser() title = NotAvailable duration = NotAvailable release_date = NotAvailable pitch = NotAvailable country = NotAvailable note = NotAvailable short_description = NotAvailable thumbnail_url = NotAvailable other_titles = [] genres = [] roles = {} if 'Title' not in jres: return title = htmlparser.unescape(unicode(jres['Title'].strip())) if 'Poster' in jres: thumbnail_url = unicode(jres['Poster']) if 'Director' in jres: short_description = unicode(jres['Director']) if 'Genre' in jres: for g in jres['Genre'].split(', '): genres.append(g) if 'Runtime' in jres: m = re.search('(\d+?) min', jres['Runtime']) if m: duration = int(m.group(1)) if 'Released' in jres: released_string = str(jres['Released']) if released_string == 'N/A': release_date = NotAvailable else: months = { 'Jan':'01', 'Feb':'02', 'Mar':'03', 'Apr':'04', 'May':'05', 'Jun':'06', 'Jul':'07', 'Aug':'08', 'Sep':'09', 'Oct':'10', 'Nov':'11', 'Dec':'12', } for st in months: released_string = released_string.replace(st,months[st]) release_date = datetime.strptime(released_string, '%d %m %Y') if 'Country' in jres: country = u'' for c in jres['Country'].split(', '): country += '%s, ' % c country = country[:-2] if 'Plot' in jres: pitch = unicode(jres['Plot']) if 'imdbRating' in jres and 'imdbVotes' in jres: note = u'%s/10 (%s votes)' % (jres['imdbRating'], jres['imdbVotes']) for r in ['Actors', 'Director', 'Writer']: if '%s' % r in jres.keys(): roles['%s' % r] = [('N/A',e) for e in jres['%s' % r].split(', ')] movie = Movie(id, title) movie.other_titles = other_titles movie.release_date = release_date movie.duration = duration movie.genres = genres movie.pitch = pitch movie.country = country movie.note = note movie.roles = roles movie.short_description = short_description movie.all_release_dates = NotLoaded movie.thumbnail_url = thumbnail_url return movie
def get_movie(self, id): res = self.readurl( 'http://api.allocine.fr/rest/v3/movie?partner=YW5kcm9pZC12M3M&code=%s&profile=large&mediafmt=mp4-lc&format=json&filter=movie&striptags=synopsis,synopsisshort' % id) if res is not None: jres = json.loads(res) if 'movie' in jres: jres = jres['movie'] else: return None else: return None title = NotAvailable duration = NotAvailable release_date = NotAvailable pitch = NotAvailable country = NotAvailable note = NotAvailable short_description = NotAvailable thumbnail_url = NotAvailable other_titles = [] genres = [] roles = {} if 'originalTitle' not in jres: return title = unicode(jres['originalTitle'].strip()) if 'poster' in jres: thumbnail_url = unicode(jres['poster']['href']) if 'genre' in jres: for g in jres['genre']: genres.append(g['$']) if 'runtime' in jres: nbsecs = jres['runtime'] duration = nbsecs / 60 if 'release' in jres: dstr = str(jres['release']['releaseDate']) tdate = dstr.split('-') day = 1 month = 1 year = 1901 if len(tdate) > 2: year = int(tdate[0]) month = int(tdate[1]) day = int(tdate[2]) release_date = datetime(year, month, day) if 'nationality' in jres: country = u'' for c in jres['nationality']: country += '%s, ' % c['$'] country = country.strip(', ') if 'synopsis' in jres: pitch = unicode(jres['synopsis']) if 'statistics' in jres and 'userRating' in jres['statistics']: note = u'%s/10 (%s votes)' % ( jres['statistics']['userRating'], jres['statistics']['userReviewCount']) if 'castMember' in jres: for cast in jres['castMember']: if cast['activity']['$'] not in roles: roles[cast['activity']['$']] = [] roles[cast['activity']['$']].append(cast['person']['name']) movie = Movie(id, title) movie.other_titles = other_titles movie.release_date = release_date movie.duration = duration movie.genres = genres movie.pitch = pitch movie.country = country movie.note = note movie.roles = roles movie.short_description = short_description movie.all_release_dates = NotLoaded movie.thumbnail_url = thumbnail_url return movie
def get_movie(self, id): res = self.readurl('http://www.omdbapi.com/?i=%s&plot=full' % id) if res is not None: jres = json.loads(res) else: return None htmlparser = HTMLParser() title = NotAvailable duration = NotAvailable release_date = NotAvailable pitch = NotAvailable country = NotAvailable note = NotAvailable short_description = NotAvailable thumbnail_url = NotAvailable other_titles = [] genres = [] roles = {} if 'Title' not in jres: return title = htmlparser.unescape(unicode(jres['Title'].strip())) if 'Poster' in jres: thumbnail_url = unicode(jres['Poster']) if 'Director' in jres: short_description = unicode(jres['Director']) if 'Genre' in jres: for g in jres['Genre'].split(', '): genres.append(g) if 'Runtime' in jres: m = re.search('(\d+?) min', jres['Runtime']) if m: duration = int(m.group(1)) if 'Released' in jres: release_date = datetime.strptime(str(jres['Released']), '%d %b %Y') if 'Country' in jres: country = u'' for c in jres['Country'].split(', '): country += '%s, ' % c country = country[:-2] if 'Plot' in jres: pitch = unicode(jres['Plot']) if 'imdbRating' in jres and 'imdbVotes' in jres: note = u'%s/10 (%s votes)' % (jres['imdbRating'], jres['imdbVotes']) for r in ['Actors', 'Director', 'Writer']: if '%s' % r in jres.keys(): roles['%s' % r] = jres['%s' % r].split(', ') movie = Movie(id, title) movie.other_titles = other_titles movie.release_date = release_date movie.duration = duration movie.genres = genres movie.pitch = pitch movie.country = country movie.note = note movie.roles = roles movie.short_description = short_description movie.all_release_dates = NotLoaded movie.thumbnail_url = thumbnail_url return movie
def get_movie(self, id): params = [ ("partner", self.PARTNER_KEY), ("code", id), ("profile", "large"), ("mediafmt", "mp4-lc"), ("filter", "movie"), ("striptags", "synopsis,synopsisshort"), ("format", "json"), ] res = self.__do_request("movie", params) if res is not None: jres = json.loads(res) if "movie" in jres: jres = jres["movie"] else: return None else: return None title = NotAvailable duration = NotAvailable release_date = NotAvailable pitch = NotAvailable country = NotAvailable note = NotAvailable short_description = NotAvailable thumbnail_url = NotAvailable other_titles = [] genres = [] roles = {} if "originalTitle" not in jres: return title = unicode(jres["originalTitle"].strip()) if "poster" in jres: thumbnail_url = unicode(jres["poster"]["href"]) if "genre" in jres: for g in jres["genre"]: genres.append(g["$"]) if "runtime" in jres: nbsecs = jres["runtime"] duration = nbsecs / 60 if "release" in jres: dstr = str(jres["release"]["releaseDate"]) tdate = dstr.split("-") day = 1 month = 1 year = 1901 if len(tdate) > 2: year = int(tdate[0]) month = int(tdate[1]) day = int(tdate[2]) release_date = datetime(year, month, day) if "nationality" in jres: country = u"" for c in jres["nationality"]: country += "%s, " % c["$"] country = country.strip(", ") if "synopsis" in jres: pitch = unicode(jres["synopsis"]) if "statistics" in jres and "userRating" in jres["statistics"]: note = u"%s/10 (%s votes)" % (jres["statistics"]["userRating"], jres["statistics"]["userReviewCount"]) if "castMember" in jres: for cast in jres["castMember"]: if cast["activity"]["$"] not in roles: roles[cast["activity"]["$"]] = [] person_to_append = (u"%s" % cast["person"]["code"], cast["person"]["name"]) roles[cast["activity"]["$"]].append(person_to_append) movie = Movie(id, title) movie.other_titles = other_titles movie.release_date = release_date movie.duration = duration movie.genres = genres movie.pitch = pitch movie.country = country movie.note = note movie.roles = roles movie.short_description = short_description movie.all_release_dates = NotLoaded movie.thumbnail_url = thumbnail_url return movie
def get_movie(self, id): res = self.readurl("http://www.omdbapi.com/?i=%s&plot=full" % id) if res is not None: jres = json.loads(res) else: return None htmlparser = HTMLParser() title = NotAvailable duration = NotAvailable release_date = NotAvailable pitch = NotAvailable country = NotAvailable note = NotAvailable short_description = NotAvailable thumbnail_url = NotAvailable other_titles = [] genres = [] roles = {} if "Title" not in jres: return title = htmlparser.unescape(unicode(jres["Title"].strip())) if "Poster" in jres: thumbnail_url = unicode(jres["Poster"]) if "Director" in jres: short_description = unicode(jres["Director"]) if "Genre" in jres: for g in jres["Genre"].split(", "): genres.append(g) if "Runtime" in jres: m = re.search("(\d+?) min", jres["Runtime"]) if m: duration = int(m.group(1)) if "Released" in jres: release_date = datetime.strptime(str(jres["Released"]), "%d %b %Y") if "Country" in jres: country = u"" for c in jres["Country"].split(", "): country += "%s, " % c country = country[:-2] if "Plot" in jres: pitch = unicode(jres["Plot"]) if "imdbRating" in jres and "imdbVotes" in jres: note = u"%s/10 (%s votes)" % (jres["imdbRating"], jres["imdbVotes"]) for r in ["Actors", "Director", "Writer"]: if "%s" % r in jres.keys(): roles["%s" % r] = jres["%s" % r].split(", ") movie = Movie(id, title) movie.other_titles = other_titles movie.release_date = release_date movie.duration = duration movie.genres = genres movie.pitch = pitch movie.country = country movie.note = note movie.roles = roles movie.short_description = short_description movie.all_release_dates = NotLoaded movie.thumbnail_url = thumbnail_url return movie