def onPlayBackStarted(self): for i in range(0, 500): if not self.isPlayingVideo(): control.sleep(100) bookmark = bookmarks.get(self.name, str(self.year)) self.offset = 0.0 if not bookmark.offset == 0.0 and not self.getTotalTime() == 0.0: self.offset = self.getTotalTime() * (bookmark.offset / 100) if not self.offset == 0.0: self.seekTime(float(self.offset)) subtitles().get(self.name, self.imdb, self.season, self.episode) self.idleForPlayback()
def run(self, title, year, season, episode, imdb, tmdb, url, meta): try: control.sleep(200) self.totalTime = 0 self.currentTime = 0 self.content = 'movie' if season == None or episode == None else 'episode' self.title = title self.year = year self.name = urllib_parse.quote_plus( title) + urllib_parse.quote_plus( ' (%s)' % year ) if self.content == 'movie' else urllib_parse.quote_plus( title) + urllib_parse.quote_plus( ' S%01dE%01d' % (int(season), int(episode))) self.name = urllib_parse.unquote_plus(self.name) self.season = '%01d' % int( season) if self.content == 'episode' else None self.episode = '%01d' % int( episode) if self.content == 'episode' else None self.DBID = None self.imdb = imdb if not imdb == None else '0' self.tmdb = tmdb if not tmdb == None else '0' self.ids = {'imdb': self.imdb, 'tmdb': self.tmdb} self.ids = dict( (k, v) for k, v in six.iteritems(self.ids) if not v == '0') self.offset = bookmarks.get(self.content, imdb, season, episode) poster, thumb, fanart, clearlogo, clearart, discart, meta = self.getMeta( meta) item = control.item(path=url) if self.content == 'movie': item.setArt({ 'icon': thumb, 'thumb': thumb, 'poster': poster, 'fanart': fanart, 'clearlogo': clearlogo, 'clearart': clearart, 'discart': discart }) else: item.setArt({ 'icon': thumb, 'thumb': thumb, 'tvshow.poster': poster, 'season.poster': poster, 'fanart': fanart }) item.setInfo(type='video', infoLabels=control.metadataClean(meta)) if 'plugin' in control.infoLabel('Container.PluginName'): control.player.play(url, item) control.resolve(int(sys.argv[1]), True, item) control.window.setProperty('script.trakt.ids', json.dumps(self.ids)) self.keepPlaybackAlive() control.window.clearProperty('script.trakt.ids') except: return
def channelDirectory(self, items): if items == None or len(items) == 0: return #control.idle() ; sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart = control.addonFanart() traktCredentials = trakt.getTraktCredentialsInfo() kodiVersion = control.getKodiVersion() isPlayable = True if not 'plugin' in control.infoLabel('Container.PluginName') else False indicators = playcount.getMovieIndicators(refresh=True) if action == 'movies' else playcount.getMovieIndicators() if self.trailer_source == '0': trailerAction = 'tmdb_trailer' elif self.trailer_source == '1': trailerAction = 'yt_trailer' else: trailerAction = 'imdb_trailer' playbackMenu = control.lang(32063) if control.setting('hosts.mode') == '2' else control.lang(32064) watchedMenu = control.lang(32068) if trakt.getTraktIndicatorsInfo() == True else control.lang(32066) unwatchedMenu = control.lang(32069) if trakt.getTraktIndicatorsInfo() == True else control.lang(32067) queueMenu = control.lang(32065) traktManagerMenu = control.lang(32070) nextMenu = control.lang(32053) addToLibrary = control.lang(32551) clearProviders = control.lang(32081) findSimilar = control.lang(32100) infoMenu = control.lang(32101) for i in items: try: imdb, tmdb, title, year = i['imdb'], i['tmdb'], i['originaltitle'], i['year'] label = i['label'] if 'label' in i and not i['label'] == '0' else title label = '%s (%s)' % (label, year) if 'channel' in i: label = '[B]%s[/B] : %s' % (i['channel'].upper(), label) status = i['status'] if 'status' in i else '0' sysname = urllib_parse.quote_plus('%s (%s)' % (title, year)) systitle = urllib_parse.quote_plus(title) meta = dict((k,v) for k, v in six.iteritems(i) if not v == '0') meta.update({'imdbnumber': imdb, 'code': tmdb}) meta.update({'mediatype': 'movie'}) meta.update({'trailer': '%s?action=%s&name=%s&tmdb=%s&imdb=%s' % (sysaddon, trailerAction, systitle, tmdb, imdb)}) if not 'duration' in i: meta.update({'duration': '120'}) elif i['duration'] == '0': meta.update({'duration': '120'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass if 'castwiththumb' in i and not i['castwiththumb'] == '0': meta.pop('cast', '0') poster = i['poster'] if 'poster' in i and not i['poster'] == '0' else addonPoster meta.update({'poster': poster}) sysmeta = urllib_parse.quote_plus(json.dumps(meta)) url = '%s?action=play&title=%s&year=%s&imdb=%s&meta=%s&t=%s' % (sysaddon, systitle, year, imdb, sysmeta, self.systime) sysurl = urllib_parse.quote_plus(url) #path = '%s?action=play&title=%s&year=%s&imdb=%s' % (sysaddon, systitle, year, imdb) cm = [] cm.append((findSimilar, 'Container.Update(%s?action=movies&url=%s)' % (sysaddon, urllib_parse.quote_plus(self.related_link % tmdb)))) cm.append(('[I]Cast[/I]', 'RunPlugin(%s?action=moviecredits&tmdb=%s&status=%s)' % (sysaddon, tmdb, status))) cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) try: overlay = int(playcount.getMovieOverlay(indicators, imdb)) if overlay == 7: cm.append((unwatchedMenu, 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=6)' % (sysaddon, imdb))) meta.update({'playcount': 1, 'overlay': 7}) else: cm.append((watchedMenu, 'RunPlugin(%s?action=moviePlaycount&imdb=%s&query=7)' % (sysaddon, imdb))) meta.update({'playcount': 0, 'overlay': 6}) except: pass if traktCredentials == True: cm.append((traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&imdb=%s&content=movie)' % (sysaddon, sysname, imdb))) cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta))) if kodiVersion < 17: cm.append((infoMenu, 'Action(Info)')) cm.append((addToLibrary, 'RunPlugin(%s?action=movieToLibrary&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s)' % (sysaddon, sysname, systitle, year, imdb, tmdb))) cm.append(('[I]Scrape Filterless[/I]', 'RunPlugin(%s?action=playUnfiltered&title=%s&year=%s&imdb=%s&meta=%s&t=%s)' % (sysaddon, systitle, year, imdb, sysmeta, self.systime))) cm.append((clearProviders, 'RunPlugin(%s?action=clearCacheProviders)' % sysaddon)) try: item = control.item(label=label, offscreen=True) except: item = control.item(label=label) art = {} art.update({'icon': poster, 'thumb': poster, 'poster': poster}) fanart = i['fanart'] if 'fanart' in i and not i['fanart'] == '0' else addonFanart if self.settingFanart == 'true': art.update({'fanart': fanart}) else: art.update({'fanart': addonFanart}) if 'banner' in i and not i['banner'] == '0': art.update({'banner': i['banner']}) else: art.update({'banner': addonBanner}) if 'clearlogo' in i and not i['clearlogo'] == '0': art.update({'clearlogo': i['clearlogo']}) if 'clearart' in i and not i['clearart'] == '0': art.update({'clearart': i['clearart']}) if 'landscape' in i and not i['landscape'] == '0': landscape = i['landscape'] else: landscape = fanart art.update({'landscape': landscape}) if 'discart' in i and not i['discart'] == '0': art.update({'discart': i['discart']}) item.setArt(art) item.addContextMenuItems(cm) if isPlayable: item.setProperty('IsPlayable', 'true') castwiththumb = i.get('castwiththumb') if castwiththumb and not castwiththumb == '0': if kodiVersion >= 18: item.setCast(castwiththumb) else: cast = [(p['name'], p['role']) for p in castwiththumb] meta.update({'cast': cast}) offset = bookmarks.get('movie', imdb, '', '', True) if float(offset) > 120: percentPlayed = int(float(offset) / float(meta['duration']) * 100) item.setProperty('resumetime', str(offset)) item.setProperty('percentplayed', str(percentPlayed)) item.setProperty('imdb_id', imdb) item.setProperty('tmdb_id', tmdb) try: item.setUniqueIDs({'imdb': imdb, 'tmdb': tmdb}) except: pass item.setInfo(type='Video', infoLabels = control.metadataClean(meta)) video_streaminfo = {'codec': 'h264'} item.addStreamInfo('video', video_streaminfo) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False) except: log_utils.log('channels_dir', 1) pass control.content(syshandle, 'files') control.directory(syshandle, cacheToDisc=True)