Пример #1
0
 def get_person_filmography(self, personID):
     infosets = ('filmography', 'episodes')
     res = {}
     episodes = {}
     works = ('actor', 'actresse', 'producer', 'writer',
             'cinematographer', 'composer', 'costume-designer',
             'director', 'editor', 'miscellaneou', 'production-designer')
     for i in works:
         index = getFullIndex('%s%ss.names' % (self.__db, i), personID)
         if index is not None:
             params = {'offset': index,
                         'indexF': '%stitles.index' % self.__db,
                         'keyF': '%stitles.key' % self.__db,
                         'attrIF': '%sattributes.index' % self.__db,
                         'attrKF': '%sattributes.key' % self.__db,
                         'charNF': '%scharacter2id.index' % self.__db}
             name = key = i
             if '-' in name:
                 name = name.replace('-', ' ')
             elif name == 'actresse':
                 name = 'actress'
                 params['doCast'] = 1
             elif name == 'miscellaneou':
                 name = 'miscellaneous crew'
                 key = 'miscellaneou'
             elif name == 'actor':
                 params['doCast'] = 1
             elif name == 'writer':
                 params['doWriters'] = 1
             params['dataF'] = '%s%ss.data' % (self.__db, key)
             data = getFilmography(**params)
             movies = []
             eps = []
             # Split normal titles from episodes.
             for d in data:
                 if d.get('kind') != 'episode':
                     movies.append(d)
                 else:
                     eps.append(d)
             movies.sort()
             if movies:
                 res[name] = movies
             for e in eps:
                 series = Movie(data=e['episode of'], accessSystem='local')
                 seriesID = self._getTitleID(series.get(
                                             'long imdb canonical title'))
                 series.movieID = seriesID
                 if not e.get('year'):
                     year = getFullIndex('%smovies.data' % self.__db,
                                         e.movieID, kind='moviedata',
                                         rindex=1)
                     if year: e['year'] = year
                 if not e.currentRole and name not in ('actor', 'actress'):
                     if e.notes: e.notes = ' %s' % e.notes
                     e.notes = '[%s]%s' % (name, e.notes)
                 episodes.setdefault(series, []).append(e)
     if episodes:
         for k in episodes:
             episodes[k].sort()
             episodes[k].reverse()
         res['episodes'] = episodes
     return {'data': res, 'info sets': tuple(infosets)}
Пример #2
0
 def get_person_filmography(self, personID):
     infosets = ('filmography', 'episodes')
     res = {}
     episodes = {}
     works = ('actor', 'actresse', 'producer', 'writer',
             'cinematographer', 'composer', 'costume-designer',
             'director', 'editor', 'miscellaneou', 'production-designer')
     for i in works:
         index = getFullIndex('%s%ss.names' % (self.__db, i), personID)
         if index is not None:
             params = {'offset': index,
                         'indexF': '%stitles.index' % self.__db,
                         'keyF': '%stitles.key' % self.__db,
                         'attrIF': '%sattributes.index' % self.__db,
                         'attrKF': '%sattributes.key' % self.__db,
                         'charNF': '%scharacter2id.index' % self.__db}
             name = key = i
             if '-' in name:
                 name = name.replace('-', ' ')
             elif name == 'actresse':
                 name = 'actress'
                 params['doCast'] = 1
             elif name == 'miscellaneou':
                 name = 'miscellaneous crew'
                 key = 'miscellaneou'
             elif name == 'actor':
                 params['doCast'] = 1
             elif name == 'writer':
                 params['doWriters'] = 1
             params['dataF'] = '%s%ss.data' % (self.__db, key)
             data = getFilmography(**params)
             movies = []
             eps = []
             # Split normal titles from episodes.
             for d in data:
                 if d.get('kind') != 'episode':
                     movies.append(d)
                 else:
                     eps.append(d)
             movies.sort()
             if movies:
                 res[name] = movies
             for e in eps:
                 series = Movie(data=e['episode of'], accessSystem='local')
                 seriesID = self._getTitleID(series.get(
                                             'long imdb canonical title'))
                 series.movieID = seriesID
                 if not e.get('year'):
                     year = getFullIndex('%smovies.data' % self.__db,
                                         e.movieID, kind='moviedata',
                                         rindex=1)
                     if year: e['year'] = year
                 if not e.currentRole and name not in ('actor', 'actress'):
                     if e.notes: e.notes = ' %s' % e.notes
                     e.notes = '[%s]%s' % (name, e.notes)
                 episodes.setdefault(series, []).append(e)
     if episodes:
         for k in episodes:
             episodes[k].sort()
             episodes[k].reverse()
         res['episodes'] = episodes
     return {'data': res, 'info sets': tuple(infosets)}
Пример #3
0
 def get_movie_main(self, movieID):
     # Information sets provided by this method.
     infosets = ('main', 'vote details')
     tl = getLabel(movieID, '%stitles.index' % self.__db,
                     '%stitles.key' % self.__db)
     # No title, no party.
     if tl is None:
         raise IMDbDataAccessError, 'unable to get movieID "%s"' % movieID
     res = analyze_title(tl)
     # Build the cast list.
     actl = []
     for castG in ('actors', 'actresses'):
         midx = getFullIndex('%s%s.titles' % (self.__db, castG),
                         movieID, multi=1)
         if midx is not None:
             params = {'movieID': movieID,
                         'dataF': '%s%s.data' % (self.__db, castG),
                         'indexF': '%snames.index' % self.__db,
                         'keyF': '%snames.key' % self.__db,
                         'attrIF': '%sattributes.index' % self.__db,
                         'attrKF': '%sattributes.key' % self.__db,
                         'charNF': '%scharacter2id.index' % self.__db,
                         'offsList': midx, 'doCast': 1}
             actl += getMovieCast(**params)
     if actl:
         actl.sort()
         res['cast'] = actl
     # List of other workers.
     works = ('writer', 'cinematographer', 'composer',
             'costume-designer', 'director', 'editor', 'miscellaneou',
             'producer', 'production-designer', 'cinematographer')
     for i in works:
         index = getFullIndex('%s%ss.titles' % (self.__db, i),
                                 movieID, multi=1)
         if index is not None:
             params = {'movieID': movieID,
                         'dataF': '%s%s.data' % (self.__db, i),
                         'indexF': '%snames.index' % self.__db,
                         'keyF': '%snames.key' % self.__db,
                         'attrIF': '%sattributes.index' % self.__db,
                         'attrKF': '%sattributes.key' % self.__db,
                         'offsList': index}
             name = key = i
             if '-' in name:
                 name = name.replace('-', ' ')
             elif name == 'miscellaneou':
                 name = 'miscellaneous crew'
                 key = 'miscellaneou'
             elif name == 'writer':
                 params['doWriters'] = 1
             params['dataF'] = '%s%ss.data' % (self.__db, key)
             data = getMovieCast(**params)
             if name == 'writer': data.sort()
             res[name] = data
     # Rating.
     rt = self.get_movie_vote_details(movieID)['data']
     if rt: res.update(rt)
     # Various information.
     miscInfo = (('runtimes', 'running-times'), ('color info', 'color-info'),
                 ('genres', 'genres'), ('distributors', 'distributors'),
                 ('languages', 'language'), ('certificates', 'certificates'),
                 ('special effects companies', 'special-effects-companies'),
                 ('sound mix', 'sound-mix'), ('tech info', 'technical'),
                 ('production companies', 'production-companies'),
                 ('countries', 'countries'))
     for name, fname in miscInfo:
         params = {'movieID': movieID,
             'dataF': '%s%s.data' % (self.__db, fname),
             'indexF': '%s%s.index' % (self.__db, fname),
             'attrIF': '%sattributes.index' % self.__db,
             'attrKF': '%sattributes.key' % self.__db}
         data = getMovieMisc(**params)
         if name in ('distributors', 'special effects companies',
                     'production companies'):
             for nitem in xrange(len(data)):
                 n, notes = split_company_name_notes(data[nitem])
                 company = Company(name=n, companyID=getCompanyID(n,
                                     '%scompany2id.index' % self.__db),
                                     notes=notes,
                                     accessSystem=self.accessSystem)
                 data[nitem] = company
         if data: res[name] = data
     if res.has_key('runtimes') and len(res['runtimes']) > 0:
         rt = res['runtimes'][0]
         episodes = re_episodes.findall(rt)
         if episodes:
             res['runtimes'][0] = re_episodes.sub('', rt)
             res['number of episodes'] = episodes[0]
     # AKA titles.
     akas = getAkaTitles(movieID,
                 '%saka-titles.data' % self.__db,
                 '%stitles.index' % self.__db,
                 '%stitles.key' % self.__db,
                 '%sattributes.index' % self.__db,
                 '%sattributes.key' % self.__db)
     if akas:
         # normalize encoding.
         for i in xrange(len(akas)):
             ts = akas[i].split('::')
             if len(ts) != 2: continue
             t = ts[0]
             n = ts[1]
             nt = self._changeAKAencoding(n, t)
             if nt is not None: akas[i] = '%s::%s' % (nt, n)
         res['akas'] = akas
     if res.get('kind') == 'episode':
         # Things to do if this is a tv series episode.
         episodeOf = res.get('episode of')
         if episodeOf is not None:
             parentSeries = Movie(data=res['episode of'],
                                         accessSystem='local')
             seriesID = self._getTitleID(parentSeries.get(
                                         'long imdb canonical title'))
             parentSeries.movieID = seriesID
             res['episode of'] = parentSeries
         if not res.get('year'):
             year = getFullIndex('%smovies.data' % self.__db,
                                 movieID, kind='moviedata', rindex=1)
             if year: res['year'] = year
     # MPAA info.
     mpaa = getMPAA(movieID, '%smpaa-ratings-reasons.index' % self.__db,
                     '%smpaa-ratings-reasons.data' % self.__db)
     if mpaa: res.update(mpaa)
     return {'data': res, 'info sets': infosets}
Пример #4
0
 def get_movie_main(self, movieID):
     # Information sets provided by this method.
     infosets = ('main', 'vote details')
     tl = getLabel(movieID, '%stitles.index' % self.__db,
                     '%stitles.key' % self.__db)
     # No title, no party.
     if tl is None:
         raise IMDbDataAccessError, 'unable to get movieID "%s"' % movieID
     res = analyze_title(tl)
     # Build the cast list.
     actl = []
     for castG in ('actors', 'actresses'):
         midx = getFullIndex('%s%s.titles' % (self.__db, castG),
                         movieID, multi=1)
         if midx is not None:
             params = {'movieID': movieID,
                         'dataF': '%s%s.data' % (self.__db, castG),
                         'indexF': '%snames.index' % self.__db,
                         'keyF': '%snames.key' % self.__db,
                         'attrIF': '%sattributes.index' % self.__db,
                         'attrKF': '%sattributes.key' % self.__db,
                         'charNF': '%scharacter2id.index' % self.__db,
                         'offsList': midx, 'doCast': 1}
             actl += getMovieCast(**params)
     if actl:
         actl.sort()
         res['cast'] = actl
     # List of other workers.
     works = ('writer', 'cinematographer', 'composer',
             'costume-designer', 'director', 'editor', 'miscellaneou',
             'producer', 'production-designer', 'cinematographer')
     for i in works:
         index = getFullIndex('%s%ss.titles' % (self.__db, i),
                                 movieID, multi=1)
         if index is not None:
             params = {'movieID': movieID,
                         'dataF': '%s%s.data' % (self.__db, i),
                         'indexF': '%snames.index' % self.__db,
                         'keyF': '%snames.key' % self.__db,
                         'attrIF': '%sattributes.index' % self.__db,
                         'attrKF': '%sattributes.key' % self.__db,
                         'offsList': index}
             name = key = i
             if '-' in name:
                 name = name.replace('-', ' ')
             elif name == 'miscellaneou':
                 name = 'miscellaneous crew'
                 key = 'miscellaneou'
             elif name == 'writer':
                 params['doWriters'] = 1
             params['dataF'] = '%s%ss.data' % (self.__db, key)
             data = getMovieCast(**params)
             if name == 'writer': data.sort()
             res[name] = data
     # Rating.
     rt = self.get_movie_vote_details(movieID)['data']
     if rt: res.update(rt)
     # Various information.
     miscInfo = (('runtimes', 'running-times'), ('color info', 'color-info'),
                 ('genres', 'genres'), ('distributors', 'distributors'),
                 ('languages', 'language'), ('certificates', 'certificates'),
                 ('special effects companies', 'special-effects-companies'),
                 ('sound mix', 'sound-mix'), ('tech info', 'technical'),
                 ('production companies', 'production-companies'),
                 ('countries', 'countries'))
     for name, fname in miscInfo:
         params = {'movieID': movieID,
             'dataF': '%s%s.data' % (self.__db, fname),
             'indexF': '%s%s.index' % (self.__db, fname),
             'attrIF': '%sattributes.index' % self.__db,
             'attrKF': '%sattributes.key' % self.__db}
         data = getMovieMisc(**params)
         if name in ('distributors', 'special effects companies',
                     'production companies'):
             for nitem in xrange(len(data)):
                 n, notes = split_company_name_notes(data[nitem])
                 company = Company(name=n, companyID=getCompanyID(n,
                                     '%scompany2id.index' % self.__db),
                                     notes=notes,
                                     accessSystem=self.accessSystem)
                 data[nitem] = company
         if data: res[name] = data
     if res.has_key('runtimes') and len(res['runtimes']) > 0:
         rt = res['runtimes'][0]
         episodes = re_episodes.findall(rt)
         if episodes:
             res['runtimes'][0] = re_episodes.sub('', rt)
             res['number of episodes'] = episodes[0]
     # AKA titles.
     akas = getAkaTitles(movieID,
                 '%saka-titles.data' % self.__db,
                 '%stitles.index' % self.__db,
                 '%stitles.key' % self.__db,
                 '%sattributes.index' % self.__db,
                 '%sattributes.key' % self.__db)
     if akas:
         # normalize encoding.
         for i in xrange(len(akas)):
             ts = akas[i].split('::')
             if len(ts) != 2: continue
             t = ts[0]
             n = ts[1]
             nt = self._changeAKAencoding(n, t)
             if nt is not None: akas[i] = '%s::%s' % (nt, n)
         res['akas'] = akas
     if res.get('kind') == 'episode':
         # Things to do if this is a tv series episode.
         episodeOf = res.get('episode of')
         if episodeOf is not None:
             parentSeries = Movie(data=res['episode of'],
                                         accessSystem='local')
             seriesID = self._getTitleID(parentSeries.get(
                                         'long imdb canonical title'))
             parentSeries.movieID = seriesID
             res['episode of'] = parentSeries
         if not res.get('year'):
             year = getFullIndex('%smovies.data' % self.__db,
                                 movieID, kind='moviedata', rindex=1)
             if year: res['year'] = year
     # MPAA info.
     mpaa = getMPAA(movieID, '%smpaa-ratings-reasons.index' % self.__db,
                     '%smpaa-ratings-reasons.data' % self.__db)
     if mpaa: res.update(mpaa)
     return {'data': res, 'info sets': infosets}