def addView(content): try: skin = control.skin skinPath = control.skinPath xml = os.path.join(skinPath,'addon.xml') file = control.openFile(xml) read = file.read().replace('\n','') file.close() try: src = re.compile('defaultresolution="(.+?)"').findall(read)[0] except: src = re.compile('<res.+?folder="(.+?)"').findall(read)[0] src = os.path.join(skinPath, src) src = os.path.join(src, 'MyVideoNav.xml') file = control.openFile(src) read = file.read().replace('\n','') file.close() views = re.compile('<views>(.+?)</views>').findall(read)[0] views = [int(x) for x in views.split(',')] for view in views: label = control.infoLabel('Control.GetLabel(%s)' % (view)) if not (label == '' or label == None): break record = (skin, content, str(view)) control.makeFile(control.dataPath) dbcon = database.connect(control.databaseFile) dbcur = dbcon.cursor() dbcur.execute("CREATE TABLE IF NOT EXISTS views (""skin TEXT, ""view_type TEXT, ""view_id TEXT, ""UNIQUE(skin, view_type)"");") dbcur.execute("DELETE FROM views WHERE skin = '%s' AND view_type = '%s'" % (record[0], record[1])) dbcur.execute("INSERT INTO views Values (?, ?, ?)", record) dbcon.commit() viewName = control.infoLabel('Container.Viewmode') control.infoDialog('This View is now Default', heading=viewName) except: return
def play(self, name, url=None): try: url = self.worker(name, url) if url == None: return title = control.infoLabel('listitem.title') if title == '': title = control.infoLabel('listitem.label') icon = control.infoLabel('listitem.icon') item = control.item(path=url, iconImage=icon, thumbnailImage=icon) try: item.setArt({'icon': icon}) except: pass item.setInfo(type='Video', infoLabels = {'title': title}) control.player.play(url, item) except: pass
def addView(content): try: skin = control.skin record = (skin, content, str(control.getCurrentViewId())) control.makeFile(control.dataPath) dbcon = database.connect(control.viewsFile) dbcur = dbcon.cursor() dbcur.execute("CREATE TABLE IF NOT EXISTS views" " (" "skin TEXT, " "view_type TEXT, " "view_id TEXT, " "UNIQUE(skin, view_type)" ");") dbcur.execute("DELETE FROM views WHERE skin = ? AND view_type = ?", ( record[0], record[1], )) dbcur.execute("INSERT INTO views Values (?, ?, ?)", record) dbcon.commit() viewName = control.infoLabel('Container.Viewmode') skinName = control.addon(skin).getAddonInfo('name') skinIcon = control.addon(skin).getAddonInfo('icon') control.infoDialog(viewName, heading=skinName, icon=skinIcon) except: return
def addView(content): try: skin = control.skin skinPath = control.skinPath xml = os.path.join(skinPath, 'addon.xml') file = control.openFile(xml) read = file.read().replace('\n', '') file.close() try: src = re.compile('defaultresolution="(.+?)"').findall(read)[0] except: src = re.compile('<res.+?folder="(.+?)"').findall(read)[0] src = os.path.join(skinPath, src) src = os.path.join(src, 'MyVideoNav.xml') file = control.openFile(src) read = file.read().replace('\n', '') file.close() views = re.compile('<views>(.+?)</views>').findall(read)[0] views = [int(x) for x in views.split(',')] for view in views: label = control.infoLabel('Control.GetLabel(%s)' % (view)) if not (label == '' or label == None): break record = (skin, content, str(view)) control.makeFile(control.dataPath) dbcon = database.connect(control.databaseFile) dbcur = dbcon.cursor() dbcur.execute("CREATE TABLE IF NOT EXISTS views (" "skin TEXT, " "view_type TEXT, " "view_id TEXT, " "UNIQUE(skin, view_type)" ");") dbcur.execute( "DELETE FROM views WHERE skin = '%s' AND view_type = '%s'" % (record[0], record[1])) dbcur.execute("INSERT INTO views Values (?, ?, ?)", record) dbcon.commit() viewName = control.infoLabel('Container.Viewmode') control.infoDialog('This View is now Default', heading=viewName) except: return
def getVideoInfo(self, content, name, imdb, tvdb): try: self.loadingTime = time.time() self.totalTime = 0 self.currentTime = 0 self.folderPath = control.infoLabel('Container.FolderPath') self.name = name self.content = content self.file = self.name + '.strm' self.file = self.file.translate(None, '\/:*?"<>|').strip('.') self.imdb = 'tt' + imdb if imdb.isdigit() else imdb self.tvdb = tvdb if not tvdb == None else '0' except: pass try: if self.content == 'movie': self.title, self.year = re.compile( '(.+?) [(](\d{4})[)]$').findall(self.name)[0] elif self.content == 'episode': self.show, self.season, self.episode = re.compile( '(.+?) S(\d*)E(\d*)$').findall(self.name)[0] self.season, self.episode = '%01d' % int( self.season), '%01d' % int(self.episode) except: pass try: if control.setting('resume_playback') == 'true': self.offset = bookmarks.getBookmark(self.name, self.imdb) if self.offset == '0': raise Exception() minutes, seconds = divmod(float(self.offset), 60) hours, minutes = divmod(minutes, 60) yes = control.yesnoDialog( '%s %02d:%02d:%02d' % (control.lang(30342).encode('utf-8'), hours, minutes, seconds), '', '', self.name, control.lang(30343).encode('utf-8'), control.lang(30344).encode('utf-8')) if yes: self.offset = '0' except: pass try: if self.content == 'movie': control.window.setProperty('script.trakt.ids', json.dumps({'imdb': self.imdb})) elif self.content == 'episode': control.window.setProperty('script.trakt.ids', json.dumps({'tvdb': self.tvdb})) except: pass
def getVideoInfo(self, content, name, imdb, tvdb): try: self.loadingTime = time.time() self.totalTime = 0 ; self.currentTime = 0 self.folderPath = control.infoLabel('Container.FolderPath') self.name = name ; self.content = content self.file = self.name + '.strm' self.file = self.file.translate(None, '\/:*?"<>|').strip('.') self.imdb = 'tt' + imdb if imdb.isdigit() else imdb self.tvdb = tvdb if not tvdb == None else '0' except: pass try: if self.content == 'movie': self.title, self.year = re.compile('(.+?) [(](\d{4})[)]$').findall(self.name)[0] elif self.content == 'episode': self.show, self.season, self.episode = re.compile('(.+?) S(\d*)E(\d*)$').findall(self.name)[0] self.season, self.episode = '%01d' % int(self.season), '%01d' % int(self.episode) except: pass try: if control.setting('resume_playback') == 'true': self.offset = bookmarks.getBookmark(self.name, self.imdb) if self.offset == '0': raise Exception() minutes, seconds = divmod(float(self.offset), 60) ; hours, minutes = divmod(minutes, 60) yes = control.yesnoDialog('%s %02d:%02d:%02d' % (control.lang(30342).encode('utf-8'), hours, minutes, seconds), '', '', self.name, control.lang(30343).encode('utf-8'), control.lang(30344).encode('utf-8')) if yes: self.offset = '0' except: pass try: if self.content == 'movie': control.window.setProperty('script.trakt.ids', json.dumps({'imdb': self.imdb})) elif self.content == 'episode': control.window.setProperty('script.trakt.ids', json.dumps({'tvdb': self.tvdb})) except: pass
def manager(name, imdb, tvdb, content): try: post = {"movies": [{"ids": {"imdb": imdb}}]} if content == 'movie' else {"shows": [{"ids": {"tvdb": tvdb}}]} items = [(control.lang(32516).encode('utf-8'), '/sync/collection')] items += [(control.lang(32517).encode('utf-8'), '/sync/collection/remove')] items += [(control.lang(32518).encode('utf-8'), '/sync/watchlist')] items += [(control.lang(32519).encode('utf-8'), '/sync/watchlist/remove')] items += [(control.lang(32520).encode('utf-8'), '/users/me/lists/%s/items')] result = getTraktAsJson('/users/me/lists') lists = [(i['name'], i['ids']['slug']) for i in result] lists = [lists[i//2] for i in range(len(lists)*2)] for i in range(0, len(lists), 2): lists[i] = ((control.lang(32521) % lists[i][0]).encode('utf-8'), '/users/me/lists/%s/items' % lists[i][1]) for i in range(1, len(lists), 2): lists[i] = ((control.lang(32522) % lists[i][0]).encode('utf-8'), '/users/me/lists/%s/items/remove' % lists[i][1]) items += lists select = control.selectDialog([i[0] for i in items], control.lang(32515).encode('utf-8')) if select == -1: return elif select == 4: t = control.lang(32520).encode('utf-8') k = control.keyboard('', t) ; k.doModal() new = k.getText() if k.isConfirmed() else None if (new == None or new == ''): return result = __getTrakt('/users/me/lists', post={"name": new, "privacy": "private"})[0] try: slug = utils.json_loads_as_str(result)['ids']['slug'] except: return control.infoDialog(control.lang(32515).encode('utf-8'), heading=str(name), sound=True, icon='ERROR') result = __getTrakt(items[select][1] % slug, post=post)[0] else: result = __getTrakt(items[select][1], post=post)[0] icon = control.infoLabel('ListItem.Icon') if not result == None else 'ERROR' control.infoDialog(control.lang(32515).encode('utf-8'), heading=str(name), sound=True, icon=icon) except: return