Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2012
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def XBMC_OriginalTitle(title):
  2.     OriginalTitle = title
  3.     json_query = xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Player.GetItem", "params": { "playerid": 1} ,"id":1}' )
  4.     json_player_getitem = simplejson.loads(unicode(json_query, 'utf-8', errors='ignore'))
  5.     if json_player_getitem.has_key('result') and json_player_getitem['result'].has_key('item') and json_player_getitem['result']['item'].has_key('id') and json_player_getitem['result']['item'].has_key('type'):
  6.         if json_player_getitem['result']['item']['type'] == "movie":
  7.             json_query = xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"VideoLibrary.GetMovieDetails", "params": { "movieid": %s, "properties": ["originaltitle"]} ,"id":1}' % (json_player_getitem['result']['item']['id']) )
  8.             json_getmoviedetails = simplejson.loads(unicode(json_query, 'utf-8', errors='ignore'))
  9.             if json_getmoviedetails.has_key('result') and json_getmoviedetails['result'].has_key('moviedetails') and json_getmoviedetails['result']['moviedetails'].has_key('originaltitle'):
  10.                 OriginalTitle = json_getmoviedetails['result']['moviedetails']['originaltitle']
  11.         elif json_player_getitem['result']['item']['type'] == "episode":
  12.             json_query = xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"VideoLibrary.GetEpisodeDetails", "params": { "episodeid": %s, "properties": ["originaltitle", "tvshowid"]} ,"id":1}' % (json_player_getitem['result']['item']['id']) )
  13.             json_getepisodedetails = simplejson.loads(unicode(json_query, 'utf-8', errors='ignore'))
  14.             if json_getepisodedetails.has_key('result') and json_getepisodedetails['result'].has_key('episodedetails') and json_getepisodedetails['result']['episodedetails'].has_key('tvshowid'):
  15.                 json_query = xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"VideoLibrary.GetTVShowDetails", "params": { "tvshowid": %s, "properties": ["originaltitle", "imdbnumber"]} ,"id":1}' % (json_getepisodedetails['result']['episodedetails']['tvshowid']) )
  16.                 json_gettvshowdetails = simplejson.loads(unicode(json_query, 'utf-8', errors='ignore'))
  17.                 if json_gettvshowdetails.has_key('result') and json_gettvshowdetails['result'].has_key('tvshowdetails') and json_gettvshowdetails['result']['tvshowdetails'].has_key('imdbnumber'):
  18.                     thetvdb = json_gettvshowdetails['result']['tvshowdetails']['imdbnumber']
  19.                     HTTPResponse = urllib2.urlopen("http://www.thetvdb.com/data/series/"+str(thetvdb)+"/").read()
  20.                     if re.search("<SeriesName>(.*?)</SeriesName>", HTTPResponse):
  21.                         OriginalTitle = re.findall("<SeriesName>(.*?)</SeriesName>", HTTPResponse)[0]
  22.     return OriginalTitle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement