def addCategoryItem(name, action, image, isFolder=True): u = '%s?action=%s' % (sys.argv[0], str(action)) image = control.addonInfo('path') + '/resources/media/phstreams/' + image item = control.item(name, iconImage=image, thumbnailImage=image) item.addContextMenuItems([], replaceItems=False) item.setProperty('Fanart_Image', control.addonInfo('fanart')) control.addItem(handle=int(sys.argv[1]), url=u, listitem=item, isFolder=isFolder)
def tvshows(tvshowtitle, imdb, tvdb, season, watched): control.busy() try: import sys,xbmc if not trakt.getTraktIndicatorsInfo() == False: raise Exception() from metahandler import metahandlers from resources.lib.indexers import episodes metaget = metahandlers.MetaData(preparezip=False) name = control.addonInfo('name') dialog = control.progressDialogBG dialog.create(str(name), str(tvshowtitle)) dialog.update(0, str(name), str(tvshowtitle)) metaget.get_meta('tvshow', name='', imdb_id=imdb) items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, '0', idx=False) try: items = [i for i in items if int('%01d' % int(season)) == int('%01d' % int(i['season']))] except: pass items = [{'label': '%s S%02dE%02d' % (tvshowtitle, int(i['season']), int(i['episode'])), 'season': int('%01d' % int(i['season'])), 'episode': int('%01d' % int(i['episode']))} for i in items] for i in range(len(items)): if xbmc.abortRequested == True: return sys.exit() dialog.update(int((100 / float(len(items))) * i), str(name), str(items[i]['label'])) season, episode = items[i]['season'], items[i]['episode'] metaget.get_episode_meta('', imdb_id=imdb, season=season, episode=episode) metaget.change_watched('episode', '', imdb_id=imdb, season=season, episode=episode, watched=int(watched)) try: dialog.close() except: pass except: try: dialog.close() except: pass try: if trakt.getTraktIndicatorsInfo() == False: raise Exception() if season: from resources.lib.indexers import episodes items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, season, idx=False) items = [(int(i['season']), int(i['episode'])) for i in items] items = [i[1] for i in items if int('%01d' % int(season)) == int('%01d' % i[0])] for i in items: if int(watched) == 7: trakt.markEpisodeAsWatched(tvdb, season, i) else: trakt.markEpisodeAsNotWatched(tvdb, season, i) else: if int(watched) == 7: trakt.markTVShowAsWatched(tvdb) else: trakt.markTVShowAsNotWatched(tvdb) trakt.cachesyncTVShows() except: pass control.refresh()
def __init__(self): self.library_folder = os.path.join( control.transPath(control.setting('library.tv')), '') self.library_setting = control.setting('library.update') or 'true' self.include_unknown = control.setting( 'library.include_unknown') or 'true' self.property = '%s_service_property' % control.addonInfo( 'name').lower() self.datetime = (datetime.datetime.utcnow() - datetime.timedelta(hours=5)) self.date = (self.datetime - datetime.timedelta(hours=24)).strftime('%Y%m%d') self.infoDialog = False
def addDirectoryItem(name, url, action, image, image2, fanart, audio, content, data, tvshow='0', totalItems=0, isFolder=True): if not str(image).lower().startswith('http'): image = control.addonInfo('icon') if not str(image2).lower().startswith('http'): image2 = control.addonInfo('icon') if not str(fanart).lower().startswith('http'): fanart = control.addonInfo('fanart') if content in ['movies', 'episodes']: playable = 'true' else: playable = 'false' sysaddon = sys.argv[0] u = '%s?name=%s&url=%s&audio=%s&image=%s&fanart=%s&playable=%s&tvshow=%s&content=%s&action=%s' % ( sysaddon, urllib.quote_plus(name), urllib.quote_plus(url), urllib.quote_plus(audio), urllib.quote_plus(image), urllib.quote_plus(fanart), urllib.quote_plus(playable), str(tvshow), str(content), str(action)) cm = [] if content in ['movies', 'tvshows']: data.update({ 'trailer': '%s?action=trailer&name=%s' % (sysaddon, urllib.quote_plus(name)) }) cm.append((control.lang(30707).encode('utf-8'), 'RunPlugin(%s?action=trailer&name=%s)' % (sysaddon, urllib.quote_plus(name)))) if not 'plot' in data: data.update({'plot': control.lang(30706).encode('utf-8')}) if content == 'movies': cm.append((control.lang(30708).encode('utf-8'), 'XBMC.Action(Info)')) elif content in ['tvshows', 'seasons']: cm.append((control.lang(30709).encode('utf-8'), 'XBMC.Action(Info)')) elif content == 'episodes': cm.append((control.lang(30710).encode('utf-8'), 'XBMC.Action(Info)')) if content == 'movies' and not isFolder == True: downloadFile = name try: downloadFile = '%s (%s)' % (data['title'], data['year']) except: pass cm.append((control.lang(30722).encode('utf-8'), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(downloadFile), urllib.quote_plus(url), urllib.quote_plus(image)))) elif content == 'episodes' and not isFolder == True: downloadFile = name try: downloadFile = '%s S%02dE%02d' % ( data['tvshowtitle'], int(data['season']), int(data['episode'])) except: pass cm.append((control.lang(30722).encode('utf-8'), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(downloadFile), urllib.quote_plus(url), urllib.quote_plus(image)))) if content == 'movies': cm.append((control.lang(30711).encode('utf-8'), 'RunPlugin(%s?action=addView&content=movies)' % sysaddon)) elif content == 'tvshows': cm.append((control.lang(30712).encode('utf-8'), 'RunPlugin(%s?action=addView&content=tvshows)' % sysaddon)) elif content == 'seasons': cm.append((control.lang(30713).encode('utf-8'), 'RunPlugin(%s?action=addView&content=seasons)' % sysaddon)) elif content == 'episodes': cm.append((control.lang(30714).encode('utf-8'), 'RunPlugin(%s?action=addView&content=episodes)' % sysaddon)) item = control.item(name, iconImage='DefaultFolder.png', thumbnailImage=image) try: item.setArt({ 'poster': image2, 'tvshow.poster': image2, 'season.poster': image2, 'banner': image, 'tvshow.banner': image, 'season.banner': image }) except: pass item.addContextMenuItems(cm, replaceItems=False) item.setProperty('Fanart_Image', fanart) if playable == 'true': item.setProperty('IsPlayable', 'true') item.setInfo(type='Video', infoLabels=data) control.addItem(handle=int(sys.argv[1]), url=u, listitem=item, totalItems=totalItems, isFolder=isFolder)
def keepPlaybackAlive(self): pname = '%s.player.overlay' % control.addonInfo('id') control.window.clearProperty(pname) if self.content == 'movie': overlay = playcount.getMovieOverlay(playcount.getMovieIndicators(), self.imdb) elif self.content == 'episode': overlay = playcount.getEpisodeOverlay(playcount.getTVShowIndicators(), self.imdb, self.tvdb, self.season, self.episode) else: overlay = '6' for i in range(0, 240): if self.isPlayingVideo(): break xbmc.sleep(1000) if overlay == '7': while self.isPlayingVideo(): try: self.totalTime = self.getTotalTime() self.currentTime = self.getTime() except: pass xbmc.sleep(2000) elif self.content == 'movie': while self.isPlayingVideo(): try: self.totalTime = self.getTotalTime() self.currentTime = self.getTime() watcher = (self.currentTime / self.totalTime >= .9) property = control.window.getProperty(pname) if watcher == True and not property == '7': control.window.setProperty(pname, '7') playcount.markMovieDuringPlayback(self.imdb, '7') elif watcher == False and not property == '6': control.window.setProperty(pname, '6') playcount.markMovieDuringPlayback(self.imdb, '6') except: pass xbmc.sleep(2000) elif self.content == 'episode': while self.isPlayingVideo(): try: self.totalTime = self.getTotalTime() self.currentTime = self.getTime() watcher = (self.currentTime / self.totalTime >= .9) property = control.window.getProperty(pname) if watcher == True and not property == '7': control.window.setProperty(pname, '7') playcount.markEpisodeDuringPlayback(self.imdb, self.tvdb, self.season, self.episode, '7') elif watcher == False and not property == '6': control.window.setProperty(pname, '6') playcount.markEpisodeDuringPlayback(self.imdb, self.tvdb, self.season, self.episode, '6') except: pass xbmc.sleep(2000) control.window.clearProperty(pname)
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import time import cProfile import StringIO import pstats import json import xbmc from ptw.libraries import control from xbmc import LOGDEBUG, LOGERROR, LOGFATAL, LOGINFO, LOGNONE, LOGNOTICE, LOGSEVERE, LOGWARNING # @UnusedImport name = control.addonInfo('name') def log(msg, level=LOGDEBUG): req_level = level # override message level to force logging when addon logging turned on if control.setting('addon_debug') == 'true' and level == LOGDEBUG: level = LOGNOTICE try: if isinstance(msg, unicode): msg = '%s (ENCODED)' % (msg.encode('utf-8')) xbmc.log('[%s] %s' % (name, msg), level) except Exception as e:
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ''' import re, os, sys, urllib, urllib2, urlparse, time, threading from ptw.libraries import control from ptw.libraries import cache import pyxbmct.addonwindow as pyxbmct downloadPath = control.setting('downloadPath') property = control.addonInfo('id') + '.downloader' def downloader(): thumb = control.addonThumb() fanart = control.addonFanart() status = control.window.getProperty(property + '.status') if not downloadPath == '': item = control.item('[COLOR FF00b8ff]Downloads[/COLOR]', iconImage=thumb, thumbnailImage=thumb) item.addContextMenuItems([], replaceItems=True) item.setProperty('fanart_image', fanart)
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. ''' import re,os,sys,urllib,json,datetime,subprocess from jars import FuckNeulionClient from ptw.libraries import control from ptw.libraries import client import xbmc addonPath = control.addonPath addonFanart = control.addonInfo('fanart') addonIcon = os.path.join(addonPath, 'resources/media/nhlcom/hockey.jpg') jarFile = os.path.join(addonPath, 'jars/FuckNeulionV2.jar') def nhlDirectory(): dt = procTimezone(5) datex = int(dt.strftime('%Y%m%d')) url = 'http://live.nhl.com/GameData/SeasonSchedule-20152016.json' result = client.request(url) items = json.loads(result) items = sorted(items, key=lambda k: k['est']) addDirectoryItem(control.lang(30751).encode('utf-8'), 'Scoreboard', 'nhlScoreboard', '0', '0')
def tvshows(tvshowtitle, year, imdb, tvdb, season, watched): traktMode = False if trakt.getTraktCredentials() == False else True watched = int(watched) try: if traktMode == True: raise Exception() from metahandler import metahandlers from resources.lib.indexers import episodes metaget = metahandlers.MetaData(preparezip=False) dialog = control.progressDialog dialog.create(control.addonInfo('name'), str(tvshowtitle)) dialog.update(0, str(tvshowtitle), control.lang(30451).encode('utf-8') + '...') metaget.get_meta('tvshow', '', imdb_id=imdb) items = episodes.episodes().get(tvshowtitle, year, imdb, '0', tvdb, '0', idx=False) try: items = [ i for i in items if int('%01d' % int(season)) == int('%01d' % int(i['season'])) ] except: pass items = [{ 'name': i['name'], 'season': int('%01d' % int(i['season'])), 'episode': int('%01d' % int(i['episode'])) } for i in items] for i in range(len(items)): if xbmc.abortRequested == True: return sys.exit() if dialog.iscanceled(): return dialog.close() dialog.update(int((100 / float(len(items))) * i), str(tvshowtitle), str(items[i]['name'])) season, episode = items[i]['season'], items[i]['episode'] metaget.get_episode_meta('', imdb, season, episode) metaget.change_watched('episode', '', imdb, season=season, episode=episode, year='', watched=watched) try: dialog.close() except: pass except: try: dialog.close() except: pass try: if traktMode == False: raise Exception() if watched == 7: trakt.markTVShowAsWatched(tvdb) else: trakt.markTVShowAsNotWatched(tvdb) trakt.syncTVShows() except: pass control.refresh()