def range(self, url): control.idle() yes = control.yesnoDialog(control.lang(30425).encode("utf-8"), "", "") if not yes: return if not control.condVisibility("Window.IsVisible(infodialog)") and not control.condVisibility("Player.HasVideo"): control.infoDialog(control.lang(30421).encode("utf-8"), time=10000000) self.infoDialog = True from resources.lib.indexers import movies items = movies.movies().get(url, idx=False) if items == None: items = [] for i in items: try: if xbmc.abortRequested == True: return sys.exit() self.add(i["name"], i["title"], i["year"], i["imdb"], range=True) except: pass if self.infoDialog == True: control.infoDialog(control.lang(30423).encode("utf-8"), time=1) if self.library_setting == "true" and not control.condVisibility("Library.IsScanningVideo"): control.execute("UpdateLibrary(video)")
def clear(table=None): try: control.idle() if table == None: table = ['rel_list', 'rel_lib'] elif not type(table) == list: table = [table] yes = control.yesnoDialog(control.lang(30401).encode('utf-8'), '', '') if not yes: return dbcon = database.connect(control.cacheFile) dbcur = dbcon.cursor() for t in table: try: dbcur.execute("DROP TABLE IF EXISTS %s" % t) dbcur.execute("VACUUM") dbcon.commit() except: pass except: pass import xbmcgui xbmcgui.Dialog().notification('[COLOR ffff0000]StreamHub[/COLOR]','Process Complete')
def range(self, url): control.idle() yes = control.yesnoDialog(control.lang(32555).encode('utf-8'), '', '') if not yes: return if not control.condVisibility('Window.IsVisible(infodialog)') and not control.condVisibility('Player.HasVideo'): control.infoDialog(control.lang(32552).encode('utf-8'), time=10000000) self.infoDialog = True from resources.lib.indexers import tvshows items = tvshows.tvshows().get(url, idx=False) if items == None: items = [] for i in items: try: if xbmc.abortRequested == True: return sys.exit() self.add(i['title'], i['year'], i['imdb'], i['tvdb'], range=True) except: pass if self.infoDialog == True: control.infoDialog(control.lang(32554).encode('utf-8'), time=1) if self.library_setting == 'true' and not control.condVisibility('Library.IsScanningVideo'): control.execute('UpdateLibrary(video)')
def views(self): try: control.idle() items = [ (control.lang(32001).encode('utf-8'), 'movies'), (control.lang(32002).encode('utf-8'), 'tvshows'), (control.lang(32054).encode('utf-8'), 'seasons'), (control.lang(32038).encode('utf-8'), 'episodes') ] select = control.selectDialog([i[0] for i in items], control.lang(32049).encode('utf-8')) if select == -1: return content = items[select][1] title = control.lang(32059).encode('utf-8') url = '%s?action=addView&content=%s' % (sys.argv[0], content) poster, banner, fanart = control.addonPoster(), control.addonBanner(), control.addonFanart() item = control.item(label=title) item.setInfo(type='Video', infoLabels = {'title': title}) item.setArt({'icon': poster, 'thumb': poster, 'poster': poster, 'banner': banner}) item.setProperty('Fanart_Image', fanart) control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False) control.content(int(sys.argv[1]), content) control.directory(int(sys.argv[1]), cacheToDisc=True) from resources.lib.modules import cache views.setView(content, {}) except: return
def clear(table=None): try: control.idle() if table == None: table = ['rel_list', 'rel_lib'] elif not type(table) == list: table = [table] yes = control.yesnoDialog('Are You Sure?', '', '') if not yes: return dbcon = database.connect(control.cacheFile) dbcur = dbcon.cursor() for t in table: try: dbcur.execute("DROP TABLE IF EXISTS %s" % t) dbcur.execute("VACUUM") dbcon.commit() except: pass control.infoDialog('Cache.db Cleared') xbmc.executebuiltin('Container.Refresh()') except: pass
def clearCache(self): control.idle() yes = control.yesnoDialog(control.lang(32056).encode('utf-8'), '', '') if not yes: return from resources.lib.modules import cache cache.cache_clear() control.infoDialog(control.lang(32057).encode('utf-8'), sound=True, icon='INFO')
def clear(table=None): try: control.idle() if table == None: table = ['rel_list', 'rel_lib'] elif not type(table) == list: table = [table] yes = control.yesnoDialog(control.lang(30401).encode('utf-8'), '', '') if not yes: return dbcon = database.connect(control.cacheFile) dbcur = dbcon.cursor() for t in table: try: dbcur.execute("DROP TABLE IF EXISTS %s" % t) dbcur.execute("VACUUM") dbcon.commit() except: pass nanscrapers.clear_cache() control.infoDialog(control.lang(30402).encode('utf-8')) except: pass
def idleForPlayback(self): for i in range(0, 200): if control.condVisibility('Window.IsActive(busydialog)') == 1: control.idle(); else: break; control.sleep(100);
def run(self, url): control.idle() title = control.infoLabel('ListItem.Label') image = control.infoLabel('ListItem.Icon') item = control.item(path=url, iconImage=image, thumbnailImage=image) item.setInfo(type='Video', infoLabels = {'title': title}) control.player.play(url, item) for i in range(0, 240): if self.isPlayingVideo(): break control.sleep(1000)
def addDirectory(self, items, queue=False): if items == None or len(items) == 0: control.idle() ; sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonFanart, addonThumb, artPath = control.addonFanart(), control.addonThumb(), control.artPath() queueMenu = control.lang(32065).encode('utf-8') playRandom = control.lang(32535).encode('utf-8') addToLibrary = control.lang(32551).encode('utf-8') for i in items: try: name = i['name'] if i['image'].startswith('http'): thumb = i['image'] elif not artPath == None: thumb = os.path.join(artPath, i['image']) else: thumb = addonThumb url = '%s?action=%s' % (sysaddon, i['action']) try: url += '&url=%s' % urllib.quote_plus(i['url']) except: pass cm = [] cm.append(('Settings', 'RunPlugin(%s?action=openSettings&query=0.0)' % sysaddon)) cm.append((playRandom, 'RunPlugin(%s?action=random&rtype=movie&url=%s)' % (sysaddon, urllib.quote_plus(i['url'])))) if queue == True: cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) try: cm.append((addToLibrary, 'RunPlugin(%s?action=moviesToLibrary&url=%s)' % (sysaddon, urllib.quote_plus(i['context'])))) except: pass item = control.item(label=name) item.setArt({'icon': thumb, 'thumb': thumb}) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.addContextMenuItems(cm) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: pass control.content(syshandle, 'addons') control.directory(syshandle, cacheToDisc=True)
def search(self): try: control.idle() k = control.keyboard('', 'Zoeken') ; k.doModal() q = k.getText() if k.isConfirmed() else None if (q == None or q == ''): return url = self.search_link % (urllib.quote_plus(q)) url = '%s?action=search_results&url=%s' % (sys.argv[0], urllib.quote_plus(url)) control.execute('Container.Update(%s)' % url) except: return
def person(self): try: control.idle() t = control.lang(32010).encode('utf-8') k = control.keyboard('', t) ; k.doModal() q = k.getText() if k.isConfirmed() else None if (q == None or q == ''): return url = self.persons_link + urllib.quote_plus(q) url = '%s?action=moviePersons&url=%s' % (sys.argv[0], urllib.quote_plus(url)) control.execute('Container.Update(%s)' % url) except: return
def ACstream(url): try: control.idle() result = client.request(url) stage1 = re.compile('url: "(.+?)",').findall(result)[0] stage1 = stage1.encode('utf-8') stage2 = re.compile("data: '(.+?)',").findall(result)[0] results = urllib2.Request(stage1,stage2) results.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36') response = urllib2.urlopen(results) link=response.read() response.close() url = re.compile('<a href="(.+?)" target="_blank" rel="nofollow">.+?</a>').findall(link)[-1] player().run(url) except: return
def addDirectory(self, items, queue=False, isFolder=True): if items == None or len(items) == 0: control.idle() ; sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonFanart, addonThumb, artPath = control.addonFanart(), control.addonThumb(), control.artPath() queueMenu = control.lang(32065).encode('utf-8') playRandom = control.lang(32535).encode('utf-8') addToLibrary = control.lang(32551).encode('utf-8') for i in items: try: name = i['name'] if i['image'].startswith('http'): thumb = i['image'] elif not artPath == None: thumb = os.path.join(artPath, i['image']) else: thumb = addonThumb item = control.item(label=name) if isFolder: url = '%s?action=%s' % (sysaddon, i['action']) try: url += '&url=%s' % urllib.quote_plus(i['url']) except: pass item.setProperty('IsPlayable', 'false') else: url = '%s?action=%s' % (sysaddon, i['action']) try: url += '&url=%s' % i['url'] except: pass item.setProperty('IsPlayable', 'true') item.setInfo("mediatype", "video") item.setInfo("audio", '') item.setArt({'icon': thumb, 'thumb': thumb}) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=isFolder) except: pass control.content(syshandle, 'addons') control.directory(syshandle, cacheToDisc=True)
def clearSources(self): try: control.idle() yes = control.yesnoDialog(control.lang(30510).encode('utf-8'), '', '') if not yes: return control.makeFile(control.dataPath) dbcon = database.connect(control.providercacheFile) dbcur = dbcon.cursor() dbcur.execute("DROP TABLE IF EXISTS rel_src") dbcur.execute("VACUUM") dbcon.commit() control.infoDialog(control.lang(30511).encode('utf-8')) except: pass
def addDirectory(self, items, queue=False): if items == None or len(items) == 0: control.idle() ; sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonFanart = control.addonFanart() addonThumb = control.addonThumb() queueMenu = control.lang(32065).encode('utf-8') for i in items: try: name = i['name'] url = '%s?action=%s' % (sysaddon, i['action']) try: url += '&url=%s' % urllib.quote_plus(i['url']) except: pass cm = [] if queue == True: cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) item = control.item(label=name) if i['image'].startswith('http'): iconIcon = iconThumb = iconPoster = iconBanner = i['image'] else: iconIcon, iconThumb, iconPoster, iconBanner = interface.Icon.pathAll(icon = i['image'], default = addonThumb) item.setArt({'icon': iconIcon, 'thumb': iconThumb, 'poster': iconPoster, 'banner': iconBanner}) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.addContextMenuItems(cm) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: pass control.content(syshandle, 'addons') control.directory(syshandle, cacheToDisc=True) interface.traktApi()
def search_new(self): control.idle() t = control.lang(32010).encode('utf-8') k = control.keyboard('', t) ; k.doModal() q = k.getText() if k.isConfirmed() else None if (q == None or q == ''): return try: from sqlite3 import dbapi2 as database except: from pysqlite2 import dbapi2 as database dbcon = database.connect(control.searchFile) dbcur = dbcon.cursor() dbcur.execute("INSERT INTO furk VALUES (?,?)", (None,q)) dbcon.commit() dbcur.close() url = urllib.quote_plus(q) url = '%s?action=furkMetaSearch&url=%s' % (sys.argv[0], urllib.quote_plus(url)) control.execute('Container.Update(%s)' % url)
def person(self, query=None): try: control.idle() sysloc = [urlparse.urlparse(sys.argv[0]).netloc, 'plugin.program.super.favourites' ] sysplg = True if control.infoLabel('Container.PluginName') in sysloc else False if query == None: t = control.lang(32010).encode('utf-8') k = control.keyboard('', t) ; k.doModal() query = k.getText() if k.isConfirmed() else None if (query == None or query == '' or sysplg == False): return url = self.persons_link + urllib.quote_plus(query) url = '%s?action=moviePersons&url=%s' % (sys.argv[0], urllib.quote_plus(url)) control.execute('Container.Update(%s)' % url) except: return
def addDirectory(self, items, queue=False): if items == None or len(items) == 0: control.idle() ; sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonFanart, addonThumb, artPath = control.addonFanart(), control.addonThumb(), control.artPath() queueMenu = control.lang(32065).encode('utf-8') for i in items: try: name = i['name'] if i['image'].startswith('http://'): thumb = i['image'] elif not artPath == None: thumb = os.path.join(artPath, i['image']) else: thumb = addonThumb url = '%s?action=%s' % (sysaddon, i['action']) try: url += '&url=%s' % urllib.quote_plus(i['url']) except: pass cm = [] if queue == True: cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) item = control.item(label=name) item.setArt({'icon': thumb, 'thumb': thumb}) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.addContextMenuItems(cm) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: pass #control.do_block_check(False) control.directory(syshandle, cacheToDisc=True)
def search_new(self): control.idle() t = control.lang(32010).encode('utf-8') k = control.keyboard('', t) ; k.doModal() q = k.getText() if k.isConfirmed() else None if (q == None or q == ''): return #try: from sqlite3 import dbapi2 as database #except: from pysqlite2 import dbapi2 as database #dbcon = database.connect(control.searchFile) #dbcur = dbcon.cursor() #dbcur.execute("INSERT INTO movies VALUES (?,?)", (None,q)) #dbcon.commit() #dbcur.close() url = self.search_link + q.replace(" ", "+") #url = '%s?action=moviePage&url=%s' % (sys.argv[0], urllib.quote_plus(url)) #control.execute('Container.Update(%s)' % url) movies().get(url)
def CCstream(url): try: control.idle() url = urlparse.urljoin('http://kisscartoon.me', url) result = cloudflare.request(url) items = client.parseDOM(result,'select', attrs={'id':'selectQuality'}) items = client.parseDOM(items, 'option', ret='value') url = [] for item in items: try: u = base64.b64decode(item) u = u.encode('utf-8') if u[-3:] == 'm37': q = '1080P' elif u[-3:] == 'm22': q = '720P' elif u[-3:] == 'm18': q = '360P' else: q = 'UNKNOWN' url.append({'q': q, 'u': u}) except: pass if len(url) > 1: q = [i['q'] for i in url] u = [i['u'] for i in url] select = control.selectDialog(q) if select == -1: return url = u[select] else: url = url[0]['u'] player().run(url) except: return
def silent(self, url): control.idle() if not control.condVisibility('Window.IsVisible(infodialog)') and not control.condVisibility('Player.HasVideo'): control.infoDialog(control.lang(32552).encode('utf-8'), time=10000000) self.infoDialog = True self.silentDialog = True from resources.lib.indexers import movies items = movies.movies().get(url, idx=False) if items == None: items = [] for i in items: try: if xbmc.abortRequested == True: return sys.exit() self.add('%s (%s)' % (i['title'], i['year']), i['title'], i['year'], i['imdb'], i['tmdb'], range=True) except: pass if self.infoDialog == True: self.silentDialog = False control.infoDialog("Trakt Movies Sync Complete", time=1)
def implementsearch(): from resources.lib.modules import control; try: control.idle(); title = control.lang(32726).encode('utf-8'); kb = control.keyboard('', title); kb.doModal(); text = kb.getText() if kb.isConfirmed() else None; if (text == None or text == ''): return None; else: return text; except Exception as inst: logger.error(inst); return None;
def movieDirectory(self, items): if items == None or len(items) == 0: control.idle() ; sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting('fanart') traktCredentials = trakt.getTraktCredentialsInfo() try: isOld = False ; control.item().getArt('type') except: isOld = True isEstuary = True if 'estuary' in control.skin else False isPlayable = 'true' if not 'plugin' in control.infoLabel('Container.PluginName') else 'false' indicators = playcount.getMovieIndicators(refresh=True) if action == 'movies' else playcount.getMovieIndicators() playbackMenu = control.lang(32063).encode('utf-8') if control.setting('hosts.mode') == '2' else control.lang(32064).encode('utf-8') watchedMenu = control.lang(32068).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32066).encode('utf-8') unwatchedMenu = control.lang(32069).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32067).encode('utf-8') queueMenu = control.lang(32065).encode('utf-8') traktManagerMenu = control.lang(32070).encode('utf-8') nextMenu = control.lang(32053).encode('utf-8') for i in items: try: label = '%s (%s)' % (i['title'], i['year']) imdb, title, year = i['imdb'], i['originaltitle'], i['year'] sysname = urllib.quote_plus('%s (%s)' % (title, year)) systitle = urllib.quote_plus(title) poster, banner, fanart = i['poster'], i['banner'], i['fanart'] if banner == '0' and not fanart == '0': banner = fanart elif banner == '0' and not poster == '0': banner = poster if poster == '0': poster = addonPoster if banner == '0': banner = addonBanner meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'mediatype': 'movie'}) #meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)}) meta.update({'trailer': 'plugin://script.extendedinfo/?info=playtrailer&&id=%s' % imdb}) if 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 isEstuary == True: try: del meta['cast'] except: pass sysmeta = urllib.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.quote_plus(url) path = '%s?action=play&title=%s&year=%s&imdb=%s' % (sysaddon, systitle, year, imdb) cm = [] 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 isOld == True: cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)')) item = control.item(label=label) item.setArt({'icon': poster, 'thumb': poster, 'poster': poster, 'banner': banner}) if settingFanart == 'true' and not fanart == '0': item.setProperty('Fanart_Image', fanart) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.addContextMenuItems(cm) item.setProperty('IsPlayable', isPlayable) item.setInfo(type='Video', infoLabels = meta) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False) except: pass try: url = items[0]['next'] if url == '': raise Exception() icon = control.addonNext() url = '%s?action=moviePage&url=%s' % (sysaddon, urllib.quote_plus(url)) item = control.item(label=nextMenu) item.setArt({'icon': icon, 'thumb': icon, 'poster': icon, 'banner': icon}) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: pass control.content(syshandle, 'movies') #control.do_block_check(False) control.directory(syshandle, cacheToDisc=True) views.setView('movies', {'skin.confluence': 500})
def search_clear(): cache.delete(control.searchFile, withyes=False) control.refresh() control.idle()
def accountCheck(self): if traktCredentials == False and imdbCredentials == False: control.idle() control.infoDialog(six.ensure_str(control.lang(32042)), sound=True, icon='WARNING') sys.exit()
def clearCacheSearch(self): control.idle() if control.yesnoDialog(control.lang(32056).encode('utf-8'), '', ''): control.setSetting('tvsearch', '') control.setSetting('moviesearch', '') control.refresh()
def search_term(self, name): control.idle() url = self.search_link + urllib.quote_plus(name) url = '%s?action=moviePage&url=%s' % (sys.argv[0], urllib.quote_plus(url)) control.execute('Container.Update(%s)' % url)
def channelDirectory(self, items): if items == None or len(items) == 0: control.idle() ; sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), tools.Settings.getBoolean('interface.fanart') try: isOld = False ; control.item().getArt('type') except: isOld = True isPlayable = 'true' if not 'plugin' in control.infoLabel('Container.PluginName') else 'false' playbackMenu = control.lang(32063).encode('utf-8') if control.setting('playback.automatic.enabled') == 'true' else control.lang(32064).encode('utf-8') queueMenu = control.lang(32065).encode('utf-8') refreshMenu = control.lang(32072).encode('utf-8') for i in items: try: # [BUBBLESCODE] #label = '[B]%s[/B] : %s (%s)' % (i['channel'].upper(), i['title'], i['year']) label = '[B]%s[/B][CR]%s (%s)' % (i['channel'].upper(), i['title'], i['year']) # [/BUBBLESCODE] sysname = urllib.quote_plus('%s (%s)' % (i['title'], i['year'])) systitle = urllib.quote_plus(i['title']) imdb, year = i['imdb'], i['year'] meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'mediatype': 'movie'}) meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)}) #meta.update({'trailer': 'plugin://script.extendedinfo/?info=playtrailer&&id=%s' % imdb}) meta.update({'playcount': 0, 'overlay': 6}) try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) url = self.parameterize('%s?action=play&title=%s&year=%s&imdb=%s&meta=%s&t=%s' % (sysaddon, systitle, year, imdb, sysmeta, self.systime)) sysurl = urllib.quote_plus(url) cm = [] cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) cm.append((refreshMenu, 'RunPlugin(%s?action=refresh)' % sysaddon)) if not self.kidsOnly() and control.setting('downloads.manual.enabled') == 'true': cm.append((control.lang(33585).encode('utf-8'), 'Container.Update(%s?action=downloadsManager)' % (sysaddon))) cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta))) if isOld == True: cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)')) item = control.item(label=label) art = {} poster = '0' if poster == '0' and 'poster3' in i: poster = i['poster3'] if poster == '0' and 'poster2' in i: poster = i['poster2'] if poster == '0' and 'poster' in i: poster = i['poster'] icon = '0' if icon == '0' and 'icon3' in i: icon = i['icon3'] if icon == '0' and 'icon2' in i: icon = i['icon2'] if icon == '0' and 'icon' in i: icon = i['icon'] thumb = '0' if thumb == '0' and 'thumb3' in i: thumb = i['thumb3'] if thumb == '0' and 'thumb2' in i: thumb = i['thumb2'] if thumb == '0' and 'thumb' in i: thumb = i['thumb'] banner = '0' if banner == '0' and 'banner3' in i: banner = i['banner3'] if banner == '0' and 'banner2' in i: banner = i['banner2'] if banner == '0' and 'banner' in i: banner = i['banner'] fanart = '0' if settingFanart: if fanart == '0' and 'fanart3' in i: fanart = i['fanart3'] if fanart == '0' and 'fanart2' in i: fanart = i['fanart2'] if fanart == '0' and 'fanart' in i: fanart = i['fanart'] clearlogo = '0' if clearlogo == '0' and 'clearlogo' in i: clearlogo = i['clearlogo'] clearart = '0' if clearart == '0' and 'clearart' in i: clearart = i['clearart'] if poster == '0': poster = addonPoster if icon == '0': icon = poster if thumb == '0': thumb = poster if banner == '0': banner = addonBanner if fanart == '0': fanart = addonFanart if not poster == '0' and not poster == None: art.update({'poster' : poster}) if not icon == '0' and not icon == None: art.update({'icon' : icon}) if not thumb == '0' and not thumb == None: art.update({'thumb' : thumb}) if not banner == '0' and not banner == None: art.update({'banner' : banner}) if not clearlogo == '0' and not clearlogo == None: art.update({'clearlogo' : clearlogo}) if not clearart == '0' and not clearart == None: art.update({'clearart' : clearart}) if not fanart == '0' and not fanart == None: item.setProperty('Fanart_Image', fanart) item.setArt(art) item.addContextMenuItems(cm) item.setProperty('IsPlayable', isPlayable) item.setInfo(type='Video', infoLabels = meta) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False) except: pass control.content(syshandle, 'files') control.directory(syshandle, cacheToDisc=True)
def update(self, query=None, info='true'): if not query == None: control.idle() try: items = [] season, episode = [], [] show = [os.path.join(self.library_folder, i) for i in control.listDir(self.library_folder)[0]] for s in show: try: season += [os.path.join(s, i) for i in control.listDir(s)[0]] except: pass for s in season: try: episode.append([os.path.join(s, i) for i in control.listDir(s)[1] if i.endswith('.strm')][-1]) except: pass for file in episode: try: file = control.openFile(file) read = file.read() read = read.encode('utf-8') file.close() if not read.startswith(sys.argv[0]): raise Exception() params = dict(urlparse.parse_qsl(read.replace('?',''))) try: tvshowtitle = params['tvshowtitle'] except: tvshowtitle = None try: tvshowtitle = params['show'] except: pass if tvshowtitle == None or tvshowtitle == '': raise Exception() year, imdb, tvdb = params['year'], params['imdb'], params['tvdb'] imdb = 'tt' + re.sub('[^0-9]', '', str(imdb)) try: tmdb = params['tmdb'] except: tmdb = '0' try: tvrage = params['tvrage'] except: tvrage = '0' items.append({'tvshowtitle': tvshowtitle, 'year': year, 'imdb': imdb, 'tmdb': tmdb, 'tvdb': tvdb, 'tvrage': tvrage}) except: pass items = [i for x, i in enumerate(items) if i not in items[x + 1:]] if len(items) == 0: raise Exception() except: return try: lib = control.jsonrpc('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": {"properties" : ["imdbnumber", "title", "year"]}, "id": 1}') lib = unicode(lib, 'utf-8', errors='ignore') lib = json.loads(lib)['result']['tvshows'] except: return if info == 'true' and not control.condVisibility('Window.IsVisible(infodialog)') and not control.condVisibility('Player.HasVideo'): control.infoDialog(control.lang(30422).encode('utf-8'), time=10000000) self.infoDialog = True try: control.makeFile(control.dataPath) dbcon = database.connect(control.libcacheFile) dbcur = dbcon.cursor() dbcur.execute("CREATE TABLE IF NOT EXISTS tvshows (""id TEXT, ""items TEXT, ""UNIQUE(id)"");") except: return try: from resources.lib.indexers import episodes except: return for item in items: it = None if xbmc.abortRequested == True: return sys.exit() try: dbcur.execute("SELECT * FROM tvshows WHERE id = '%s'" % item['tvdb']) fetch = dbcur.fetchone() it = eval(fetch[1].encode('utf-8')) except: pass try: if not it == None: raise Exception() it = episodes.episodes().get(item['tvshowtitle'], item['year'], item['imdb'], item['tmdb'], item['tvdb'], item['tvrage'], idx=False) status = it[0]['status'].lower() it = [{'name': i['name'], 'title': i['title'], 'year': i['year'], 'imdb': i['imdb'], 'tmdb': i['tmdb'], 'tvdb': i['tvdb'], 'tvrage': i['tvrage'], 'season': i['season'], 'episode': i['episode'], 'tvshowtitle': i['tvshowtitle'], 'alter': i['alter'], 'date': i['premiered']} for i in it] if status == 'continuing': raise Exception() dbcur.execute("INSERT INTO tvshows Values (?, ?)", (item['tvdb'], repr(it))) dbcon.commit() except: pass try: id = [item['imdb'], item['tvdb']] if not item['tmdb'] == '0': id += [item['tmdb']] ep = [x['title'].encode('utf-8') for x in lib if str(x['imdbnumber']) in id or (x['title'].encode('utf-8') == item['tvshowtitle'] and str(x['year']) == item['year'])][0] ep = control.jsonrpc('{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"filter":{"and": [{"field": "tvshow", "operator": "is", "value": "%s"}]}, "properties": ["season", "episode"]}, "id": 1}' % ep) ep = unicode(ep, 'utf-8', errors='ignore') ep = json.loads(ep)['result']['episodes'][-1] num = [x for x,y in enumerate(it) if str(y['season']) == str(ep['season']) and str(y['episode']) == str(ep['episode'])][-1] it = [y for x,y in enumerate(it) if x > num] if len(it) == 0: continue except: continue for i in it: try: if xbmc.abortRequested == True: return sys.exit() if int(self.date) <= int(re.sub('[^0-9]', '', str(i['date']))): from resources.lib.sources import sources src = sources().checkSources(i['name'], i['title'], i['year'], i['imdb'], i['tmdb'], i['tvdb'], i['tvrage'], i['season'], i['episode'], i['tvshowtitle'], i['alter'], i['date']) control.log('### SOURCES SRC 10 %s | %s' % (src,i['name'])) if src == False: raise Exception() libtvshows().strmFile(i) except: pass if self.infoDialog == True: control.infoDialog(control.lang(30423).encode('utf-8'), time=1) if self.library_setting == 'true' and not control.condVisibility('Library.IsScanningVideo'): control.execute('UpdateLibrary(video)')
def clearCacheAll(self): control.idle() yes = control.yesnoDialog(control.lang(32056).encode('utf-8'), '', '') if not yes: return cache.cache_clear_all() control.infoDialog(control.lang(32057).encode('utf-8'), sound=True, icon='INFO')
def clearCacheSearch(self): control.idle() yes = control.yesnoDialog("Sind Sie sicher?", '', '') if not yes: return cache.cache_clear_search() control.infoDialog("Vorgang abgeschlossen", sound=True, icon='INFO')
def channelDirectory(self, items): if items == None or len(items) == 0: control.idle() sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting( 'fanart') try: isOld = False control.item().getArt('type') except: isOld = True isPlayable = 'true' if not 'plugin' in control.infoLabel( 'Container.PluginName') else 'false' playbackMenu = control.lang(32063).encode('utf-8') if control.setting( 'hosts.mode') == '2' else control.lang(32064).encode('utf-8') queueMenu = control.lang(32065).encode('utf-8') refreshMenu = control.lang(32072).encode('utf-8') for i in items: try: label = '[B]%s[/B] : %s (%s)' % (i['channel'].upper(), i['title'], i['year']) sysname = urllib.quote_plus('%s (%s)' % (i['title'], i['year'])) systitle = urllib.quote_plus(i['title']) imdb, tmdb, year = i['imdb'], i['tmdb'], i['year'] meta = dict((k, v) for k, v in i.iteritems() if not v == '0') meta.update({ 'code': imdb, 'imdbnumber': imdb, 'imdb_id': imdb }) meta.update({'tmdb_id': tmdb}) meta.update({'mediatype': 'movie'}) meta.update({ 'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname) }) #meta.update({'trailer': 'plugin://script.extendedinfo/?info=playtrailer&&id=%s' % imdb}) meta.update({'playcount': 0, 'overlay': 6}) try: meta.update( {'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass sysmeta = urllib.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.quote_plus(url) cm = [] cm.append( (queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) cm.append( (refreshMenu, 'RunPlugin(%s?action=refresh)' % sysaddon)) cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta))) if isOld == True: cm.append( (control.lang2(19033).encode('utf-8'), 'Action(Info)')) item = control.item(label=label) art = {} if 'poster2' in i and not i['poster2'] == '0': art.update({ 'icon': i['poster2'], 'thumb': i['poster2'], 'poster': i['poster2'] }) elif 'poster' in i and not i['poster'] == '0': art.update({ 'icon': i['poster'], 'thumb': i['poster'], 'poster': i['poster'] }) else: art.update({ 'icon': addonPoster, 'thumb': addonPoster, 'poster': addonPoster }) art.update({'banner': addonBanner}) if settingFanart == 'true' and 'fanart' in i and not i[ 'fanart'] == '0': item.setProperty('Fanart_Image', i['fanart']) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setArt(art) item.addContextMenuItems(cm) item.setProperty('IsPlayable', isPlayable) 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: pass control.content(syshandle, 'files') control.directory(syshandle, cacheToDisc=True)
def idleForPlayback(self): for i in range(0, 200): if control.condVisibility('Window.IsActive(busydialog)') == 1: control.idle() else: break control.sleep(100)
elif action == 'playItem': from resources.lib.sources import sources sources().playItem(title, source) elif action == 'alterSources': from resources.lib.sources import sources sources().alterSources(url, meta) elif action == 'clearSources': from resources.lib.sources import sources sources().clearSources() elif action == 'clearMeta': import os from resources.lib.modules import control control.idle() try: os.remove(control.cacheFile) except: pass try: os.remove(control.metacacheFile) except: pass control.infoDialog('Meta Cache Deleted', sound=True, icon='INFO') elif action == 'backupSettings': from resources.lib.modules import updater updater.backupAddon()
def movieDirectory(self, items): if items == None or len(items) == 0: control.idle() ; sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting('fanart') traktCredentials = trakt.getTraktCredentialsInfo() try: isOld = False ; control.item().getArt('type') except: isOld = True isPlayable = 'true' if not 'plugin' in control.infoLabel('Container.PluginName') else 'false' indicators = playcount.getMovieIndicators(refresh=True) if action == 'movies' else playcount.getMovieIndicators() playbackMenu = control.lang(32063).encode('utf-8') if control.setting('hosts.mode') == '2' else control.lang(32064).encode('utf-8') watchedMenu = control.lang(32068).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32066).encode('utf-8') unwatchedMenu = control.lang(32069).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32067).encode('utf-8') queueMenu = control.lang(32065).encode('utf-8') traktManagerMenu = control.lang(32070).encode('utf-8') nextMenu = control.lang(32053).encode('utf-8') addToLibrary = control.lang(32551).encode('utf-8') for i in items: try: label = '%s (%s)' % (i['title'], i['year']) imdb, tmdb, title, year = i['imdb'], i['tmdb'], i['originaltitle'], i['year'] sysname = urllib.quote_plus('%s (%s)' % (title, year)) systitle = urllib.quote_plus(title) meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'code': imdb, 'imdbnumber': imdb, 'imdb_id': imdb}) meta.update({'tmdb_id': tmdb}) meta.update({'mediatype': 'movie'}) meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, urllib.quote_plus(label))}) #meta.update({'trailer': 'plugin://script.extendedinfo/?info=playtrailer&&id=%s' % 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 poster = [i[x] for x in ['poster3', 'poster', 'poster2'] if i.get(x, '0') != '0'] poster = poster[0] if poster else addonPoster meta.update({'poster': poster}) sysmeta = urllib.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.quote_plus(url) path = '%s?action=play&title=%s&year=%s&imdb=%s' % (sysaddon, systitle, year, imdb) cm = [] 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 isOld == True: cm.append((control.lang2(19033).encode('utf-8'), '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))) item = control.item(label=label) art = {} art.update({'icon': poster, 'thumb': poster, 'poster': poster}) 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 settingFanart == 'true' and 'fanart2' in i and not i['fanart2'] == '0': item.setProperty('Fanart_Image', i['fanart2']) elif settingFanart == 'true' and 'fanart' in i and not i['fanart'] == '0': item.setProperty('Fanart_Image', i['fanart']) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setArt(art) item.addContextMenuItems(cm) item.setProperty('IsPlayable', isPlayable) item.setInfo(type='Video', infoLabels = meta) video_streaminfo = {'codec': 'h264'} item.addStreamInfo('video', video_streaminfo) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False) except: pass try: url = items[0]['next'] if url == '': raise Exception() icon = control.addonNext() url = '%s?action=moviePage&url=%s' % (sysaddon, urllib.quote_plus(url)) item = control.item(label=nextMenu) item.setArt({'icon': icon, 'thumb': icon, 'poster': icon, 'banner': icon}) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: pass control.content(syshandle, 'movies') control.directory(syshandle, cacheToDisc=True) views.setView('movies', {'skin.estuary': 55, 'skin.confluence': 500})
def accountCheck(self): if traktCredentials == False: control.idle() control.infoDialog(control.lang(32042).encode('utf-8'), sound=True, icon='WARNING') control.openSettings('2.12') sys.exit()
def seasonDirectory(self, items): if items == None or len(items) == 0: control.idle() sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart( ), tools.Settings.getBoolean('interface.fanart') traktCredentials = trakt.getTraktCredentialsInfo() try: isOld = False control.item().getArt('type') except: isOld = True try: indicators = playcount.getSeasonIndicators(items[0]['imdb']) except: pass traktHas = trakt.getTraktIndicatorsInfo() == True watchedMenu = control.lang(32068).encode( 'utf-8') if traktHas else control.lang(32066).encode('utf-8') unwatchedMenu = control.lang(32069).encode( 'utf-8') if traktHas else control.lang(32067).encode('utf-8') unwatchedEnabled = tools.Settings.getBoolean( 'interface.tvshows.unwatched.enabled') unwatchedLimit = tools.Settings.getBoolean( 'interface.tvshows.unwatched.limit') queueMenu = control.lang(32065).encode('utf-8') traktManagerMenu = control.lang(32070).encode('utf-8') media = tools.Media() try: multi = [i['tvshowtitle'] for i in items] except: multi = [] multi = len([x for y, x in enumerate(multi) if x not in multi[:y]]) multi = True if multi > 1 else False for i in items: try: label = None try: label = media.title(tools.Media.TypeSeason, season=i['season']) except: pass if label == None: label = i['season'] if multi == True and not label in i['tvshowtitle'] and not i[ 'tvshowtitle'] in label: label = '%s - %s' % (i['tvshowtitle'], label) systitle = sysname = urllib.quote_plus(i['tvshowtitle']) imdb, tvdb, year, season = i['imdb'], i['tvdb'], i['year'], i[ 'season'] meta = dict((k, v) for k, v in i.iteritems() if not v == '0') meta.update({'mediatype': 'tvshow'}) meta.update({ 'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname) }) # Bubbles # Remove default time, since this might mislead users. Rather show no time. #if not 'duration' in i: meta.update({'duration': '60'}) #elif i['duration'] == '0': meta.update({'duration': '60'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass try: meta.update( {'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass try: meta.update({'tvshowtitle': i['label']}) except: pass try: # Year is the shows year, not the seasons year. Extract the correct year frpm the premier date. yearNew = i['premiered'] yearNew = re.findall('(\d{4})', yearNew)[0] yearNew = yearNew.encode('utf-8') meta.update({'year': yearNew}) except: pass try: if season in indicators: meta.update({'playcount': 1, 'overlay': 7}) overlay = 7 else: meta.update({'playcount': 0, 'overlay': 6}) overlay = 6 except: overlay = None url = self.parameterize( '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s' % (sysaddon, systitle, year, imdb, tvdb, season)) cm = [] cm.append( (queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) if not traktHas: link = self.parameterize( '%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=7' % (sysaddon, systitle, imdb, tvdb, season)) cm.append((watchedMenu, 'RunPlugin(%s)' % link)) link = self.parameterize( '%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=6' % (sysaddon, systitle, imdb, tvdb, season)) cm.append((unwatchedMenu, 'RunPlugin(%s)' % link)) if traktCredentials == True: link = self.parameterize( '%s?action=traktManager&tvdb=%s&season=%s' % (sysaddon, tvdb, season)) cm.append((traktManagerMenu, 'RunPlugin(%s)' % link)) if not self.kidsOnly() and control.setting( 'downloads.manual.enabled') == 'true': cm.append( (control.lang(33585).encode('utf-8'), 'RunPlugin(%s?action=downloadsManager)' % (sysaddon))) if isOld == True: cm.append( (control.lang2(19033).encode('utf-8'), 'Action(Info)')) item = control.item(label=label) if unwatchedEnabled and not overlay == None and not overlay == 7: try: count = playcount.getSeasonCount( imdb, season, unwatchedLimit) if count: item.setProperty('TotalEpisodes', str(count['total'])) item.setProperty('WatchedEpisodes', str(count['watched'])) item.setProperty('UnWatchedEpisodes', str(count['unwatched'])) except: pass art = {} # First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster. poster = '0' if poster == '0' and 'poster3' in i: poster = i['thumb3'] if poster == '0' and 'poster2' in i: poster = i['thumb2'] if poster == '0' and 'poster' in i: poster = i['thumb'] if poster == '0' and 'poster3' in i: poster = i['poster3'] if poster == '0' and 'poster2' in i: poster = i['poster2'] if poster == '0' and 'poster' in i: poster = i['poster'] icon = '0' if icon == '0' and 'icon3' in i: icon = i['icon3'] if icon == '0' and 'icon2' in i: icon = i['icon2'] if icon == '0' and 'icon' in i: icon = i['icon'] thumb = '0' if thumb == '0' and 'thumb3' in i: thumb = i['thumb3'] if thumb == '0' and 'thumb2' in i: thumb = i['thumb2'] if thumb == '0' and 'thumb' in i: thumb = i['thumb'] banner = '0' if banner == '0' and 'banner3' in i: banner = i['banner3'] if banner == '0' and 'banner2' in i: banner = i['banner2'] if banner == '0' and 'banner' in i: banner = i['banner'] fanart = '0' if settingFanart: if fanart == '0' and 'fanart3' in i: fanart = i['fanart3'] if fanart == '0' and 'fanart2' in i: fanart = i['fanart2'] if fanart == '0' and 'fanart' in i: fanart = i['fanart'] clearlogo = '0' if clearlogo == '0' and 'clearlogo' in i: clearlogo = i['clearlogo'] clearart = '0' if clearart == '0' and 'clearart' in i: clearart = i['clearart'] if poster == '0': poster = addonPoster if icon == '0': icon = poster if thumb == '0': thumb = poster if banner == '0': banner = addonBanner if fanart == '0': fanart = addonFanart if not poster == '0' and not poster == None: art.update({ 'poster': poster, 'tvshow.poster': poster, 'season.poster': poster }) if not icon == '0' and not icon == None: art.update({'icon': icon}) if not thumb == '0' and not thumb == None: art.update({'thumb': thumb}) if not banner == '0' and not banner == None: art.update({'banner': banner}) if not clearlogo == '0' and not clearlogo == None: art.update({'clearlogo': clearlogo}) if not clearart == '0' and not clearart == None: art.update({'clearart': clearart}) if not fanart == '0' and not fanart == None: item.setProperty('Fanart_Image', fanart) item.setArt(art) item.addContextMenuItems(cm) item.setInfo(type='Video', infoLabels=meta) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: pass try: control.property(syshandle, 'showplot', items[0]['plot']) except: pass control.content(syshandle, 'seasons') control.directory(syshandle, cacheToDisc=True) views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})
def tvshows(tvshowtitle, imdb, tmdb, season, watched): control.busy() try: import sys, xbmc if not trakt.getTraktIndicatorsInfo() == False: raise Exception() from resources.lib.indexers import episodes name = control.addonInfo('name') dialog = control.progressDialogBG dialog.create(str(name), str(tvshowtitle)) dialog.update(0, str(name), str(tvshowtitle)) #log_utils.log('playcount_season: ' + str(season)) items = [] if season: items = episodes.episodes().get(tvshowtitle, '0', imdb, tmdb, season=season, idx=False) items = [ i for i in items if int('%01d' % int(season)) == int('%01d' % int(i['season'])) ] 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'])), 'unaired': i['unaired'] } for i in items] for i in list(range(len(items))): if control.monitor.abortRequested(): return sys.exit() dialog.update(int((100 / float(len(items))) * i), str(name), str(items[i]['label'])) _season, _episode, unaired = items[i]['season'], items[i][ 'episode'], items[i]['unaired'] if int(watched) == 7: if not unaired == 'true': bookmarks.reset(1, 1, 'episode', imdb, _season, _episode) else: pass else: bookmarks._delete_record('episode', imdb, _season, _episode) else: seasons = episodes.seasons().get(tvshowtitle, '0', imdb, tmdb, idx=False) seasons = [i['season'] for i in seasons] #log_utils.log('playcount_seasons: ' + str(seasons)) for s in seasons: items = episodes.episodes().get(tvshowtitle, '0', imdb, tmdb, season=s, idx=False) 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'])), 'unaired': i['unaired'] } for i in items] #log_utils.log('playcount_items2: ' + str(items)) for i in list(range(len(items))): if control.monitor.abortRequested(): return sys.exit() dialog.update(int((100 / float(len(items))) * i), str(name), str(items[i]['label'])) _season, _episode, unaired = items[i]['season'], items[i][ 'episode'], items[i]['unaired'] if int(watched) == 7: if not unaired == 'true': bookmarks.reset(1, 1, 'episode', imdb, _season, _episode) else: pass else: bookmarks._delete_record('episode', imdb, _season, _episode) try: dialog.close() except: pass except: log_utils.log('playcount_local_shows', 1) try: dialog.close() except: pass try: if trakt.getTraktIndicatorsInfo() == False: raise Exception() #log_utils.log('playcount_season: ' + str(season)) if season: from resources.lib.indexers import episodes items = episodes.episodes().get(tvshowtitle, '0', imdb, tmdb, season=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(imdb, season, i) else: trakt.markEpisodeAsNotWatched(imdb, season, i) else: if int(watched) == 7: trakt.markTVShowAsWatched(imdb) else: trakt.markTVShowAsNotWatched(imdb) trakt.cachesyncTVShows() except: log_utils.log('playcount_trakt_shows', 1) pass control.refresh() control.idle()
def tvDirectory(items): if items == None or len(items) == 0: control.idle() sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting( 'fanart') traktCredentials = trakt.getTraktCredentialsInfo() try: isOld = False control.item().getArt('type') except: isOld = True indicators = playcount.getTVShowIndicators( refresh=True ) if action == 'tvshows' else playcount.getTVShowIndicators() flatten = True if control.setting('flatten.tvshows') == 'true' else False 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) playRandom = control.lang(32535) addToLibrary = control.lang(32551) remoteManagerMenu = 'Remote Library' for i in items: try: label = i['title'] systitle = sysname = urllib.parse.quote_plus(i['originaltitle']) sysimage = urllib.parse.quote_plus(i['poster']) imdb, tvdb, year = i['imdb'], i['tvdb'], i['year'] meta = dict((k, v) for k, v in i.items() if not v == '0') meta.update({'code': imdb, 'imdbnumber': imdb, 'imdb_id': imdb}) meta.update({'tvdb_id': tvdb}) meta.update({'mediatype': 'tvshow'}) meta.update({ 'trailer': '%s?action=trailer&name=%s' % (sysaddon, urllib.parse.quote_plus(label)) }) if not 'duration' in i: meta.update({'duration': '60'}) elif i['duration'] == '0': meta.update({'duration': '60'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass try: meta.update( {'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass try: overlay = int(playcount.getTVShowOverlay(indicators, tvdb)) # #print ("realizer OVERLAY", label, overlay) if overlay == 7: meta.update({'playcount': 1, 'overlay': 7}) else: meta.update({'playcount': 0, 'overlay': 6}) except: pass sysmeta = urllib.parse.quote_plus(json.dumps(meta)) if flatten == True: url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % ( sysaddon, systitle, year, imdb, tvdb) else: url = '%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&meta=%s' % ( sysaddon, systitle, year, imdb, tvdb, sysmeta) cm = [] cm.append(( playRandom, 'RunPlugin(%s?action=random&rtype=season&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s)' % (sysaddon, urllib.parse.quote_plus(systitle), urllib.parse.quote_plus(year), urllib.parse.quote_plus(imdb), urllib.parse.quote_plus(tvdb)))) cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) cm.append(( watchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=0&query=7)' % (sysaddon, systitle, imdb, tvdb))) cm.append(( unwatchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=0&query=6)' % (sysaddon, systitle, imdb, tvdb))) cm.append(( remoteManagerMenu, 'RunPlugin(%s?action=remoteManager&imdb=%s&tvdb=%s&meta=%s&content=tv)' % (sysaddon, imdb, tvdb, sysmeta))) if not action == 'tvFavourites': cm.append(( 'Add to Watchlist', 'RunPlugin(%s?action=addFavourite&meta=%s&content=tvshows)' % (sysaddon, sysmeta))) if action == 'tvFavourites': cm.append(( 'Remove From Watchlist', 'RunPlugin(%s?action=deleteFavourite&meta=%s&content=tvshows)' % (sysaddon, sysmeta))) # if not action == 'tvdbFav':cm.append(('Add To Tvdb', 'RunPlugin(%s?action=tvdbAdd&tvshowtitle=%s&tvdb=%s)' % (sysaddon, systitle, tvdb))) # if action == 'tvdbFav': cm.append(('Remove From Tvdb', 'RunPlugin(%s?action=tvdbRemove&tvdb=%s)' % (sysaddon, tvdb))) if traktCredentials == True: cm.append(( traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&tvdb=%s&content=tvshow)' % (sysaddon, sysname, tvdb))) if isOld == True: cm.append((control.lang2(19033), 'Action(Info)')) cm.append(( addToLibrary, 'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&icon=%s)' % (sysaddon, systitle, year, imdb, tvdb, i['poster']))) item = control.item(label=label) art = {} if 'poster' in i and not i['poster'] == '0': art.update({ 'icon': i['poster'], 'thumb': i['poster'], 'poster': i['poster'] }) #elif 'poster2' in i and not i['poster2'] == '0': #art.update({'icon': i['poster2'], 'thumb': i['poster2'], 'poster': i['poster2']}) else: art.update({ 'icon': addonPoster, 'thumb': addonPoster, 'poster': addonPoster }) if 'banner' in i and not i['banner'] == '0': art.update({'banner': i['banner']}) #elif 'banner2' in i and not i['banner2'] == '0': #art.update({'banner': i['banner2']}) elif 'fanart' in i and not i['fanart'] == '0': art.update({'banner': i['fanart']}) 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 settingFanart == 'true' and 'fanart' in i and not i[ 'fanart'] == '0': item.setProperty('Fanart_Image', i['fanart']) #elif settingFanart == 'true' and 'fanart2' in i and not i['fanart2'] == '0': #item.setProperty('Fanart_Image', i['fanart2']) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setArt(art) item.addContextMenuItems(cm) item.setInfo(type='Video', infoLabels=meta) video_streaminfo = {'codec': 'h264'} item.addStreamInfo('video', video_streaminfo) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: pass control.content(syshandle, 'tvshows') control.directory(syshandle, cacheToDisc=True)
def tvshows(tvshowtitle, imdb, tvdb, season, watched): control.busy() try: import sys import xbmc if not trakt.getTraktIndicatorsInfo() == False: raise Exception() from metahandler import metahandlers from resources.lib.indexers import episodes metaget = metahandlers.MetaData() 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() control.idle()
def update(self, query=None, info='true'): if not query == None: control.idle() try: items = [] season, episode = [], [] show = [ os.path.join(self.library_folder, i) for i in control.listDir(self.library_folder)[0] ] for s in show: try: season += [ os.path.join(s, i) for i in control.listDir(s)[0] ] except: pass for s in season: try: episode.append([ os.path.join(s, i) for i in control.listDir(s)[1] if i.endswith('.strm') ][-1]) except: pass for file in episode: try: file = control.openFile(file) read = file.read() read = read.encode('utf-8') file.close() if not read.startswith(sys.argv[0]): raise Exception() params = dict(urlparse.parse_qsl(read.replace('?', ''))) try: tvshowtitle = params['tvshowtitle'] except: tvshowtitle = None try: tvshowtitle = params['show'] except: pass if tvshowtitle == None or tvshowtitle == '': raise Exception() year, imdb, tvdb = params['year'], params['imdb'], params[ 'tvdb'] imdb = 'tt' + re.sub('[^0-9]', '', str(imdb)) try: tmdb = params['tmdb'] except: tmdb = '0' items.append({ 'tvshowtitle': tvshowtitle, 'year': year, 'imdb': imdb, 'tmdb': tmdb, 'tvdb': tvdb }) except: pass items = [i for x, i in enumerate(items) if i not in items[x + 1:]] if len(items) == 0: raise Exception() except: return try: lib = control.jsonrpc( '{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShows", "params": {"properties" : ["imdbnumber", "title", "year"]}, "id": 1}' ) lib = unicode(lib, 'utf-8', errors='ignore') lib = json.loads(lib)['result']['tvshows'] except: return if info == 'true' and not control.condVisibility( 'Window.IsVisible(infodialog)') and not control.condVisibility( 'Player.HasVideo'): control.infoDialog(control.lang(32553).encode('utf-8'), time=10000000) self.infoDialog = True try: control.makeFile(control.dataPath) dbcon = database.connect(control.libcacheFile) dbcur = dbcon.cursor() dbcur.execute("CREATE TABLE IF NOT EXISTS tvshows (" "id TEXT, " "items TEXT, " "UNIQUE(id)" ");") except: return try: from resources.lib.indexers import episodes except: return files_added = 0 # __init__ doesn't get called from services so self.date never gets updated and new episodes are not added to the library self.datetime = (datetime.datetime.utcnow() - datetime.timedelta(hours=5)) if control.setting('library.importdelay') != 'true': self.date = self.datetime.strftime('%Y%m%d') else: self.date = (self.datetime - datetime.timedelta(hours=24)).strftime('%Y%m%d') for item in items: it = None if xbmc.abortRequested == True: return sys.exit() try: dbcur.execute("SELECT * FROM tvshows WHERE id = '%s'" % item['tvdb']) fetch = dbcur.fetchone() it = eval(fetch[1].encode('utf-8')) except: pass try: if not it == None: raise Exception() it = episodes.episodes().get(item['tvshowtitle'], item['year'], item['imdb'], item['tvdb'], idx=False) status = it[0]['status'].lower() it = [{ 'title': i['title'], 'year': i['year'], 'imdb': i['imdb'], 'tvdb': i['tvdb'], 'season': i['season'], 'episode': i['episode'], 'tvshowtitle': i['tvshowtitle'], 'premiered': i['premiered'] } for i in it] if status == 'continuing': raise Exception() dbcur.execute("INSERT INTO tvshows Values (?, ?)", (item['tvdb'], repr(it))) dbcon.commit() except: pass try: id = [item['imdb'], item['tvdb']] if not item['tmdb'] == '0': id += [item['tmdb']] ep = [ x['title'].encode('utf-8') for x in lib if str(x['imdbnumber']) in id or ( x['title'].encode('utf-8') == item['tvshowtitle'] and str(x['year']) == item['year']) ][0] ep = control.jsonrpc( '{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"filter":{"and": [{"field": "tvshow", "operator": "is", "value": "%s"}]}, "properties": ["season", "episode"]}, "id": 1}' % ep) ep = unicode(ep, 'utf-8', errors='ignore') ep = json.loads(ep).get('result', {}).get('episodes', {}) ep = [{ 'season': int(i['season']), 'episode': int(i['episode']) } for i in ep] ep = sorted(ep, key=lambda x: (x['season'], x['episode']))[-1] num = [ x for x, y in enumerate(it) if str(y['season']) == str(ep['season']) and str(y['episode']) == str(ep['episode']) ][-1] it = [y for x, y in enumerate(it) if x > num] if len(it) == 0: continue except: continue for i in it: try: if xbmc.abortRequested == True: return sys.exit() premiered = i.get('premiered', '0') if (premiered != '0' and int(re.sub('[^0-9]', '', str(premiered))) > int(self.date)) or (premiered == '0' and not self.include_unknown): continue libtvshows().strmFile(i) files_added += 1 except: pass if self.infoDialog == True: control.infoDialog(control.lang(32554).encode('utf-8'), time=1) if self.library_setting == 'true' and not control.condVisibility( 'Library.IsScanningVideo') and files_added > 0: control.execute('UpdateLibrary(video)')
def tvshowDirectory(self, items): if items == None or len(items) == 0: control.idle() ; sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting('fanart') traktCredentials = trakt.getTraktCredentialsInfo() try: isOld = False ; control.item().getArt('type') except: isOld = True indicators = playcount.getTVShowIndicators(refresh=True) if action == 'tvshows' else playcount.getTVShowIndicators() flatten = True if control.setting('flatten.tvshows') == 'true' else False watchedMenu = control.lang(32068).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32066).encode('utf-8') unwatchedMenu = control.lang(32069).encode('utf-8') if trakt.getTraktIndicatorsInfo() == True else control.lang(32067).encode('utf-8') queueMenu = control.lang(32065).encode('utf-8') traktManagerMenu = control.lang(32070).encode('utf-8') nextMenu = control.lang(32053).encode('utf-8') for i in items: try: label = i['title'] systitle = sysname = urllib.quote_plus(i['originaltitle']) sysimage = urllib.quote_plus(i['poster']) imdb, tvdb, year = i['imdb'], i['tvdb'], i['year'] meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'mediatype': 'tvshow'}) meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)}) if not 'duration' in i: meta.update({'duration': '60'}) elif i['duration'] == '0': meta.update({'duration': '60'}) try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass try: overlay = int(playcount.getTVShowOverlay(indicators, tvdb)) if overlay == 7: meta.update({'playcount': 1, 'overlay': 7}) else: meta.update({'playcount': 0, 'overlay': 6}) except: pass if flatten == True: url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (sysaddon, systitle, year, imdb, tvdb) else: url = '%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s' % (sysaddon, systitle, year, imdb, tvdb) cm = [] cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) cm.append((watchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=7)' % (sysaddon, systitle, imdb, tvdb))) cm.append((unwatchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&query=6)' % (sysaddon, systitle, imdb, tvdb))) if traktCredentials == True: cm.append((traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&tvdb=%s&content=tvshow)' % (sysaddon, sysname, tvdb))) if isOld == True: cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)')) item = control.item(label=label) art = {} if 'poster' in i and not i['poster'] == '0': art.update({'icon': i['poster'], 'thumb': i['poster'], 'poster': i['poster']}) #elif 'poster2' in i and not i['poster2'] == '0': #art.update({'icon': i['poster2'], 'thumb': i['poster2'], 'poster': i['poster2']}) else: art.update({'icon': addonPoster, 'thumb': addonPoster, 'poster': addonPoster}) if 'banner' in i and not i['banner'] == '0': art.update({'banner': i['banner']}) #elif 'banner2' in i and not i['banner2'] == '0': #art.update({'banner': i['banner2']}) elif 'fanart' in i and not i['fanart'] == '0': art.update({'banner': i['fanart']}) 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 settingFanart == 'true' and 'fanart' in i and not i['fanart'] == '0': item.setProperty('Fanart_Image', i['fanart']) #elif settingFanart == 'true' and 'fanart2' in i and not i['fanart2'] == '0': #item.setProperty('Fanart_Image', i['fanart2']) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setArt(art) item.addContextMenuItems(cm) item.setInfo(type='Video', infoLabels = meta) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: pass try: url = items[0]['next'] if url == '': raise Exception() icon = control.addonNext() url = '%s?action=tvshowPage&url=%s' % (sysaddon, urllib.quote_plus(url)) item = control.item(label=nextMenu) item.setArt({'icon': icon, 'thumb': icon, 'poster': icon, 'banner': icon}) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: pass control.content(syshandle, 'tvshows') control.directory(syshandle, cacheToDisc=True) views.setView('tvshows', {'skin.confluence': 500})
def channelDirectory(self, items, name): if items == None or len(items) == 0: control.idle() sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart = control.addonFanart() try: isOld = False control.item().getArt('type') except: isOld = True isPlayable = 'true' if not 'plugin' in control.infoLabel( 'Container.PluginName') else 'false' #playbackMenu = control.lang(32063).encode('utf-8') if control.setting('hosts.mode') == '2' else control.lang(32064).encode('utf-8') #queueMenu = control.lang(32065).encode('utf-8') #refreshMenu = control.lang(32072).encode('utf-8') if name == None: for i in items: try: item = control.item(label=i['name']) item.setInfo(type='Video', infoLabels="") item.addStreamInfo('video', { 'width': 1920, 'height': 1080 }) item.setProperty('Video', 'true') control.addItem(handle=int(sys.argv[1]), url="plugin://" + control.addon().getAddonInfo('id') + "/?action=channels&name=" + i['url'], listitem=item, isFolder=True) except: pass else: for i in items: try: label = '[B]%s[/B] (%s) %s' % (i['name'].upper(), i['id'], i['title']) sysname = urllib.quote_plus('%s (%s)' % (i['name'], i['id'])) systitle = urllib.quote_plus(i['name']) poster = i['poster'] banner = '0' url = i['url'] sysurl = urllib.quote_plus(url) cm = [] #cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) #cm.append((refreshMenu, 'RunPlugin(%s?action=refresh)' % sysaddon)) #cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta))) if isOld == True: cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)')) item = control.item(label=label) if (str(i['hd']) == "1"): item.addStreamInfo('video', { 'width': 1280, 'height': 720 }) elif (str(i['hd']) == "2"): item.addStreamInfo('video', { 'width': 1920, 'height': 1080 }) else: item.addStreamInfo('video', { 'width': 600, 'height': 320 }) item.setArt({ 'icon': poster, 'thumb': poster, 'poster': poster, 'banner': banner }) if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.addContextMenuItems(cm) item.setProperty('IsPlayable', isPlayable) item.setInfo(type='Video', infoLabels="") control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False) except: pass control.content(syshandle, 'movies') #control.do_block_check(False) control.directory(syshandle, cacheToDisc=True)
def range(self, url, list_name): control.idle() if not control.yesnoDialog(control.lang(32555).encode('utf-8'), '', ''): return if 'traktcollection' in url: message = 32661 if 'traktwatchlist' in url: message = 32662 if '/lists/' in url: message = 32674 if '/likes/' in url: message = 32675 if not control.condVisibility('Window.IsVisible(infodialog)') and not control.condVisibility('Player.HasVideo'): control.notification(title = 'default', message = message, icon = 'default', time = 1000, sound = notificationSound) from resources.lib.menus import tvshows items = tvshows.TVshows().get(url, idx=False) if items is None or items == []: if general_notification: control.notification(title = message, message = 33049, icon = 'INFO', time = 3000, sound=notificationSound) return contains = lib_tools.ckKodiSources() total_added = 0 for i in items: try: if xbmc.abortRequested is True:#..I think this is deprecated and was for Gotham and earlier # xbmc.Monitor().abortRequested() #check this return sys.exit() files_added = self.add(i['title'], i['year'], i['imdb'], i['tvdb'], range=True) if general_notification and files_added > 0: control.notification(title = i['title'], message = 32554, icon = 'default', time = 1000, sound = notificationSound) total_added += 1 except: log_utils.error() pass if '/users/' in url: try: type = 'tvshows' control.makeFile(control.dataPath) dbcon = database.connect(control.libcacheFile) dbcur = dbcon.cursor() dbcur.execute("CREATE TABLE IF NOT EXISTS lists (""type TEXT, ""list_name TEXT, ""url TEXT, ""UNIQUE(type, list_name, url)"");") dbcur.execute("INSERT OR REPLACE INTO lists Values (?, ?, ?)", (type, list_name, url)) dbcur.connection.commit() dbcon.close() except: log_utils.error() try: dbcon.close() except: pass pass if self.library_update == 'true' and not control.condVisibility('Library.IsScanningVideo') and total_added > 0: if contains: control.sleep(10000) control.execute('UpdateLibrary(video)') elif general_notification: control.notification(title = 'default', message = 'strm files written but library cannot be updated', icon = 'default', time = 2000, sound = notificationSound)
def addItem(self, title): control.playlist.clear() items = control.window.getProperty(self.itemProperty) items = json.loads(items) if items == None or len(items) == 0: control.idle() sys.exit() meta = control.window.getProperty(self.metaProperty) meta = json.loads(meta) sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) downloads = True if control.setting('downloads') == 'true' and not ( control.setting('movie.download.path') == '' or control.setting('tv.download.path') == '') else False systitle = sysname = urllib.quote_plus(title) if 'tvshowtitle' in meta and 'season' in meta and 'episode' in meta: sysname += urllib.quote_plus( ' S%02dE%02d' % (int(meta['season']), int(meta['episode']))) elif 'year' in meta: sysname += urllib.quote_plus(' (%s)' % meta['year']) poster = meta['poster3'] if 'poster3' in meta else '0' if poster == '0': poster = meta['poster'] if 'poster' in meta else '0' fanart = meta['fanart2'] if 'fanart2' in meta else '0' if fanart == '0': fanart = meta['fanart'] if 'fanart' in meta else '0' thumb = meta['thumb'] if 'thumb' in meta else '0' if thumb == '0': thumb = poster if thumb == '0': thumb = fanart banner = meta['banner'] if 'banner' in meta else '0' if banner == '0': banner = poster if poster == '0': poster = control.addonPoster() if banner == '0': banner = control.addonBanner() if not control.setting('fanart') == 'true': fanart = '0' if fanart == '0': fanart = control.addonFanart() if thumb == '0': thumb = control.addonFanart() sysimage = urllib.quote_plus(poster.encode('utf-8')) downloadMenu = control.lang(32403).encode('utf-8') for i in range(len(items)): try: label = items[i]['label'] syssource = urllib.quote_plus(json.dumps([items[i]])) sysurl = '%s?action=playItem&title=%s&source=%s' % ( sysaddon, systitle, syssource) cm = [] if downloads == True: cm.append(( downloadMenu, 'RunPlugin(%s?action=download&name=%s&image=%s&source=%s)' % (sysaddon, sysname, sysimage, syssource))) item = control.item(label=label) item.setArt({ 'icon': thumb, 'thumb': thumb, 'poster': poster, 'banner': banner }) item.setProperty('Fanart_Image', fanart) video_streaminfo = {'codec': 'h264'} item.addStreamInfo('video', video_streaminfo) item.addContextMenuItems(cm) item.setInfo(type='Video', infoLabels=meta) control.addItem(handle=syshandle, url=sysurl, listitem=item, isFolder=False) except: pass control.content(syshandle, 'files') control.directory(syshandle, cacheToDisc=True)
def seasonDirectory(self, items): if items is None or len(items) == 0: control.idle() control.notification(title = 32054, message = 33049, icon = 'INFO') sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting('fanart') traktCredentials = trakt.getTraktCredentialsInfo() # try: # isOld = False ; control.item().getArt('type') # except: # isOld = True if trakt.getTraktIndicatorsInfo() is True: watchedMenu = control.lang(32068).encode('utf-8') unwatchedMenu = control.lang(32069).encode('utf-8') else: watchedMenu = control.lang(32066).encode('utf-8') unwatchedMenu = control.lang(32067).encode('utf-8') traktManagerMenu = control.lang(32070).encode('utf-8') playlistManagerMenu = control.lang(35522).encode('utf-8') queueMenu = control.lang(32065).encode('utf-8') showPlaylistMenu = control.lang(35517).encode('utf-8') clearPlaylistMenu = control.lang(35516).encode('utf-8') labelMenu = control.lang(32055).encode('utf-8') playRandom = control.lang(32535).encode('utf-8') addToLibrary = control.lang(32551).encode('utf-8') try: multi = [i['tvshowtitle'] for i in items] except: multi = [] multi = len([x for y,x in enumerate(multi) if x not in multi[:y]]) multi = True if multi > 1 else False for i in items: try: imdb, tvdb, year, season = i['imdb'], i['tvdb'], i['year'], i['season'] title = i['tvshowtitle'] label = '%s %s' % (labelMenu, i['season']) if self.season_special is False and control.setting('tv.specials') == 'true': self.season_special = True if int(season) == 0 else False try: if i['unaired'] == 'true': label = '[COLOR %s][I]%s[/I][/COLOR]' % (self.unairedcolor, label) except: pass systitle = sysname = urllib.quote_plus(title) meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'code': imdb, 'imdbnumber': imdb, 'imdb_id': imdb}) meta.update({'tvdb_id': tvdb}) meta.update({'mediatype': 'tvshow'}) meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)}) try: plot = meta['plot'] index = plot.rfind('See full summary') if index >= 0: plot = plot[:index] plot = plot.strip() if re.match('[a-zA-Z\d]$', plot): plot += ' ...' meta['plot'] = plot except: pass try: meta.update({'duration': str(int(meta['duration']) * 60)}) except: pass try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass try: meta.update({'tvshowtitle': i['label']}) except: pass try: # Year is the shows year, not the seasons year. Extract the correct year frpm the premier date. yearNew = i['premiered'] yearNew = re.findall('(\d{4})', yearNew)[0] yearNew = yearNew.encode('utf-8') meta.update({'year': yearNew}) except: pass # First check thumbs, since they typically contains the seasons poster. The normal poster contains the show poster. poster = '0' if poster == '0' and 'thumb3' in i: poster = i['thumb3'] if poster == '0' and 'thumb2' in i: poster = i['thumb2'] if poster == '0' and 'thumb' in i: poster = i['thumb'] if poster == '0' and 'poster3' in i: poster = i['poster3'] if poster == '0' and 'poster2' in i: poster = i['poster2'] if poster == '0' and 'poster' in i: poster = i['poster'] icon = '0' if icon == '0' and 'icon3' in i: icon = i['icon3'] if icon == '0' and 'icon2' in i: icon = i['icon2'] if icon == '0' and 'icon' in i: icon = i['icon'] thumb = '0' if thumb == '0' and 'thumb3' in i: thumb = i['thumb3'] if thumb == '0' and 'thumb2' in i: thumb = i['thumb2'] if thumb == '0' and 'thumb' in i: thumb = i['thumb'] banner = '0' if banner == '0' and 'banner3' in i: banner = i['banner3'] if banner == '0' and 'banner2' in i: banner = i['banner2'] if banner == '0' and 'banner' in i: banner = i['banner'] fanart = '0' if settingFanart: if fanart == '0' and 'fanart3' in i: fanart = i['fanart3'] if fanart == '0' and 'fanart2' in i: fanart = i['fanart2'] if fanart == '0' and 'fanart' in i: fanart = i['fanart'] clearlogo = '0' if clearlogo == '0' and 'clearlogo' in i: clearlogo = i['clearlogo'] clearart = '0' if clearart == '0' and 'clearart' in i: clearart = i['clearart'] if poster == '0': poster = addonPoster if icon == '0': icon = poster if thumb == '0': thumb = poster if banner == '0': banner = addonBanner if fanart == '0': fanart = addonFanart art = {} if not poster == '0' and not poster is None: art.update({'poster' : poster, 'tvshow.poster' : poster, 'season.poster' : poster}) if not fanart == '0' and not fanart is None: art.update({'fanart' : fanart}) if not icon == '0' and not icon is None: art.update({'icon' : icon}) if not thumb == '0' and not thumb is None: art.update({'thumb' : thumb}) if not banner == '0' and not banner is None: art.update({'banner' : banner}) if not clearlogo == '0' and not clearlogo is None: art.update({'clearlogo' : clearlogo}) if not clearart == '0' and not clearart is None: art.update({'clearart' : clearart}) ####-Context Menu and Overlays-#### cm = [] if traktCredentials is True: cm.append((traktManagerMenu, 'RunPlugin(%s?action=traktManager&name=%s&imdb=%s&tvdb=%s&season=%s)' % (sysaddon, sysname, imdb, tvdb, season))) try: indicators = playcount.getSeasonIndicators(imdb) overlay = int(playcount.getSeasonOverlay(indicators, imdb, tvdb, season)) watched = overlay == 7 if watched: meta.update({'playcount': 1, 'overlay': 7}) cm.append((unwatchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=6)' % (sysaddon, systitle, imdb, tvdb, season))) else: meta.update({'playcount': 0, 'overlay': 6}) cm.append((watchedMenu, 'RunPlugin(%s?action=tvPlaycount&name=%s&imdb=%s&tvdb=%s&season=%s&query=7)' % (sysaddon, systitle, imdb, tvdb, season))) except: pass sysmeta = urllib.quote_plus(json.dumps(meta)) sysart = urllib.quote_plus(json.dumps(art)) url = '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s' % (sysaddon, systitle, year, imdb, tvdb, season) sysurl = urllib.quote_plus(url) cm.append((playRandom, 'RunPlugin(%s?action=random&rtype=episode&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s&season=%s)' % ( sysaddon, urllib.quote_plus(systitle), urllib.quote_plus(year), urllib.quote_plus(imdb), urllib.quote_plus(tvdb), urllib.quote_plus(season)))) # cm.append((playlistManagerMenu, 'RunPlugin(%s?action=playlistManager&name=%s&url=%s&meta=%s&art=%s)' % (sysaddon, systitle, sysurl, sysmeta, sysart))) cm.append((queueMenu, 'RunPlugin(%s?action=queueItem&name=%s)' % (sysaddon, systitle))) cm.append((showPlaylistMenu, 'RunPlugin(%s?action=showPlaylist)' % sysaddon)) cm.append((clearPlaylistMenu, 'RunPlugin(%s?action=clearPlaylist)' % sysaddon)) # if isOld is True: # cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)')) cm.append((addToLibrary, 'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tvdb=%s)' % (sysaddon, systitle, year, imdb, tvdb))) cm.append(('[COLOR red]ego Settings[/COLOR]', 'RunPlugin(%s?action=openSettings&query=(0,0))' % sysaddon)) #################################### item = control.item(label = label) unwatchedEnabled = True unwatchedLimit = False if unwatchedEnabled: count = playcount.getSeasonCount(imdb, season, self.season_special, unwatchedLimit) if count: item.setProperty('TotalEpisodes', str(count['total'])) item.setProperty('WatchedEpisodes', str(count['watched'])) item.setProperty('UnWatchedEpisodes', str(count['unwatched'])) total_seasons = trakt.getSeasons(imdb, full=False) if not total_seasons is None: total_seasons = [i['number'] for i in total_seasons] total_seasons = len(total_seasons) if control.setting('tv.specials') == 'false' or self.season_special is False: total_seasons = total_seasons - 1 item.setProperty('TotalSeasons', str(total_seasons)) if 'episodeIDS' in i: item.setUniqueIDs(i['episodeIDS']) if 'cast' in i: item.setCast(i['cast']) if not fanart == '0' and not fanart is None: item.setProperty('Fanart_Image', fanart) item.setArt(art) item.setInfo(type='video', infoLabels=control.metadataClean(meta)) item.addContextMenuItems(cm) video_streaminfo = {'codec': 'h264'} item.addStreamInfo('video', video_streaminfo) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=True) except: pass try: control.property(syshandle, 'showplot', items[0]['plot']) except: pass control.content(syshandle, 'seasons') control.directory(syshandle, cacheToDisc=True) views.setView('seasons', {'skin.estuary': 55, 'skin.confluence': 500})
def getSources(self, title, year, imdb, tvdb, season, episode, tvshowtitle, premiered, presetDict=[], timeout=30, progress=True): sourceDict = [] for package, name, is_pkg in pkgutil.walk_packages(__path__): sourceDict.append((name, is_pkg)) sourceDict = [i[0] for i in sourceDict if i[1] == False] if not presetDict == []: sourceDict = [i for i in presetDict if i in sourceDict] content = 'movie' if tvshowtitle == None else 'episode' if content == 'movie': sourceDict = [i for i in sourceDict if i.endswith(('_mv', '_mv_tv'))] else: sourceDict = [i for i in sourceDict if i.endswith(('_tv', '_mv_tv'))] try: sourceDict = [(i, control.setting('provider.' + re.sub('_mv_tv$|_mv$|_tv$', '', i))) for i in sourceDict] except: sourceDict = [(i, 'true') for i in sourceDict] sourceDict = [i[0] for i in sourceDict if not i[1] == 'false'] threads = [] control.makeFile(control.dataPath) self.sourceFile = control.providercacheFile if content == 'movie': title = cleantitle.normalize(title) for source in sourceDict: threads.append(workers.Thread(self.getMovieSource, title, year, imdb, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source())) else: tvshowtitle = cleantitle.normalize(tvshowtitle) for source in sourceDict: threads.append(workers.Thread(self.getEpisodeSource, title, year, imdb, tvdb, season, episode, tvshowtitle, premiered, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source())) try: timeout = int(control.setting('scrapers.timeout.1')) except: pass [i.start() for i in threads] control.idle() sourceLabel = [re.sub('_mv_tv$|_mv$|_tv$', '', i) for i in sourceDict] sourceLabel = [re.sub('v\d+$', '', i).upper() for i in sourceLabel] if progress == True: self.progressDialog = control.progressDialog self.progressDialog.create(control.addonInfo('name'), '') self.progressDialog.update(0) string1 = control.lang(30512).encode('utf-8') string2 = control.lang(30513).encode('utf-8') string3 = control.lang(30514).encode('utf-8') for i in range(0, timeout * 2): try: if xbmc.abortRequested == True: return sys.exit() try: info = [sourceLabel[int(re.sub('[^0-9]', '', str(x.getName()))) - 1] for x in threads if x.is_alive() == True] except: info = [] if len(info) > 5: info = len(info) if progress == True: self.progressDialog.update(int((100 / float(len(threads))) * len([x for x in threads if x.is_alive() == False])), str('%s: %s %s' % (string1, int(i * 0.5), string2)), str('%s: %s' % (string3, str(info).translate(None, "[]'")))) if self.progressDialog.iscanceled(): break is_alive = [x.is_alive() for x in threads] if all(x == False for x in is_alive): break time.sleep(0.5) except: pass try: self.progressDialog.close() except: pass self.sourcesFilter() return self.sources
def __getVideoInfo(self, id): proxy = control.proxy_url proxy = None if proxy is None or proxy == '' else { 'http': proxy, 'https': proxy, } playlistUrl = 'http://api.globovideos.com/videos/%s/playlist' playlistJson = client.request(playlistUrl % id, headers={"Accept-Encoding": "gzip"}) if not playlistJson or 'videos' not in playlistJson or len( playlistJson['videos']) == 0: # Video Not Available control.infoDialog(message=control.lang(34101).encode('utf-8'), sound=True, icon='ERROR') control.idle() sys.exit() return None # raise Exception("Player version not found.") playlistJson = playlistJson['videos'][0] resource = None for node in playlistJson['resources']: # prefer mp4 if 'height' in node and node['height'] == 720 and any( "desktop" in s for s in node['players']): resource = node break if resource is None: for node in playlistJson['resources']: # fallback to hls if any(PLAYER_SLUG in s for s in node['players']): resource = node break if resource is None: control.infoDialog(message=control.lang(34102).encode('utf-8'), sound=True, icon='ERROR') control.idle() sys.exit() return None # cuepoints = playlistJson['cuepoints'] # "cuepoints": [ # { # "type": "next_segment", # "title": "", # "description": "", # "time": 596062 # }, # { # "type": "next_segment", # "title": "", # "description": "", # "time": 1136068 # }, # { # "type": "next_segment", # "title": "", # "description": "", # "time": 1687152 # }, # { # "type": "next_segment", # "title": "", # "description": "", # "time": 2020151 # } # ] resource_id = resource['_id'] username = control.setting('globoplay_username') password = control.setting('globoplay_password') # authenticate credentials = auth.auth().authenticate(username, password) hashUrl = 'http://security.video.globo.com/videos/%s/hash?resource_id=%s&version=%s&player=%s' % ( id, resource_id, PLAYER_VERSION, PLAYER_SLUG) hashJson = client.request(hashUrl, cookie=credentials, mobile=True, headers={"Accept-Encoding": "gzip"}, proxy=proxy) if not hashJson or 'hash' not in hashJson: control.infoDialog(message=control.lang(34101).encode('utf-8'), sound=True, icon='ERROR') control.idle() sys.exit() return None return { "id": playlistJson["id"], "title": playlistJson["title"], "duration": int(resource["duration"]) if 'duration' in resource else 0, "program": playlistJson["program"], "program_id": playlistJson["program_id"], "provider_id": playlistJson["provider_id"], "channel": playlistJson["channel"], "channel_id": playlistJson["channel_id"], "category": playlistJson["category"], "subscriber_only": playlistJson["subscriber_only"], "exhibited_at": playlistJson["exhibited_at"], "player": PLAYER_SLUG, "url": resource["url"], "query_string_template": resource["query_string_template"], "thumbUri": None, "hash": hashJson["hash"], "user": None, "credentials": credentials, "encrypted": False }
def accountCheck(self): if traktCredentials == False and imdbCredentials == False: control.idle() control.infoDialog("Kein Trakt- oder IMDb-Konto gefunden", sound=True, icon='WARNING') sys.exit()
def clearCache(self): control.idle() from resources.lib.modules import cache cache.cache_clear() control.infoDialog(control.lang(32057).encode('utf-8'), sound=True, icon='INFO')
def onPlayBackStarted(self): control.sleep(200) control.idle()
def accountCheck(self): if traktCredentials == False and imdbCredentials == False: control.idle() control.infoDialog(control.lang(32042).encode('utf-8'), sound=True, icon='WARNING') sys.exit()
def channelDirectory(self, items): if items == None or len(items) == 0: control.idle() ; sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) addonPoster, addonBanner = control.addonPoster(), control.addonBanner() addonFanart, settingFanart = control.addonFanart(), control.setting('fanart') try: isOld = False ; control.item().getArt('type') except: isOld = True isPlayable = 'true' if not 'plugin' in control.infoLabel('Container.PluginName') else 'false' playbackMenu = control.lang(32063).encode('utf-8') if control.setting('hosts.mode') == '2' else control.lang(32064).encode('utf-8') queueMenu = control.lang(32065).encode('utf-8') refreshMenu = control.lang(32072).encode('utf-8') for i in items: try: label = '[B]%s[/B] : %s (%s)' % (i['channel'].upper(), i['title'], i['year']) sysname = urllib.quote_plus('%s (%s)' % (i['title'], i['year'])) systitle = urllib.quote_plus(i['title']) imdb, tmdb, year = i['imdb'], i['tmdb'], i['year'] meta = dict((k,v) for k, v in i.iteritems() if not v == '0') meta.update({'code': imdb, 'imdbnumber': imdb, 'imdb_id': imdb}) meta.update({'tmdb_id': tmdb}) meta.update({'mediatype': 'movie'}) meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)}) #meta.update({'trailer': 'plugin://script.extendedinfo/?info=playtrailer&&id=%s' % imdb}) meta.update({'playcount': 0, 'overlay': 6}) try: meta.update({'genre': cleangenre.lang(meta['genre'], self.lang)}) except: pass sysmeta = urllib.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.quote_plus(url) cm = [] cm.append((queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon)) cm.append((refreshMenu, 'RunPlugin(%s?action=refresh)' % sysaddon)) cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta))) if isOld == True: cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)')) item = control.item(label=label) art = {} if 'poster2' in i and not i['poster2'] == '0': art.update({'icon': i['poster2'], 'thumb': i['poster2'], 'poster': i['poster2']}) elif 'poster' in i and not i['poster'] == '0': art.update({'icon': i['poster'], 'thumb': i['poster'], 'poster': i['poster']}) else: art.update({'icon': addonPoster, 'thumb': addonPoster, 'poster': addonPoster}) art.update({'banner': addonBanner}) if settingFanart == 'true' and 'fanart' in i and not i['fanart'] == '0': item.setProperty('Fanart_Image', i['fanart']) elif not addonFanart == None: item.setProperty('Fanart_Image', addonFanart) item.setArt(art) item.addContextMenuItems(cm) item.setProperty('IsPlayable', isPlayable) item.setInfo(type='Video', infoLabels = meta) video_streaminfo = {'codec': 'h264'} item.addStreamInfo('video', video_streaminfo) control.addItem(handle=syshandle, url=url, listitem=item, isFolder=False) except: pass control.content(syshandle, 'files') control.directory(syshandle, cacheToDisc=True)
def channel_directory(self, items): if items is None or len(items) == 0: control.idle() sys.exit() sysaddon = sys.argv[0] syshandle = int(sys.argv[1]) try: isOld = False control.item().getArt('type') except: isOld = True refreshMenu = control.lang(32072).encode('utf-8') list_items = [] for order, channel in enumerate(items): label = channel['name'] meta = channel meta.update( { 'mediatype': channel['mediatype'] if 'mediatype' in channel else 'tvshow' } ) # string - "video", "movie", "tvshow", "season", "episode" or "musicvideo" meta.update({'playcount': 0, 'overlay': 6}) meta.update({'duration': channel['duration'] }) if 'duration' in channel else None meta.update({'title': channel['title'] }) if 'title' in channel else None meta.update({'tagline': channel['tagline'] }) if 'tagline' in channel else None sysmeta = urllib.quote_plus(json.dumps(meta)) id_globo_videos = channel['id'] brplayprovider = channel[ 'brplayprovider'] if 'brplayprovider' in channel else None isFolder = channel[ 'isFolder'] == 'true' if 'isFolder' in channel else False isPlayable = channel[ 'playable'] == 'true' if 'playable' in channel else False url = channel[ 'url'] if 'url' in channel else '%s?action=playlive&provider=%s&id_globo_videos=%s&isFolder=%s&meta=%s&t=%s' % ( sysaddon, brplayprovider, id_globo_videos, isFolder, sysmeta, self.systime) cm = [(refreshMenu, 'RunPlugin(%s?action=refresh)' % sysaddon)] if isOld is True: cm.append( (control.lang2(19033).encode('utf-8'), 'Action(Info)')) item = control.item(label=label) fanart = channel['fanart'] art = {'icon': channel['logo'], 'fanart': fanart} if 'poster' in channel: art.update({'poster': channel['poster']}) if 'banner' in channel: art.update({'banner': channel['banner']}) if 'clearart' in channel: art.update({'clearart': channel['clearart']}) if 'clearlogo' in channel: art.update({'clearlogo': channel['clearlogo']}) if 'landscape' in channel: art.update({'landscape': channel['landscape']}) if 'thumb' in channel: art.update({'thumb': channel['thumb']}) item.setArt(art) if 'logo' in channel and 'logo2' in channel: item.setProperty('Logo1', channel['logo']) item.setProperty('Logo2', channel['logo2']) item.setProperty('Initials1', channel['initials1']) item.setProperty('Initials2', channel['initials2']) if 'live' in channel: item.setProperty('Live', str(channel['live'])) if 'gamedetails' in channel: item.setProperty('GameDetails', channel['gamedetails']) item.setProperty('Fanart_Image', fanart) if 'hd' not in channel or channel['hd'] == True: video_info = {'aspect': 1.78, 'width': 1280, 'height': 720} else: video_info = {'aspect': 1.78, 'width': 720, 'height': 480} item.addStreamInfo('video', video_info) item.addContextMenuItems(cm) item.setProperty('IsPlayable', 'false' if isFolder or not isPlayable else 'true') item.setInfo(type='video', infoLabels=meta) item.setContentLookup(False) if 'duration' in channel and channel['duration'] is not None: duration = float(meta['duration']) startdate = util.strptime_workaround( channel['dateadded'], '%Y-%m-%d %H:%M:%S') if 'dateadded' in channel else None offset = float( util.get_total_seconds(datetime.datetime.now() - startdate)) if startdate else 0 item.setProperty( 'Progress', str((offset / duration) * 100) if duration else str(0)) item.setProperty('totaltime', str(duration)) # if not isFolder: # item.setMimeType("application/vnd.apple.mpegurl") list_items.append((url, item, isFolder)) # control.addSortMethod(int(sys.argv[1]), control.SORT_METHOD_DATEADDED) # control.addSortMethod(int(sys.argv[1]), control.SORT_METHOD_VIDEO_SORT_TITLE) # control.addSortMethod(int(sys.argv[1]), control.SORT_METHOD_LABEL_IGNORE_FOLDERS) control.addItems(syshandle, list_items) control.category(handle=syshandle, category="Live") content = 'LiveTV' if control.isJarvis else 'tvshows' control.content(syshandle, content) control.directory(syshandle, cacheToDisc=False)
def accountCheck(self): if traktCredentials == False and imdbCredentials == False: control.idle() control.infoDialog(control.lang(32042), sound=True, icon='WARNING')
def download(name, iconimage, url): from resources.lib.modules import control control.busy() import json if url is None: control.idle() return try: url = evaluate(url) # xbmc.log('URL-EVALUATE: %s' % url) except Exception: control.idle() xbmcgui.Dialog().ok(NAME, 'Download failed', 'Your service can\'t resolve this hoster', 'or Link is down') return try: headers = dict(parse_qsl(url.rsplit('|', 1)[1])) except BaseException: headers = dict('') control.idle() title = re.sub('\[.+?\]', '', name) content = re.compile('(.+?)\s+[\.|\(|\[]S(\d+)E\d+[\.|\)|\]]', re.I).findall(title) transname = title.translate(None, '\/:*?"<>|').strip('.') transname = re.sub('\[.+?\]', '', transname) levels = ['../../../..', '../../..', '../..', '..'] if len(content) == 0: dest = control.setting('movie.download.path') dest = control.transPath(dest) for level in levels: try: control.makeFile(os.path.abspath(os.path.join(dest, level))) except: pass control.makeFile(dest) dest = os.path.join(dest, transname) control.makeFile(dest) else: dest = control.setting('tv.download.path') dest = control.transPath(dest) for level in levels: try: control.makeFile(os.path.abspath(os.path.join(dest, level))) except: pass control.makeFile(dest) tvtitle = re.sub('\[.+?\]', '', content[0]) transtvshowtitle = tvtitle.translate(None, '\/:*?"<>|').strip('.') dest = os.path.join(dest, transtvshowtitle) control.makeFile(dest) dest = os.path.join(dest, 'Season %01d' % int(content[0][1])) control.makeFile(dest) control.idle() # ext = os.path.splitext(urlparse(url).path)[1] ext = os.path.splitext(urlparse(url).path)[1][1:] # xbmc.log('URL-EXT: %s' % ext) if not ext in ['mp4', 'mkv', 'flv', 'avi', 'mpg']: ext = 'mp4' dest = os.path.join(dest, transname + '.' + ext) headers = quote_plus(json.dumps(headers)) # xbmc.log('URL-HEADERS: %s' % headers) from resources.lib.modules import downloader control.idle() downloader.doDownload(url, dest, name, iconimage, headers)