def play_source(self, title, year, season, episode, imdb, tmdb, tvdb, url, meta, debridPackCall=False): try: from sys import argv # some functions like ActivateWindow() throw invalid handle less this is imported here. if not url: raise Exception self.media_type = 'movie' if season is None or episode is None else 'episode' self.title, self.year = title, str(year) if self.media_type == 'movie': self.name, self.season, self.episode = '%s (%s)' % (title, self.year), None, None elif self.media_type == 'episode': self.name, self.season, self.episode = '%s S%02dE%02d' % (title, int(season), int(episode)), '%01d' % int(season), '%01d' % int(episode) self.imdb, self.tmdb, self.tvdb = imdb or '', tmdb or '', tvdb or '' self.ids = {'imdb': self.imdb, 'tmdb': self.tmdb, 'tvdb': self.tvdb} ## - compare meta received to database and use largest(eventually switch to a request to fetch missing db meta for item) self.imdb_user = control.setting('imdb.user').replace('ur', '') self.tmdb_key = control.setting('tmdb.api.key') if not self.tmdb_key: self.tmdb_key = '3320855e65a9758297fec4f7c9717698' self.tvdb_key = control.setting('tvdb.api.key') if self.media_type == 'episode': self.user = str(self.imdb_user) + str(self.tvdb_key) else: self.user = str(self.tmdb_key) self.lang = control.apiLanguage()['tvdb'] meta1 = dict((k, v) for k, v in iter(meta.items()) if v is not None and v != '') if meta else None meta2 = metacache.fetch([{'imdb': self.imdb, 'tmdb': self.tmdb, 'tvdb': self.tvdb}], self.lang, self.user)[0] if meta2 != self.ids: meta2 = dict((k, v) for k, v in iter(meta2.items()) if v is not None and v != '') if meta1 is not None: try: if len(meta2) > len(meta1): meta2.update(meta1) meta = meta2 else: meta = meta1 except: log_utils.error() else: meta = meta2 if meta2 != self.ids else meta1 ################## self.poster = meta.get('poster') if meta else '' self.fanart = meta.get('fanart') if meta else '' self.meta = meta poster, thumb, season_poster, fanart, banner, clearart, clearlogo, discart, meta = self.getMeta(meta) self.offset = Bookmarks().get(name=self.name, imdb=imdb, tmdb=tmdb, tvdb=tvdb, season=season, episode=episode, year=self.year, runtime=meta.get('duration') if meta else 0) if self.offset == '-1': log_utils.log('User requested playback cancel', level=log_utils.LOGDEBUG) control.notification(message=32328) return control.cancelPlayback() item = control.item(path=url) item.setUniqueIDs(self.ids) if self.media_type == 'episode': item.setArt({'tvshow.clearart': clearart, 'tvshow.clearlogo': clearlogo, 'tvshow.discart': discart, 'thumb': thumb, 'tvshow.poster': season_poster, 'season.poster': season_poster, 'tvshow.fanart': fanart}) else: item.setArt({'clearart': clearart, 'clearlogo': clearlogo, 'discart': discart, 'thumb': thumb, 'poster': poster, 'fanart': fanart}) if 'castandart' in meta: item.setCast(meta.get('castandart', '')) item.setInfo(type='video', infoLabels=control.metadataClean(meta)) item.setProperty('IsPlayable', 'true') if debridPackCall: control.player.play(url, item) # seems this is only way browseDebrid pack files will play and have meta marked as watched else: control.resolve(int(argv[1]), True, item) homeWindow.setProperty('script.trakt.ids', jsdumps(self.ids)) self.keepAlive() homeWindow.clearProperty('script.trakt.ids') except: log_utils.error() return control.cancelPlayback()
def play_source(self, title, year, season, episode, imdb, tmdb, tvdb, url, meta, select=None): try: if not url: raise Exception self.media_type = 'movie' if season is None or episode is None else 'episode' self.title = title self.year = str(year) if self.media_type == 'movie': self.name = '%s (%s)' % (title, self.year) self.season = None self.episode = None elif self.media_type == 'episode': self.name = '%s S%02dE%02d' % (title, int(season), int(episode)) self.season = '%01d' % int(season) self.episode = '%01d' % int(episode) self.DBID = None self.imdb = imdb if imdb is not None else '' self.tmdb = tmdb if tmdb is not None else '' self.tvdb = tvdb if tvdb is not None else '' self.ids = { 'imdb': self.imdb, 'tmdb': self.tmdb, 'tvdb': self.tvdb } ## - compare meta received to database and use largest(eventually switch to a request to fetch missing db meta for item) self.imdb_user = control.setting('imdb.user').replace('ur', '') self.tmdb_key = control.setting('tmdb.api.key') if not self.tmdb_key: self.tmdb_key = '3320855e65a9758297fec4f7c9717698' self.tvdb_key = control.setting('tvdb.api.key') if self.media_type == 'episode': self.user = str(self.imdb_user) + str(self.tvdb_key) else: self.user = str(self.tmdb_key) self.lang = control.apiLanguage()['tvdb'] meta1 = meta meta2 = metacache.fetch([{ 'imdb': self.imdb, 'tmdb': self.tmdb, 'tvdb': self.tvdb }], self.lang, self.user)[0] if meta2 != self.ids: meta2 = dict((k, v) for k, v in control.iteritems(meta2) if v is not None and v != '') if meta1 is not None: try: if len(meta2) > len(meta1): meta2.update(meta1) meta = meta2 else: meta = meta1 except: log_utils.error() else: meta = meta2 if meta2 != self.ids else meta1 ################## self.meta = meta poster, thumb, season_poster, fanart, banner, clearart, clearlogo, discart, meta = self.getMeta( meta) runtime = meta.get('duration') if meta else 0 self.offset = Bookmarks().get(name=self.name, imdb=imdb, tmdb=tmdb, tvdb=tvdb, season=season, episode=episode, year=self.year, runtime=runtime) item = control.item(path=url) item.setUniqueIDs(self.ids) if control.setting('disable.player.art') == 'true': for k in ('clearart', 'clearlogo', 'discart'): meta.pop(k, None) if self.media_type == 'episode': if control.setting('disable.player.art') == 'true': item.setArt({ 'thumb': thumb, 'tvshow.poster': season_poster, 'season.poster': season_poster, 'tvshow.fanart': fanart }) else: item.setArt({ 'tvshow.clearart': clearart, 'tvshow.clearlogo': clearlogo, 'tvshow.discart': discart, 'thumb': thumb, 'tvshow.poster': season_poster, 'season.poster': season_poster, 'tvshow.fanart': fanart }) else: if control.setting('disable.player.art') == 'true': item.setArt({ 'thumb': thumb, 'poster': poster, 'fanart': fanart }) else: item.setArt({ 'clearart': clearart, 'clearlogo': clearlogo, 'discart': discart, 'thumb': thumb, 'poster': poster, 'fanart': fanart }) if 'castandart' in meta: item.setCast(meta.get('castandart', '')) item.setInfo(type='video', infoLabels=control.metadataClean(meta)) if 'plugin' not in control.infoLabel( 'Container.PluginName') or select != '1': control.busy() control.resolve(int(argv[1]), True, item) elif select == '1': control.busy() control.player.play(url, item) control.homeWindow.setProperty('script.trakt.ids', jsdumps(self.ids)) self.keepAlive() control.homeWindow.clearProperty('script.trakt.ids') except: log_utils.error() return control.cancelPlayback()
def play_source(self, title, year, season, episode, imdb, tvdb, url, meta, select=None): try: if url is None: control.cancelPlayback() raise Exception control.sleep(200) self.media_type = 'movie' if season is None or episode is None else 'episode' self.title = title self.year = str(year) if self.media_type == 'movie': self.name = quote_plus(title) + quote_plus(' (%s)' % self.year) self.season = None self.episode = None elif self.media_type == 'episode': self.name = quote_plus(title) + quote_plus( ' S%02dE%02d' % (int(season), int(episode))) self.season = '%01d' % int(season) self.episode = '%01d' % int(episode) self.name = unquote_plus( self.name) # this looks dumb, quote to only unquote? self.DBID = None self.imdb = imdb if imdb is not None else '0' self.tvdb = tvdb if tvdb is not None else '0' self.ids = {'imdb': self.imdb, 'tvdb': self.tvdb} self.ids = dict( (k, v) for k, v in self.ids.iteritems() if v != '0') self.meta = meta self.offset = Bookmarks().get(self.name, self.year) item = control.item(path=url) ## - compare meta received to database and use largest(eventually switch to a request to fetch missing db meta for item) self.imdb_user = control.setting('imdb.user').replace('ur', '') self.tmdb_key = control.setting('tm.user') if self.tmdb_key == '' or self.tmdb_key is None: self.tmdb_key = '3320855e65a9758297fec4f7c9717698' self.tvdb_key = 'N1I4U1paWDkwVUE5WU1CVQ==' if self.media_type == 'episode': self.user = str(self.imdb_user) + str(self.tvdb_key) else: self.user = str(self.tmdb_key) self.lang = control.apiLanguage()['tvdb'] items = [{ 'imdb': imdb, 'tvdb': tvdb }] # need to add tmdb but it's not passed as of now items_ck = copy.deepcopy(items) meta1 = meta meta2 = metacache.fetch(items, self.lang, self.user)[0] if meta1 is not None: if len(meta2) > len(meta1): meta = meta2 else: meta = meta1 else: meta = meta2 if meta2 != items_ck[0] else meta1 ################## poster, thumb, season_poster, fanart, banner, clearart, clearlogo, discart, meta = self.getMeta( meta) if self.media_type == 'episode': self.episodeIDS = meta.get('episodeIDS', '0') item.setUniqueIDs(self.episodeIDS) if control.setting('disable.player.art') == 'true': item.setArt({ 'thumb': thumb, 'tvshow.poster': season_poster, 'season.poster': season_poster, 'tvshow.fanart': fanart }) else: item.setArt({ 'tvshow.clearart': clearart, 'tvshow.clearlogo': clearlogo, 'tvshow.discart': discart, 'thumb': thumb, 'tvshow.poster': season_poster, 'season.poster': season_poster, 'tvshow.fanart': fanart }) else: item.setUniqueIDs(self.ids) if control.setting('disable.player.art') == 'true': item.setArt({ 'thumb': thumb, 'poster': poster, 'fanart': fanart }) else: item.setArt({ 'clearart': clearart, 'clearlogo': clearlogo, 'discart': discart, 'thumb': thumb, 'poster': poster, 'fanart': fanart }) if 'castandart' in meta: item.setCast(meta.get('castandart', '')) item.setInfo(type='video', infoLabels=control.metadataClean(meta)) if 'plugin' not in control.infoLabel( 'Container.PluginName') or select != '1': if control.window.getProperty('infodialogs.active'): control.closeAll() control.resolve(syshandle, True, item) elif select == '1': control.closeAll() control.player.play(url, item) self.keepAlive() control.window.setProperty('script.trakt.ids', json.dumps(self.ids)) control.window.clearProperty('script.trakt.ids') except: log_utils.error() return control.cancelPlayback()
def play_source(self, title, year, season, episode, imdb, tvdb, url, meta, select=None): try: if url is None: control.cancelPlayback() raise Exception control.sleep(200) self.media_type = 'movie' if season is None or episode is None else 'episode' self.title = title self.year = str(year) if self.media_type == 'movie': self.name = urllib.quote_plus(title) + urllib.quote_plus( ' (%s)' % self.year) self.season = None self.episode = None elif self.media_type == 'episode': self.name = urllib.quote_plus(title) + urllib.quote_plus( ' S%02dE%02d' % (int(season), int(episode))) self.season = '%01d' % int(season) self.episode = '%01d' % int(episode) self.name = urllib.unquote_plus(self.name) self.DBID = None self.imdb = imdb if imdb is not None else '0' self.tvdb = tvdb if tvdb is not None else '0' self.ids = {'imdb': self.imdb, 'tvdb': self.tvdb} self.ids = dict( (k, v) for k, v in self.ids.iteritems() if v != '0') self.meta = meta self.offset = Bookmarks().get(self.name, self.year) poster, thumb, season_poster, fanart, banner, clearart, clearlogo, discart, meta = self.getMeta( meta) item = control.item(path=url) if self.media_type == 'episode': if control.setting('disable.player.art') == 'true': item.setArt({ 'thumb': thumb, 'tvshow.poster': season_poster, 'season.poster': season_poster, 'tvshow.fanart': fanart }) else: item.setArt({ 'tvshow.clearart': clearart, 'tvshow.clearlogo': clearlogo, 'tvshow.discart': discart, 'thumb': thumb, 'tvshow.poster': season_poster, 'season.poster': season_poster, 'tvshow.fanart': fanart }) else: if control.setting('disable.player.art') == 'true': item.setArt({ 'thumb': thumb, 'poster': poster, 'fanart': fanart }) else: item.setArt({ 'clearart': clearart, 'clearlogo': clearlogo, 'discart': discart, 'thumb': thumb, 'poster': poster, 'fanart': fanart }) if self.media_type == 'episode': self.episodeIDS = meta.get('episodeIDS', '0') item.setUniqueIDs(self.episodeIDS) else: item.setUniqueIDs(self.ids) item.setInfo(type='video', infoLabels=control.metadataClean(meta)) if self.media_type == 'episode': if ('plugin' not in control.infoLabel('Container.PluginName') or control.setting('enable.upnext') == 'true' or control.setting('hosts.mode') == '0') or select != '1': if control.window.getProperty('infodialogs.active'): control.closeAll() control.resolve(syshandle, True, item) elif (control.setting('enable.upnext') == 'false' and control.setting('hosts.mode') == '1') or select == '1': control.closeAll() control.player.play(url, item) elif self.media_type == 'movie': if ('plugin' not in control.infoLabel('Container.PluginName') or control.setting('hosts.mode') == '0') or select != '1': if control.window.getProperty('infodialogs.active'): control.closeAll() control.resolve(syshandle, True, item) elif control.setting('hosts.mode') == '1' or select == '1': control.closeAll() control.player.play(url, item) self.keepAlive() control.window.setProperty('script.trakt.ids', json.dumps(self.ids)) control.window.clearProperty('script.trakt.ids') except: import traceback traceback.print_exc() return control.cancelPlayback()
def play_source(self, title, year, season, episode, imdb, tvdb, url, meta, select=None): try: if url is None: control.cancelPlayback() raise Exception control.sleep(200) self.media_type = 'movie' if season is None or episode is None else 'episode' self.title = title self.year = str(year) if self.media_type == 'movie': self.name = urllib.quote_plus(title) + urllib.quote_plus( ' (%s)' % self.year) self.season = None self.episode = None elif self.media_type == 'episode': self.name = urllib.quote_plus(title) + urllib.quote_plus( ' S%02dE%02d' % (int(season), int(episode))) self.season = '%01d' % int(season) self.episode = '%01d' % int(episode) self.name = urllib.unquote_plus(self.name) self.DBID = None self.imdb = imdb if imdb is not None else '0' self.tvdb = tvdb if tvdb is not None else '0' self.ids = {'imdb': self.imdb, 'tvdb': self.tvdb} self.ids = dict( (k, v) for k, v in self.ids.iteritems() if v != '0') self.meta = meta self.offset = Bookmarks().get(self.name, self.year) poster, thumb, season_poster, fanart, banner, clearart, clearlogo, discart, meta = self.getMeta( meta) item = control.item(path=url) if self.media_type == 'episode': self.episodeIDS = meta.get('episodeIDS', '0') item.setUniqueIDs(self.episodeIDS) if control.setting('disable.player.art') == 'true': item.setArt({ 'thumb': thumb, 'tvshow.poster': season_poster, 'season.poster': season_poster, 'tvshow.fanart': fanart }) else: item.setArt({ 'tvshow.clearart': clearart, 'tvshow.clearlogo': clearlogo, 'tvshow.discart': discart, 'thumb': thumb, 'tvshow.poster': season_poster, 'season.poster': season_poster, 'tvshow.fanart': fanart }) else: item.setUniqueIDs(self.ids) if control.setting('disable.player.art') == 'true': item.setArt({ 'thumb': thumb, 'poster': poster, 'fanart': fanart }) else: item.setArt({ 'clearart': clearart, 'clearlogo': clearlogo, 'discart': discart, 'thumb': thumb, 'poster': poster, 'fanart': fanart }) # self.tvdb_key = 'N1I4U1paWDkwVUE5WU1CVQ==' # self.imdb_user = control.setting('imdb.user').replace('ur', '') # self.user = str(self.imdb_user) + str(self.tvdb_key) # self.lang = control.apiLanguage()['tvdb'] # items = [{'imdb': imdb, 'tvdb': tvdb}] # list = metacache.fetch(items, self.lang, self.user) # if 'castandart' in str(list): # item.setCast(list[0].get('castandart', '')) # test = control.infoLabel('ListItem.thumb') # log_utils.log('thumb = %s' % test, __name__, log_utils.LOGDEBUG) if 'castandart' in meta: item.setCast(meta.get('castandart', '')) item.setInfo(type='video', infoLabels=control.metadataClean(meta)) if 'plugin' not in control.infoLabel( 'Container.PluginName') or select != '1': if control.window.getProperty('infodialogs.active'): control.closeAll() control.resolve(syshandle, True, item) elif select == '1': control.closeAll() control.player.play(url, item) self.keepAlive() control.window.setProperty('script.trakt.ids', json.dumps(self.ids)) control.window.clearProperty('script.trakt.ids') except: log_utils.error() return control.cancelPlayback()