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 play(self, name, url=None, windowedtrailer=0): try: url = self.worker(name, url) if not url: return title = control.infoLabel('listitem.title') if not 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, windowedtrailer) if windowedtrailer == 1: # The call to the play() method is non-blocking. So we delay further script execution to keep the script alive at this spot. # Otherwise this script will continue and probably already be garbage collected by the time the trailer has ended. control.sleep( 1000 ) # Wait until playback starts. Less than 900ms is too short (on my box). Make it one second. while control.player.isPlayingVideo(): control.sleep(1000) # Close the dialog. # Same behaviour as the fullscreenvideo window when : # the media plays to the end, # or the user pressed one of X, ESC, or Backspace keys on the keyboard/remote to stop playback. control.execute("Dialog.Close(%s, true)" % control.getCurrentDialogId) except: pass
def startDownload(): if downloadPath == '': return control.infoDialog( 'You need to set your download folder in addon settings first', 'File Not Downloadable') control.execute('RunPlugin(%s?action=startDownloadThread)' % sys.argv[0])
def play(self, name='', url='', windowedtrailer=0): try: url = self.worker(name, url) if not url: return title = control.infoLabel('ListItem.Title') if not title: title = control.infoLabel('ListItem.Label') icon = control.infoLabel('ListItem.Icon') item = control.item(label=name, iconImage=icon, thumbnailImage=icon, path=url) item.setInfo(type="Video", infoLabels={"Title": name}) item.setProperty('IsPlayable', 'true') control.resolve(handle=int(sys.argv[1]), succeeded=True, listitem=item) if windowedtrailer == 1: # The call to the play() method is non-blocking. So we delay further script execution to keep the script alive at this spot. # Otherwise this script will continue and probably already be garbage collected by the time the trailer has ended. control.sleep( 1000 ) # Wait until playback starts. Less than 900ms is too short (on my box). Make it one second. while control.player.isPlayingVideo(): control.sleep(1000) # Close the dialog. # Same behaviour as the fullscreenvideo window when : # the media plays to the end, # or the user pressed one of X, ESC, or Backspace keys on the keyboard/remote to stop playback. control.execute("Dialog.Close(%s, true)" % control.getCurrentDialogId) except: pass
def syncTraktLibrary(): control.execute( 'RunPlugin(plugin://%s)' % 'plugin.video.fanfilm/?action=tvshowsToLibrarySilent&url=traktcollection' ) control.execute( 'RunPlugin(plugin://%s)' % 'plugin.video.fanfilm/?action=moviesToLibrarySilent&url=traktcollection' )
def add(self, name, title, year, imdb, tmdb, range=False): if not control.condVisibility('Window.IsVisible(infodialog)') and not control.condVisibility('Player.HasVideo')\ and self.silentDialog is False: control.infoDialog(control.lang(32552).encode('utf-8'), time=10000000) self.infoDialog = True try: if not self.dupe_setting == 'true': raise Exception() id = [imdb, tmdb] if not tmdb == '0' else [imdb] lib = control.jsonrpc( '{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovies", "params": {"filter":{"or": [{"field": "year", "operator": "is", "value": "%s"}, {"field": "year", "operator": "is", "value": "%s"}, {"field": "year", "operator": "is", "value": "%s"}]}, "properties" : ["imdbnumber", "originaltitle", "year"]}, "id": 1}' % (year, str(int(year) + 1), str(int(year) - 1))) lib = unicode(lib, 'utf-8', errors='ignore') lib = json.loads(lib)['result']['movies'] lib = [ i for i in lib if str(i['imdbnumber']) in id or (i['originaltitle'].encode( 'utf-8') == title and str(i['year']) == year) ][0] except: lib = [] files_added = 0 try: if not lib == []: raise Exception() if self.check_setting == 'true': src = lib_tools.check_sources(title, year, imdb, None, None, None, None, None) if not src: raise Exception() self.strmFile({ 'name': name, 'title': title, 'year': year, 'imdb': imdb, 'tmdb': tmdb }) files_added += 1 except: pass if range == True: return 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 list_episodes(nazwaSerii, wersja, fanart): lista = [] lista_tytulow = [] ocena = [] cookie = cache.cache_get('strefadb_cookie')['value'] if type(cookie) is dict: cookie = cookie['value'] HEADERS['Cookie'] = cookie url = 'https://strefadb.pl/odcinki/' + nazwaSerii + '.html' result = s.get(url, headers=HEADERS).content test = client.parseDOM(result, 'ul', attrs={'class': 'lista-odcinkow'}) test = client.parseDOM(test, 'li') for item in test: if 'a href' in item and '?typ' not in item and not 'ul class' in item: lista.append(item) for item in lista: try: item = client.parseDOM(item, 'a') lista_tytulow.append(str(item[0])) ocena.append(float(lista_tytulow[-1][-5:-1])) lista_tytulow[-1] = lista_tytulow[-1][:-7] except: pass i = 1 while i < len(lista_tytulow) + 1: url = 'https://strefadb.pl/odcinki/' + nazwaSerii + '-' + str( i) + '.html' addon.addDir(str(i) + ' ' + str(lista_tytulow[i - 1]), url, mode='ListowanieLinkow', fanart=fanart, rating=ocena[i - 1]) i += 1 skin = control.skin if 'titan' in skin: control.execute('Container.SetViewMode(51)')
def setView(content, viewDict=None): for i in range(0, 200): if control.condVisibility('Container.Content(%s)' % content): try: skin = control.skin record = (skin, content) dbcon = database.connect(control.viewsFile) dbcur = dbcon.cursor() dbcur.execute( "SELECT * FROM views WHERE skin = '%s' AND view_type = '%s'" % (record[0], record[1])) view = dbcur.fetchone() view = view[2] if view == None: raise Exception() return control.execute('Container.SetViewMode(%s)' % str(view)) except: try: return control.execute('Container.SetViewMode(%s)' % str(viewDict[skin])) except: return control.sleep(100)
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)) 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 add(self, tvshowtitle, year, imdb, tvdb, range=False): if not control.condVisibility('Window.IsVisible(infodialog)') and not control.condVisibility('Player.HasVideo')\ and self.silentDialog is False: control.infoDialog(control.lang(32552).encode('utf-8'), time=10000000) self.infoDialog = True from resources.lib.indexers import episodes items = episodes.episodes().get(tvshowtitle, year, imdb, tvdb, idx=False) try: items = [{ '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 items] except: items = [] try: if not self.dupe_setting == 'true': raise Exception() if items == []: raise Exception() id = [items[0]['imdb'], items[0]['tvdb']] 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'] lib = [ i['title'].encode('utf-8') for i in lib if str(i['imdbnumber']) in id or ( i['title'].encode('utf-8') == items[0]['tvshowtitle'] and str(i['year']) == items[0]['year']) ][0] lib = control.jsonrpc( '{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"filter":{"and": [{"field": "tvshow", "operator": "is", "value": "%s"}]}, "properties": ["season", "episode"]}, "id": 1}' % lib) lib = unicode(lib, 'utf-8', errors='ignore') lib = json.loads(lib)['result']['episodes'] lib = [ 'S%02dE%02d' % (int(i['season']), int(i['episode'])) for i in lib ] items = [ i for i in items if not 'S%02dE%02d' % (int(i['season']), int(i['episode'])) in lib ] except: pass files_added = 0 for i in items: try: if xbmc.abortRequested == True: return sys.exit() if self.check_setting == 'true': if i['episode'] == '1': self.block = True src = lib_tools.check_sources(i['title'], i['year'], i['imdb'], i['tvdb'], i['season'], i['episode'], i['tvshowtitle'], i['premiered']) if src: self.block = False if self.block == True: raise Exception() 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 self.strmFile(i) files_added += 1 except: pass if range == True: return if self.infoDialog is 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)')
the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ from ptw.libraries import log_utils from ptw.libraries import control import threading control.execute('RunPlugin(plugin://%s)' % control.get_plugin_url({'action': 'service'})) def syncTraktLibrary(): control.execute( 'RunPlugin(plugin://%s)' % 'plugin.video.fanfilm/?action=tvshowsToLibrarySilent&url=traktcollection' ) control.execute( 'RunPlugin(plugin://%s)' % 'plugin.video.fanfilm/?action=moviesToLibrarySilent&url=traktcollection' ) try: MediaVersion = control.addon('script.fanfilm.media').getAddonInfo(
def endCategory(): if control.skin == 'skin.confluence': control.execute('Container.SetViewMode(500)') control.directory(int(sys.argv[1]), cacheToDisc=True)
def onPlayBackStarted(self): control.execute('Dialog.Close(all,true)') if not self.offset == '0': self.seekTime(float(self.offset)) subtitles().get(self.name, self.imdb, self.season, self.episode) self.idleForPlayback()
try: control.infoDialog(rlist[rand]['title'], control.lang(32536).encode('utf-8'), time=30000) except: pass elif rtype == "episode": try: control.infoDialog(rlist[rand]['tvshowtitle'] + " - Season " + rlist[rand]['season'] + " - " + rlist[rand]['title'], control.lang(32536).encode('utf-8'), time=30000) except: pass control.execute('RunPlugin(%s)' % r) except: control.infoDialog(control.lang(32537).encode('utf-8'), time=8000) elif action == 'movieToLibrary': from resources.lib.libraries import libtools libtools.libmovies().add(name, title, year, imdb, tmdb) elif action == 'moviesToLibrary': from resources.lib.libraries import libtools libtools.libmovies().range(url) elif action == 'moviesToLibrarySilent': from resources.lib.libraries import libtools libtools.libmovies().silent(url)
keys = request.redirect_dict.keys() except urllib2.HTTPError as response: if request.redirect_dict > 0: keys = request.redirect_dict.keys() pass except: continue reallink = '' if type(keys) == list: for key in keys: if not 'strefadb' in key: reallink = key else: reallink = keys o = urlparse(reallink) provider = str(o.netloc) addon.addLink(provider + " Lektor:" + lektor + " Napisy:" + napisy + " Jakość:" + quality, reallink, mode='OdpalanieLinku') skin = control.skin if 'titan' in skin: control.execute('Container.SetViewMode(51)') elif mode == 'OdpalanieLinku': OdpalanieLinku() ################################################################################### xbmcplugin.endOfDirectory(int(sys.argv[1]))