def main(): # TODO: on jarvis use sys.listitem and getProperty, getfilename, getVideoInfoTag stream_file = xbmc.getInfoLabel('ListItem.FileNameAndPath') url = get_url(stream_file) if url is None: db_type = xbmc.getInfoLabel('ListItem.DBTYPE') if db_type == "movie": imdbnumber = xbmc.getInfoLabel('ListItem.IMDBNumber') url = "plugin://{0}/movies/play/{1}/{2}/select".format(pluginid, "imdb", imdbnumber) else: storage_path = xbmc.translatePath('special://profile/addon_data/%s/.storage/' % pluginid) if not os.path.isdir(storage_path): os.makedirs(storage_path) tvdb = Tvdb("0629B785CE550C8D", language="all", cache=storage_path) title = xbmc.getInfoLabel('ListItem.TVShowTitle') year = xbmc.getInfoLabel('ListItem.Property(year)') season = xbmc.getInfoLabel('ListItem.Season') episode = xbmc.getInfoLabel('ListItem.Episode') results = [x['id'] for x in tvdb.search(title, year)] if results: tvdb_id = results[0] url = "plugin://{0}/tv/play/{1}/{2}/{3}/select".format(pluginid, tvdb_id, season, episode) else: title = "Meta" msg = "Failed to find media on TVDB" xbmc.executebuiltin('XBMC.Notification("%s", "%s", "%s", "%s")' % (msg, title, 2000, '')) xbmc.executebuiltin("PlayMedia({0})".format(url))
def nameByName(showname, episodename): """Searches for episode with correct name. The tvdb_api search is very simple, along the lines of: if searchterm in current_episodename: ..so the episode name must be accurate """ try: show = Tvdb(interactive=True)[showname] except Exception as e: print e return None, [] sr = show.search(episodename, key='episodename') if len(sr) == 0: another = " ".join(episodename.replace('_', ' ').split(" ")[0:2]) print "Zero results, Searching for {} instead...".format(another) sr = show.search(another, key='episodename') if len(sr) != 1: print "Got %d search results for %s episode named %s" % (len(sr), showname, episodename) return show['seriesname'], sr
def main(): # TODO: on jarvis use sys.listitem and getProperty, getfilename, getVideoInfoTag stream_file = xbmc.getInfoLabel('ListItem.FileNameAndPath') url = get_url(stream_file) if url is None: db_type = xbmc.getInfoLabel('ListItem.DBTYPE') if db_type == "movie": imdbnumber = xbmc.getInfoLabel('ListItem.IMDBNumber') url = "plugin://{0}/movies/play/{1}/{2}/select".format( pluginid, "imdb", imdbnumber) elif db_type == "episode": storage_path = xbmc.translatePath( 'special://profile/addon_data/%s/.storage/' % pluginid) if not os.path.isdir(storage_path): os.makedirs(storage_path) tvdb = Tvdb("0629B785CE550C8D", cache=storage_path) title = xbmc.getInfoLabel('ListItem.TVShowTitle') year = xbmc.getInfoLabel('ListItem.Property(year)') season = xbmc.getInfoLabel('ListItem.Season') episode = xbmc.getInfoLabel('ListItem.Episode') dbid = xbmc.getInfoLabel('ListItem.DBID') results = tvdb.search(title, year, language="all") if results: tvdb_id = None identifier = get_tvshow_id_by_episode(dbid) if identifier: by_id = [ x for x in results if x['id'] == identifier or x.get('imdb_id') == identifier ] if by_id: tvdb_id = by_id[0]['id'] if tvdb_id is None: tvdb_id = results[0]['id'] url = "plugin://{0}/tv/play/{1}/{2}/{3}/select".format( pluginid, tvdb_id, season, episode) else: title = "Meta" msg = "Failed to find media on TVDB" xbmc.executebuiltin( 'XBMC.Notification("%s", "%s", "%s", "%s")' % (msg, title, 2000, '')) xbmc.executebuiltin("PlayMedia({0})".format(url))
def search(self, text): tv = Tvdb() return tv.search(text)