44from builtins import * # noqa: F401, F403
55
66import tvdb_api
7+ from . import imdb
78
89
910class TvdbResult (object ):
@@ -47,9 +48,28 @@ def summary(self):
4748 'cast' : self .show ['_actors' ],
4849 # 'seasons': len(self.show),
4950 # 'status': self.show['status'],
50- 'contentrating' : self .show ['rating' ]
51+ 'contentrating' : self .show ['rating' ],
52+ 'imdb_id' : self .show ['imdbId' ],
5153 }
5254
55+ def add_show_titles (self , summary ):
56+ i = imdb .IMDB ()
57+ try :
58+ imdb_info = i .get_info (summary ['imdb_id' ])
59+ except Exception :
60+ summary ['titles' ] = {}
61+ else :
62+ imdb_sum = imdb_info .summary ()
63+ tvdb_title = summary ['title' ]
64+ # Original title
65+ summary ['title' ] = imdb_sum ['title' ]
66+ # dict of international titles
67+ summary ['titles' ] = imdb_sum ['titles' ]
68+ # "XWW" is IMDb's international title, but unlike TVDB, it doesn't include the
69+ # year if there are multiple shows with the same name.
70+ if 'XWW' in summary ['titles' ]:
71+ summary ['titles' ]['XWW' ] = tvdb_title
72+
5373
5474class TvdbSeason (TvdbResult ):
5575 def summary (self ):
@@ -73,6 +93,7 @@ def summary(self):
7393 s ['cover' ] = self .banner (season_number )
7494 s ['season' ] = season_number
7595 s ['imdb_id' ] = self .show ['imdbId' ]
96+ self .add_show_titles (s )
7697 return s
7798
7899
@@ -95,7 +116,7 @@ def summary(self):
95116 'language' : self .episode ['language' ],
96117 'url' : 'https://thetvdb.com/series/{}' .format (self .show ['slug' ]),
97118 'cover' : self .banner (self .episode ['seasonnumber' ])})
98-
119+ self . add_show_titles ( summary )
99120 return summary
100121
101122
0 commit comments