group output by services
This commit is contained in:
parent
ece58dad63
commit
5e253ba9ac
1 changed files with 46 additions and 17 deletions
|
@ -14,6 +14,7 @@ from ox import stripTags
|
|||
import ox.web.archive
|
||||
import ox.web.imdb
|
||||
import ox.web.wikipedia
|
||||
import ox.web.allmovie
|
||||
|
||||
|
||||
def getMovieIdByImdbId(imdb_id):
|
||||
|
@ -143,30 +144,58 @@ class MovieId(models.Model):
|
|||
|
||||
def json(self):
|
||||
json = {}
|
||||
keys = [
|
||||
json['imdb.com'] = {}
|
||||
for key in [
|
||||
'title',
|
||||
'director',
|
||||
'year',
|
||||
'imdb_id',
|
||||
'oxdb_id',
|
||||
'amg_id',
|
||||
'wikipedia_id',
|
||||
'criterion_id',
|
||||
'impawards_id',
|
||||
]
|
||||
if self.episode > -1:
|
||||
keys += ['episode', 'season', 'episode_title', 'series_title']
|
||||
for key in keys:
|
||||
]:
|
||||
value = getattr(self, key)
|
||||
if value:
|
||||
json[key] = value
|
||||
if 'director' in json:
|
||||
json['directors'] = json.pop('director').split(', ')
|
||||
if 'year' in json and json['year']:
|
||||
json['year'] = int(json['year'])
|
||||
json['imdb.com'][{'imdb_id': 'id'}.get(key, key)] = value
|
||||
json['imdb.com']['url'] = ox.web.imdb.getUrl(self.imdb_id)
|
||||
|
||||
json['suggested_name'] = self.suggested_name()
|
||||
json['suggested_path'] = self.suggested_path()
|
||||
if self.amg_id:
|
||||
json['allmovie.com'] = {
|
||||
'id': self.amg_id,
|
||||
'url': ox.web.allmovie.getUrl(self.amg_id)
|
||||
}
|
||||
if self.wikipedia_id:
|
||||
json['wikipedia.org'] = {
|
||||
'id': self.wikipedia_id,
|
||||
'url': ox.web.wikipedia.getUrl(self.wikipedia_id)
|
||||
}
|
||||
if self.criterion_id:
|
||||
json['criterion.com'] = {
|
||||
'id': self.criterion_id,
|
||||
'url': ox.web.criterion.getUrl(self.criterion_id)
|
||||
}
|
||||
if self.impawards_id:
|
||||
json['impawards.com'] = {
|
||||
'id': self.impawards_id,
|
||||
'url': ox.web.impawards.getUrl(self.impawards_id)
|
||||
}
|
||||
if self.archiveorg_id:
|
||||
json['archive.org'] = {
|
||||
'id': self.archiveorg_id,
|
||||
'url': ox.web.archive.getUrl(self.archive_id)
|
||||
}
|
||||
|
||||
if self.episode > -1:
|
||||
keys = ['episode', 'season', 'episode_title', 'series_title']
|
||||
for key in keys:
|
||||
value = getattr(self, key)
|
||||
if value:
|
||||
json['imdb.com'][key] = value
|
||||
if 'director' in json['imdb.com']:
|
||||
json['imdb.com']['directors'] = json['imdb.com'].pop('director').split(', ')
|
||||
if 'year' in json['imdb.com'] and json['imdb.com']['year']:
|
||||
json['imdb.com']['year'] = int(json['imdb.com']['year'])
|
||||
|
||||
json['0xdb.org'] = {}
|
||||
json['0xdb.org']['suggested_name'] = self.suggested_name()
|
||||
json['0xdb.org']['suggested_path'] = self.suggested_path()
|
||||
|
||||
return json
|
||||
|
||||
|
|
Loading…
Reference in a new issue