Example #1
0
 def iter_movies(self, role_filter=None):
     for role_div in self.parser.select(self.document.getroot(), 'div.filmo'):
         role = self.parser.select(role_div, 'h5 a', 1).text.replace(':', '')
         if (role_filter is None or (role_filter is not None and role.lower().strip() == role_filter))\
                 and role != 'In Development':
             for a in self.parser.select(role_div, 'ol > li > a'):
                 id = a.attrib.get('href', '').strip('/').split('/')[-1]
                 if id.startswith('tt'):
                     title = unicode(a.text)
                     role_detail = NotAvailable
                     if len(a.tail) > 0:
                         role_detail = unicode(' '.join(a.tail.replace('..', '').split()))
                     movie = Movie(id, title)
                     movie.short_description = role_detail
                     yield movie
Example #2
0
 def iter_movies(self, role_filter=None):
     for role_div in self.doc.xpath(
             '//div[@id="filmography"]/div[has-class("filmo-category-section")]/div'
     ):
         for a in role_div.xpath('.//a'):
             m = re.search('/title/(tt.*)/\?.*', a.attrib.get('href'))
             if m:
                 yield Movie(m.group(1), a.text)
Example #3
0
 def iter_movies(self, role_filter=None):
     for role_div in self.parser.select(
             self.document.getroot(),
             'div#filmography > div.filmo-category-section > div'):
         for a in self.parser.select(role_div, 'a'):
             m = re.search('/title/(tt.*)/\?.*', a.attrib.get('href'))
             if m:
                 yield Movie(m.group(1), a.text)
Example #4
0
 def iter_movies(self, role_filter=None):
     for role_div in self.parser.select(self.document.getroot(),
                                        'div.filmo'):
         role = self.parser.select(role_div, 'h5 a',
                                   1).text.replace(':', '')
         if (role_filter is None or (role_filter is not None and role.lower().strip() == role_filter))\
                 and role != 'In Development':
             for a in self.parser.select(role_div, 'ol > li > a'):
                 id = a.attrib.get('href', '').strip('/').split('/')[-1]
                 if id.startswith('tt'):
                     title = unicode(a.text)
                     role_detail = NotAvailable
                     if len(a.tail) > 0:
                         role_detail = unicode(' '.join(
                             a.tail.replace('..', '').split()))
                     movie = Movie(id, title)
                     movie.short_description = role_detail
                     yield movie
Example #5
0
    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
Example #6
0
 def iter_movies(self, pattern):
     res = self.readurl('http://www.imdb.com/xml/find?json=1&nr=1&tt=on&q=%s' % pattern.encode('utf-8'))
     jres = json.loads(res)
     htmlparser = HTMLParser()
     for cat in ['title_popular', 'title_exact', 'title_approx']:
         if cat in jres:
             for m in jres[cat]:
                 tdesc = unicode(m['title_description'])
                 if '<a' in tdesc and '>' in tdesc:
                     short_description = u'%s %s' % (tdesc.split('<')[
                                                     0].strip(', '), tdesc.split('>')[1].split('<')[0])
                 else:
                     short_description = tdesc.strip(', ')
                 movie = Movie(m['id'], htmlparser.unescape(m['title']))
                 movie.other_titles = NotLoaded
                 movie.release_date = NotLoaded
                 movie.duration = NotLoaded
                 movie.short_description = htmlparser.unescape(short_description)
                 movie.pitch = NotLoaded
                 movie.country = NotLoaded
                 movie.note = NotLoaded
                 movie.roles = NotLoaded
                 movie.all_release_dates = NotLoaded
                 movie.thumbnail_url = NotLoaded
                 yield movie
Example #7
0
 def iter_movies(self, pattern):
     res = self.readurl('http://api.allocine.fr/rest/v3/search?partner=YW5kcm9pZC12M3M&filter=movie&q=%s&format=json' % pattern.encode('utf-8'))
     jres = json.loads(res)
     if 'movie' not in jres['feed']:
         return
     for m in jres['feed']['movie']:
         tdesc = u''
         if 'title' in m:
             tdesc += '%s' % m['title']
         if 'productionYear' in m:
             tdesc += ' ; %s' % m['productionYear']
         elif 'release' in m:
             tdesc += ' ; %s' % m['release']['releaseDate']
         if 'castingShort' in m and 'actors' in m['castingShort']:
             tdesc += ' ; %s' % m['castingShort']['actors']
         short_description = tdesc.strip('; ')
         thumbnail_url = NotAvailable
         if 'poster' in m:
             thumbnail_url = unicode(m['poster']['href'])
         movie = Movie(m['code'], unicode(m['originalTitle']))
         movie.other_titles = NotLoaded
         movie.release_date = NotLoaded
         movie.duration = NotLoaded
         movie.short_description = short_description
         movie.pitch = NotLoaded
         movie.country = NotLoaded
         movie.note = NotLoaded
         movie.roles = NotLoaded
         movie.all_release_dates = NotLoaded
         movie.thumbnail_url = thumbnail_url
         yield movie
Example #8
0
 def iter_movies(self, pattern):
     res = self.open('http://www.imdb.com/xml/find?json=1&nr=1&tt=on',
                     params={'q': pattern})
     jres = res.json()
     htmlparser = HTMLParser()
     for cat in ['title_popular', 'title_exact', 'title_approx']:
         if cat in jres:
             for m in jres[cat]:
                 tdesc = unicode(m['title_description'])
                 if '<a' in tdesc and '>' in tdesc:
                     short_description = u'%s %s' % (
                         tdesc.split('<')[0].strip(', '),
                         tdesc.split('>')[1].split('<')[0])
                 else:
                     short_description = tdesc.strip(', ')
                 movie = Movie(m['id'], htmlparser.unescape(m['title']))
                 movie.other_titles = NotLoaded
                 movie.release_date = NotLoaded
                 movie.duration = NotLoaded
                 movie.short_description = htmlparser.unescape(
                     short_description)
                 movie.pitch = NotLoaded
                 movie.country = NotLoaded
                 movie.note = NotLoaded
                 movie.roles = NotLoaded
                 movie.all_release_dates = NotLoaded
                 movie.thumbnail_url = NotLoaded
                 yield movie
Example #9
0
    def iter_movies(self, pattern):
        params = [('partner', self.PARTNER_KEY),
                  ('q', pattern.encode('utf-8')),
                  ('format', 'json'),
                  ('filter', 'movie')]

        res = self.__do_request('search', params)
        if res is None:
            return
        jres = json.loads(res)
        if 'movie' not in jres['feed']:
            return
        for m in jres['feed']['movie']:
            tdesc = u''
            if 'title' in m:
                tdesc += '%s' % m['title']
            if 'productionYear' in m:
                tdesc += ' ; %s' % m['productionYear']
            elif 'release' in m:
                tdesc += ' ; %s' % m['release']['releaseDate']
            if 'castingShort' in m and 'actors' in m['castingShort']:
                tdesc += ' ; %s' % m['castingShort']['actors']
            short_description = tdesc.strip('; ')
            thumbnail_url = NotAvailable
            if 'poster' in m:
                thumbnail_url = unicode(m['poster']['href'])
            movie = Movie(m['code'], unicode(m['originalTitle']))
            movie.other_titles = NotLoaded
            movie.release_date = NotLoaded
            movie.duration = NotLoaded
            movie.short_description = short_description
            movie.pitch = NotLoaded
            movie.country = NotLoaded
            movie.note = NotLoaded
            movie.roles = NotLoaded
            movie.all_release_dates = NotLoaded
            movie.thumbnail_url = thumbnail_url
            yield movie
Example #10
0
    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
Example #11
0
    def iter_person_movies(self, person_id, role_filter):
        params = [('partner', self.PARTNER_KEY), ('code', person_id),
                  ('profile', 'medium'), ('filter', 'movie'),
                  ('format', 'json')]

        jres = self.__do_request('filmography', params)
        if jres is not None:
            if 'person' in jres:
                jres = jres['person']
            else:
                return
        else:
            return
        for m in jres['participation']:
            if (role_filter is None or (role_filter is not None
                                        and m['activity']['$'].lower().strip()
                                        == role_filter.lower().strip())):
                prod_year = '????'
                if 'productionYear' in m['movie']:
                    prod_year = m['movie']['productionYear']
                short_description = u'(%s) %s' % (prod_year,
                                                  m['activity']['$'])
                if 'role' in m:
                    short_description += ', %s' % m['role']
                movie = Movie(m['movie']['code'],
                              unicode(m['movie']['originalTitle']))
                movie.other_titles = NotLoaded
                movie.release_date = NotLoaded
                movie.duration = NotLoaded
                movie.short_description = short_description
                movie.pitch = NotLoaded
                movie.country = NotLoaded
                movie.note = NotLoaded
                movie.roles = NotLoaded
                movie.all_release_dates = NotLoaded
                movie.thumbnail_url = NotLoaded
                yield movie
Example #12
0
    def iter_movies(self, pattern):
        params = [("partner", self.PARTNER_KEY), ("q", pattern), ("format", "json"), ("filter", "movie")]

        res = self.__do_request("search", params)
        if res is None:
            return
        jres = json.loads(res)
        if "movie" not in jres["feed"]:
            return
        for m in jres["feed"]["movie"]:
            tdesc = u""
            if "title" in m:
                tdesc += "%s" % m["title"]
            if "productionYear" in m:
                tdesc += " ; %s" % m["productionYear"]
            elif "release" in m:
                tdesc += " ; %s" % m["release"]["releaseDate"]
            if "castingShort" in m and "actors" in m["castingShort"]:
                tdesc += " ; %s" % m["castingShort"]["actors"]
            short_description = tdesc.strip("; ")
            thumbnail_url = NotAvailable
            if "poster" in m:
                thumbnail_url = unicode(m["poster"]["href"])
            movie = Movie(m["code"], unicode(m["originalTitle"]))
            movie.other_titles = NotLoaded
            movie.release_date = NotLoaded
            movie.duration = NotLoaded
            movie.short_description = short_description
            movie.pitch = NotLoaded
            movie.country = NotLoaded
            movie.note = NotLoaded
            movie.roles = NotLoaded
            movie.all_release_dates = NotLoaded
            movie.thumbnail_url = thumbnail_url
            yield movie
Example #13
0
    def iter_person_movies(self, person_id, role_filter):
        params = [
            ("partner", self.PARTNER_KEY),
            ("code", person_id),
            ("profile", "medium"),
            ("filter", "movie"),
            ("format", "json"),
        ]

        res = self.__do_request("filmography", params)
        if res is not None:
            jres = json.loads(res)
            if "person" in jres:
                jres = jres["person"]
            else:
                return
        else:
            return
        for m in jres["participation"]:
            if role_filter is None or (
                role_filter is not None and m["activity"]["$"].lower().strip() == role_filter.lower().strip()
            ):
                prod_year = "????"
                if "productionYear" in m["movie"]:
                    prod_year = m["movie"]["productionYear"]
                short_description = u"(%s) %s" % (prod_year, m["activity"]["$"])
                if "role" in m:
                    short_description += ", %s" % m["role"]
                movie = Movie(m["movie"]["code"], unicode(m["movie"]["originalTitle"]))
                movie.other_titles = NotLoaded
                movie.release_date = NotLoaded
                movie.duration = NotLoaded
                movie.short_description = short_description
                movie.pitch = NotLoaded
                movie.country = NotLoaded
                movie.note = NotLoaded
                movie.roles = NotLoaded
                movie.all_release_dates = NotLoaded
                movie.thumbnail_url = NotLoaded
                yield movie
Example #14
0
    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
Example #15
0
    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
Example #16
0
 def iter_movies(self, pattern):
     res = self.readurl("http://www.imdb.com/xml/find?json=1&nr=1&tt=on&q=%s" % pattern.encode("utf-8"))
     jres = json.loads(res)
     htmlparser = HTMLParser()
     for cat in ["title_popular", "title_exact", "title_approx"]:
         if cat in jres:
             for m in jres[cat]:
                 tdesc = unicode(m["title_description"])
                 if "<a" in tdesc and ">" in tdesc:
                     short_description = u"%s %s" % (
                         tdesc.split("<")[0].strip(", "),
                         tdesc.split(">")[1].split("<")[0],
                     )
                 else:
                     short_description = tdesc.strip(", ")
                 movie = Movie(m["id"], htmlparser.unescape(m["title"]))
                 movie.other_titles = NotLoaded
                 movie.release_date = NotLoaded
                 movie.duration = NotLoaded
                 movie.short_description = htmlparser.unescape(short_description)
                 movie.pitch = NotLoaded
                 movie.country = NotLoaded
                 movie.note = NotLoaded
                 movie.roles = NotLoaded
                 movie.all_release_dates = NotLoaded
                 movie.thumbnail_url = NotLoaded
                 yield movie
Example #17
0
    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
Example #18
0
    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
Example #19
0
    def iter_movies(self, pattern):
        params = [('partner', self.PARTNER_KEY), ('q', pattern),
                  ('format', 'json'), ('filter', 'movie')]

        jres = self.__do_request('search', params)
        if jres is None:
            return
        if 'movie' not in jres['feed']:
            return
        for m in jres['feed']['movie']:
            tdesc = u''
            if 'title' in m:
                tdesc += '%s' % m['title']
            if 'productionYear' in m:
                tdesc += ' ; %s' % m['productionYear']
            elif 'release' in m:
                tdesc += ' ; %s' % m['release']['releaseDate']
            if 'castingShort' in m and 'actors' in m['castingShort']:
                tdesc += ' ; %s' % m['castingShort']['actors']
            short_description = tdesc.strip('; ')
            thumbnail_url = NotAvailable
            if 'poster' in m:
                thumbnail_url = unicode(m['poster']['href'])
            movie = Movie(m['code'], unicode(m['originalTitle']))
            movie.other_titles = NotLoaded
            movie.release_date = NotLoaded
            movie.duration = NotLoaded
            movie.short_description = short_description
            movie.pitch = NotLoaded
            movie.country = NotLoaded
            movie.note = NotLoaded
            movie.roles = NotLoaded
            movie.all_release_dates = NotLoaded
            movie.thumbnail_url = thumbnail_url
            yield movie
Example #20
0
 def iter_person_movies(self, person_id, role_filter):
     res = self.readurl(
         'http://api.allocine.fr/rest/v3/filmography?partner=YW5kcm9pZC12M3M&profile=medium&code=%s&filter=movie&format=json'
         % person_id)
     if res is not None:
         jres = json.loads(res)
         if 'person' in jres:
             jres = jres['person']
         else:
             return
     else:
         return
     for m in jres['participation']:
         if (role_filter is None or (role_filter is not None
                                     and m['activity']['$'].lower().strip()
                                     == role_filter.lower().strip())):
             prod_year = '????'
             if 'productionYear' in m['movie']:
                 prod_year = m['movie']['productionYear']
             short_description = u'(%s) %s' % (prod_year,
                                               m['activity']['$'])
             if 'role' in m:
                 short_description += ', %s' % m['role']
             movie = Movie(m['movie']['code'],
                           unicode(m['movie']['originalTitle']))
             movie.other_titles = NotLoaded
             movie.release_date = NotLoaded
             movie.duration = NotLoaded
             movie.short_description = short_description
             movie.pitch = NotLoaded
             movie.country = NotLoaded
             movie.note = NotLoaded
             movie.roles = NotLoaded
             movie.all_release_dates = NotLoaded
             movie.thumbnail_url = NotLoaded
             yield movie
Example #21
0
    def iter_person_movies(self, person_id, role_filter):
        params = [('partner', self.PARTNER_KEY),
                  ('code', person_id),
                  ('profile', 'medium'),
                  ('filter', 'movie'),
                  ('format', 'json')]

        res = self.__do_request('filmography', params)
        if res is not None:
            jres = json.loads(res)
            if 'person' in jres:
                jres = jres['person']
            else:
                return
        else:
            return
        for m in jres['participation']:
            if (role_filter is None or (role_filter is not None and m['activity']['$'].lower().strip() == role_filter.lower().strip())):
                prod_year = '????'
                if 'productionYear' in m['movie']:
                    prod_year = m['movie']['productionYear']
                short_description = u'(%s) %s' % (prod_year, m['activity']['$'])
                if 'role' in m:
                    short_description += ', %s' % m['role']
                movie = Movie(m['movie']['code'], unicode(m['movie']['originalTitle']))
                movie.other_titles = NotLoaded
                movie.release_date = NotLoaded
                movie.duration = NotLoaded
                movie.short_description = short_description
                movie.pitch = NotLoaded
                movie.country = NotLoaded
                movie.note = NotLoaded
                movie.roles = NotLoaded
                movie.all_release_dates = NotLoaded
                movie.thumbnail_url = NotLoaded
                yield movie
Example #22
0
 def iter_movies(self, pattern):
     res = self.readurl(
         'http://api.allocine.fr/rest/v3/search?partner=YW5kcm9pZC12M3M&filter=movie&q=%s&format=json'
         % pattern.encode('utf-8'))
     jres = json.loads(res)
     if 'movie' not in jres['feed']:
         return
     for m in jres['feed']['movie']:
         tdesc = u''
         if 'title' in m:
             tdesc += '%s' % m['title']
         if 'productionYear' in m:
             tdesc += ' ; %s' % m['productionYear']
         elif 'release' in m:
             tdesc += ' ; %s' % m['release']['releaseDate']
         if 'castingShort' in m and 'actors' in m['castingShort']:
             tdesc += ' ; %s' % m['castingShort']['actors']
         short_description = tdesc.strip('; ')
         thumbnail_url = NotAvailable
         if 'poster' in m:
             thumbnail_url = unicode(m['poster']['href'])
         movie = Movie(m['code'], unicode(m['originalTitle']))
         movie.other_titles = NotLoaded
         movie.release_date = NotLoaded
         movie.duration = NotLoaded
         movie.short_description = short_description
         movie.pitch = NotLoaded
         movie.country = NotLoaded
         movie.note = NotLoaded
         movie.roles = NotLoaded
         movie.all_release_dates = NotLoaded
         movie.thumbnail_url = thumbnail_url
         yield movie
Example #23
0
    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
Example #24
0
    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
Example #25
0
    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
Example #26
0
 def iter_person_movies(self, person_id, role_filter):
     res = self.readurl(
             'http://api.allocine.fr/rest/v3/filmography?partner=YW5kcm9pZC12M3M&profile=medium&code=%s&filter=movie&format=json' % person_id)
     if res is not None:
         jres = json.loads(res)
         if 'person' in jres:
             jres = jres['person']
         else:
             return
     else:
         return
     for m in jres['participation']:
         if (role_filter is None or (role_filter is not None and m['activity']['$'].lower().strip() == role_filter.lower().strip())):
             prod_year = '????'
             if 'productionYear' in m['movie']:
                 prod_year = m['movie']['productionYear']
             short_description = u'(%s) %s' % (prod_year, m['activity']['$'])
             if 'role' in m:
                 short_description += ', %s' % m['role']
             movie = Movie(m['movie']['code'], unicode(m['movie']['originalTitle']))
             movie.other_titles = NotLoaded
             movie.release_date = NotLoaded
             movie.duration = NotLoaded
             movie.short_description = short_description
             movie.pitch = NotLoaded
             movie.country = NotLoaded
             movie.note = NotLoaded
             movie.roles = NotLoaded
             movie.all_release_dates = NotLoaded
             movie.thumbnail_url = NotLoaded
             yield movie