Пример #1
0
 def get_movie_miscellaneous_companies(self, movieID):
     params = {
         'movieID': movieID,
         'dataF': '%smiscellaneous-companies.data' % self.__db,
         'indexF': '%smiscellaneous-companies.index' % self.__db,
         'attrIF': '%sattributes.index' % self.__db,
         'attrKF': '%sattributes.key' % self.__db
     }
     try:
         data = getMovieMisc(**params)
     except IMDbDataAccessError:
         import warnings
         warnings.warn('miscellaneous-companies files not found; '
                       'run the misc-companies4local.py script.')
         return {'data': {}}
     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: return {'data': {'miscellaneous companies': data}}
     return {'data': {}}
Пример #2
0
         res.setdefault(sect, []).append(data)
 # Companies info about a movie.
 cinfo = [
     (self._compType[m.companyTypeID], m.companyID, m.note)
     for m in MovieCompanies.select(MovieCompanies.q.movieID == movieID)
 ]
 cinfo = _groupListBy(cinfo, 0)
 for group in cinfo:
     sect = group[0][0]
     for mdata in group:
         cDb = CompanyName.get(mdata[1])
         cDbTxt = cDb.name
         if cDb.countryCode:
             cDbTxt += ' %s' % cDb.countryCode
         company = Company(name=cDbTxt,
                           companyID=mdata[1],
                           notes=mdata[2] or u'',
                           accessSystem=self.accessSystem)
         res.setdefault(sect, []).append(company)
 # AKA titles.
 akat = [(get_movie_data(at.id, self._kind, fromAka=1), at.note)
         for at in AkaTitle.select(AkaTitle.q.movieID == movieID)]
 if akat:
     res['akas'] = []
     for td, note in akat:
         nt = build_title(td, canonical=1, ptdf=1)
         if note:
             net = self._changeAKAencoding(note, nt)
             if net is not None: nt = net
             nt += '::%s' % note
         if nt not in res['akas']: res['akas'].append(nt)
 # Complete cast/crew.
Пример #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}