Пример #1
0
    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'],
                         i['tmdb'],
                         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)')
Пример #2
0
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])
Пример #3
0
    def listEpisodes(self, showid, page, image):
        url = self.episodes_link % (showid)
        try: result = client.request(url)
        except: pass
        result = re.compile('(.+?)]').findall(result)[0] + ']'
        shows = json.loads(result)

        self.list.append({'name': '[UPPERCASE][COLOR orange]Try again if a show does not play![/COLOR][/UPPERCASE]', 'url': '', 'image': ''})
        # episodes per page
        for show in shows:
            if 'Not Show' == show['item_title']:
                continue
            name = show['date_added'] + ' ' + show['item_title']
            u = self.player_link % (show['media_id'], show['media_item_id'])

            self.list.append({'name': name, 'url': urllib.quote_plus(u), 'image': image})

        for episode in self.list:
            name = episode['name']
            url = episode['url']
            image = episode['image']
            action = 'sourcePage2'
            query = '?action=%s&image=%s&url=%s&name=%s' % (action, image, url, name)

            url = '%s%s' % (sysaddon, query)
            item = control.item(name, iconImage=image, thumbnailImage=image)
            if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
            item.setInfo(type="Video", infoLabels={"Title": name, "OriginalTitle": name})
            control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False)

        control.content(int(sys.argv[1]), 'movies')
        if control.skin == 'skin.confluence': control.execute('Container.SetViewMode(50)')
        control.directory(int(sys.argv[1]), cacheToDisc=True)
Пример #4
0
    def range(self, url, query):
        if query == 'tool':
            return xbmc.executebuiltin('RunPlugin(%s?action=tvshowsToLibrary&url=%s)' % (sys.argv[0], urllib.quote_plus(url)))

        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 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['tmdb'], i['tvdb'], i['tvrage'], 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)')
Пример #5
0
def setView(content, viewDict=None):

    skin = control.skin
    for i in range(0, 200):
        if control.condVisibility('Container.Content(%s)' % content):
            try:
                record = (skin, content)
                dbcon = database.connect(control.databaseFile)
                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
        else:
            try:
                return control.execute('Container.SetViewMode(%s)' %
                                       str(viewDict[skin]))
            except:
                return
        control.sleep(100)
Пример #6
0
    def add(self, name, title, year, imdb, tmdb, range=False):
        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

        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 = []

        try:
            if not lib == []: raise Exception()

            if self.check_setting == 'true':
                from resources.lib.sources import sources
                src = sources().checkSources(name, title, year, imdb, tmdb, '0', '0', None, None, None, '0', None)
                if src == False: raise Exception()

            self.strmFile({'name': name, 'title': title, 'year': year, 'imdb': imdb, 'tmdb': tmdb})
        except:
            pass

        if range == True: return

        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)')
Пример #7
0
    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"], i["tmdb"], 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)")
Пример #8
0
    def add(self, tvshowtitle, year, imdb, tmdb, tvdb, tvrage, range=False):
        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 episodes
        items = episodes.episodes().get(tvshowtitle, year, imdb, tmdb, tvdb, tvrage, idx=False)

        try: items = [{'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 items]
        except: items = []

        try:
            if not self.dupe_setting == 'true': raise Exception()
            if items == []: raise Exception()

            id = [items[0]['imdb'], items[0]['tvdb']]
            if not items[0]['tmdb'] == '0': id += [items[0]['tmdb']]

            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

        for i in items:
            try:
                if xbmc.abortRequested == True: return sys.exit()

                if self.check_setting == 'true':
                    if i['episode'] == '1':
                        self.block = True
                        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'])
                        if src == True: self.block = False
                    if self.block == True: raise Exception()

                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'])
                    if src == False: raise Exception()

                self.strmFile(i)
            except:
                pass

        if range == True: return

        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)')
Пример #9
0
    def add(self, tvshowtitle, year, imdb, tmdb, tvdb, tvrage, range=False):
        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 episodes
        items = episodes.episodes().get(tvshowtitle, year, imdb, tmdb, tvdb, tvrage, idx=False)

        try: items = [{'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 items]
        except: items = []

        try:
            if not self.dupe_setting == 'true': raise Exception()
            if items == []: raise Exception()

            id = [items[0]['imdb'], items[0]['tvdb']]
            if not items[0]['tmdb'] == '0': id += [items[0]['tmdb']]

            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

        for i in items:
            try:
                if xbmc.abortRequested == True: return sys.exit()

                if self.check_setting == 'true':
                    if i['episode'] == '1':
                        self.block = True
                        from resources.lib.sources import sources
                        src = sources().getSources(i['name'], i['title'], i['year'], i['imdb'], i['tmdb'], i['tvdb'], i['tvrage'], i['season'], i['episode'], i['tvshowtitle'], i['alter'], i['date'])
                        if len(src) > 0: self.block = False
                    if self.block == True: raise Exception()

                if int(self.date) <= int(re.sub('[^0-9]', '', str(i['date']))):
                    from resources.lib.sources import sources
                    src = sources().getSources(i['name'], i['title'], i['year'], i['imdb'], i['tmdb'], i['tvdb'], i['tvrage'], i['season'], i['episode'], i['tvshowtitle'], i['alter'], i['date'])
                    if not len(src) > 0: raise Exception()

                self.strmFile(i)
            except:
                pass

        if range == True: return

        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)')
Пример #10
0
    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:
            control.log('## ITEMS %s' % i['title'])

        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:
            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)')
Пример #11
0
 def onPlayBackStarted(self):
     while not self.isPlayingVideo():
         xbmc.sleep(1000)
     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()
Пример #12
0
    def add(self, name, title, year, imdb, tmdb, range=False):
        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

        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 = []

        try:
            if not lib == []: raise Exception()

            if self.check_setting == 'true':
                from resources.lib.sources import sources
                src = sources().getSources(name, title, year, imdb, tmdb, '0', '0', None, None, None, '0', None)
                if not len(src) > 0: raise Exception()

            self.strmFile({'name': name, 'title': title, 'year': year, 'imdb': imdb, 'tmdb': tmdb})
        except:
            pass

        if range == True: return

        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)')
Пример #13
0
    def range(self, url, query):
        if query == 'tool':
            return xbmc.executebuiltin('RunPlugin(%s?action=moviesToLibrary&url=%s)' % (sys.argv[0], urllib.quote_plus(url)))

        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'], i['tmdb'], 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)')
Пример #14
0
Файл: thai.py Проект: mpie/repo
    def listShows(self, catid, page):
        limatch = []
        url = self.shows_link % (catid)

        try: result = client.request(url)
        except: pass

        pageContent = ''.join(result.splitlines()).replace('\'','"')
        pages = re.compile('id="a_page_(.+?)" href').findall(pageContent)

        if str(page) in pages:
            pageUrl = self.shows_ajax_link % (catid, str(page))
            result = client.request(pageUrl)
            limatch+=re.compile('<figure>(.+?)</a></li>').findall(result)

        for li_content in limatch:
            show = re.compile('<a href=".+?id=(.+?)"><img src="(.+?)" alt="(.+?)" w').findall(li_content)
            #print show
            title = show[0][2].decode('iso-8859-11')
            showid = show[0][0]
            image = show[0][1]
            self.list.append({'name': title, 'showid': showid, 'image': image})

        for show in self.list:
            name = show['name'].encode('utf-8')
            showid = show['showid']
            image = show['image']
            action = 'listEpisodes'
            query = '?action=%s&name=%s&catid=%s&showid=%s&image=%s' % (action, name, catid, showid, image)
            url = '%s%s' % (sysaddon, query)
            item = control.item(name, iconImage=image, thumbnailImage=image)
            if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
            item.setInfo(type="Video", infoLabels={"Title": name, "OriginalTitle": name})
            control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)

        nextPage = int(page) + 1
        if nextPage <= len(pages):
            if 'first' in pages:
                pages.remove('first')
            if 'pre' in pages:
                pages.remove('pre')
            if 'next' in pages:
                pages.remove('next')
            if 'last' in pages:
                pages.remove('last')

            for page in pages:
                action = 'listShows'
                pageNumber = int(page) + 1
                query = '?action=%s&page=%d&name=%s&catid=%s' % (action, int(page), 'Page ' + str(pageNumber), catid)
                url = '%s%s' % (sysaddon, query)
                item = control.item('Page ' + str(pageNumber), iconImage='', thumbnailImage='')
                if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
                item.setInfo(type="Video", infoLabels={"Title": 'Page ' + str(pageNumber), "OriginalTitle": 'Page ' + str(pageNumber)})
                control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)

        control.content(int(sys.argv[1]), 'movies')
        if control.skin == 'skin.confluence': control.execute('Container.SetViewMode(500)')
        control.directory(int(sys.argv[1]), cacheToDisc=True)
Пример #15
0
    def play(self, name, title, year, imdb, tmdb, tvdb, tvrage, season,
             episode, tvshowtitle, alter, date, meta, url):
        control.log('############# PLAY # %s' % url)
        try:
            if not control.infoLabel('Container.FolderPath').startswith(
                    'plugin://'):
                control.playlist.clear()

            control.resolve(int(sys.argv[1]), True, control.item(path=''))
            control.execute('Dialog.Close(okdialog)')

            if imdb == '0': imdb = '0000000'
            imdb = 'tt' + re.sub('[^0-9]', '', str(imdb))

            content = 'movie' if tvshowtitle == None else 'episode'

            self.sources = self.getSources(name, title, year, imdb, tmdb, tvdb,
                                           tvrage, season, episode,
                                           tvshowtitle, alter, date)
            if self.sources == []: raise Exception()

            self.sources = self.sourcesFilter()

            if control.window.getProperty('PseudoTVRunning') == 'True':
                url = self.sourcesDirect()

            elif url == 'dialog://':
                url = self.sourcesDialog()

            elif url == 'direct://':
                url = self.sourcesDirect()

            elif not control.infoLabel('Container.FolderPath').startswith(
                    'plugin://') and control.setting(
                        'autoplay_library') == 'false':
                url = self.sourcesDialog()

            elif control.infoLabel('Container.FolderPath').startswith(
                    'plugin://') and control.setting('autoplay') == 'false':
                url = self.sourcesDialog()

            else:
                url = self.sourcesDirect()

            if url == None: raise Exception()
            if url == 'close://': return

            if control.setting('playback_info') == 'true':
                control.infoDialog(self.selectedSource, heading=name)

            control.sleep(200)

            from resources.lib.libraries.player import player
            player().run(content, name, url, year, imdb, tvdb, meta)

            return url
        except:
            control.infoDialog(control.lang(30501).encode('utf-8'))
Пример #16
0
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'
    )
Пример #17
0
    def alterSources(self, url, meta):
        try:
            setting = control.setting('autoplay')
            if setting == 'false': url += '&url=direct://'
            else: url += '&url=dialog://'

            control.execute('RunPlugin(%s)' % url)
        except:
            pass
Пример #18
0
    def alterSources(self, url, meta):
        try:
            setting = control.setting('autoplay')
            if setting == 'false': url += '&url=direct://'
            else: url += '&url=dialog://'

            control.execute('RunPlugin(%s)' % url)
        except:
            pass
Пример #19
0
    def play(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date, meta, url):
        try:
            if not control.infoLabel('Container.FolderPath').startswith('plugin://'):
                control.playlist.clear()
                control.resolve(int(sys.argv[1]), True, control.item(path=None))
                control.execute('Dialog.Close(okdialog)')

            if imdb == '0': imdb = '0000000'
            imdb = 'tt' + re.sub('[^0-9]', '', str(imdb))

            content = 'movie' if tvshowtitle == None else 'episode'

            self.sources = self.getSources(name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date)
            if self.sources == []: raise Exception()

            self.sources = self.sourcesFilter()

            if control.window.getProperty('PseudoTVRunning') == 'True':
                url = self.sourcesDirect()

            elif url == 'dialog://':
                url = self.sourcesDialog()

            elif url == 'direct://':
                url = self.sourcesDirect()

            elif not control.infoLabel('Container.FolderPath').startswith('plugin://') and control.setting('autoplay_library') == 'false':
                url = self.sourcesDialog()

            elif control.infoLabel('Container.FolderPath').startswith('plugin://') and control.setting('autoplay') == 'false':
                url = self.sourcesDialog()

            else:
                url = self.sourcesDirect()

            if url == None: raise Exception()
            if url == 'close://': return

            if control.setting('playback_info') == 'true':
                control.infoDialog(self.selectedSource, heading=name)

            try: self.progressDialog.close()
            except: pass

            control.sleep(200)

            from resources.lib.libraries.player import player
            player().run(content, name, url, year, imdb, tvdb, meta)

            return url
        except:
            control.infoDialog(control.lang(30501).encode('utf-8'))
Пример #20
0
    def listBollywood(self, url, page):
        try:
            html = client.request(url + 'page/' + str(page))
        except:
            pass

        result = client.parseDOM(html, 'article', attrs={'id': 'posts'})
        result = [(client.parseDOM(i, 'a', ret='href'),
                   client.parseDOM(i, 'img',
                                   ret='src'), client.parseDOM(i, 'a'))
                  for i in result]
        result = [(i[0][0], i[1][0], i[2][1]) for i in result
                  if len(i[0]) > 0 and len(i[1]) > 0 and len(i[2][1]) > 0]

        for movie in result:
            uri = movie[0]
            image = movie[1]
            name = movie[2]
            action = 'resolveBollywoodUrl'
            query = '%s?action=%s&name=%s&url=%s&image=%s' % (sysaddon, action,
                                                              name, uri, image)
            item = control.item(name, iconImage=image, thumbnailImage=image)
            item.setInfo(type="Video",
                         infoLabels={
                             "Title": name,
                             "OriginalTitle": name
                         })
            control.addItem(handle=int(sys.argv[1]),
                            url=query,
                            listitem=item,
                            isFolder=True)

        pageNum = int(page) + 1
        query = '%s?action=%s&url=%s&page=%s' % (sysaddon, 'listBollywood',
                                                 url, pageNum)
        print query
        item = control.item('Next page', iconImage='', thumbnailImage='')
        item.setInfo(type="Video",
                     infoLabels={
                         "Title": 'Page ' + str(page),
                         "OriginalTitle": 'Page ' + str(page)
                     })
        control.addItem(handle=int(sys.argv[1]),
                        url=query,
                        listitem=item,
                        isFolder=True)

        control.content(int(sys.argv[1]), 'movies')
        if control.skin == 'skin.confluence':
            control.execute('Container.SetViewMode(500)')
        control.directory(int(sys.argv[1]), cacheToDisc=True)
Пример #21
0
    def add(self, name, title, year, imdb, tmdb, range=False):
        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

        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 = []

        try:
            if not lib == []:
                raise Exception()

            if self.check_setting == "true":
                from resources.lib.sources import sources

                src = sources().checkSources(name, title, year, imdb, tmdb, "0", "0", None, None, None, "0", None)
                if src == False:
                    raise Exception()

            self.strmFile({"name": name, "title": title, "year": year, "imdb": imdb, "tmdb": tmdb})
        except:
            pass

        if range == True:
            return

        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)")
Пример #22
0
Файл: thai.py Проект: mpie/repo
    def listEpisodes(self, catid, showid, page, image):
        url = self.episodes_link % (page, showid)
        try: result = client.request(url)
        except: pass
        link = ''.join(result.splitlines()).replace('\'','"')
        link = ''.join(link.splitlines()).replace('<i class="icon-new"></i>','')

        episodematch = re.compile('<table class="program-archive">(.+?)</table>').findall(link)
        episodes = re.compile('<a href="(.+?)" >(.+?)</a>.+?</td>\t\t\t\t\t\t\t<td> \t\t\t\t\t\t\t\t<a href="(.+?)" ><img').findall(episodematch[0])

        programMeta = re.compile('<div class="program-meta">(.+?)</div>').findall(link)
        image = re.compile('<img src="(.+?)" alt').findall(programMeta[0])[0]

        # episodes per page
        for episode in episodes:
            name = episode[1].decode('iso-8859-11')
            u = 'http://www.seesantv.com/seesantv_2014/' + episode[0] + '&bitrate=high'
            self.list.append({'name': name, 'url': urllib.quote_plus(u), 'image': image})

        for episode in self.list:
            name = episode['name'].encode('utf-8')
            url = episode['url']
            image = episode['image']
            action = 'sourcePage'
            query = '?action=%s&image=%s&url=%s&name=%s' % (action, image, url, urllib.quote_plus(name))

            url = '%s%s' % (sysaddon, query)
            item = control.item(name, iconImage=image, thumbnailImage=image)
            if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
            item.setInfo(type="Video", infoLabels={"Title": name, "OriginalTitle": name})
            control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False)

        # Pagination
        paginator = re.compile('<div class="page_list"  align="center">(.+?)</ul>').findall(link)[0]
        pages = re.compile('>(\d+)</a>').findall(paginator)
        nextPage = int(page) + 1
        if nextPage < len(pages):
            action = 'listEpisodes'
            query = '?action=%s&page=%d&name=%s&catid=%s&showid=%s&image=%s' % (action, nextPage, 'Next Page', catid, showid, image)
            url = '%s%s' % (sysaddon, query)
            item = control.item('Next Page', iconImage=image, thumbnailImage=image)
            if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
            item.setInfo(type="Video", infoLabels={"Title": 'Next Page', "OriginalTitle": 'Next Page'})
            control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)

        control.content(int(sys.argv[1]), 'movies')
        if control.skin == 'skin.confluence': control.execute('Container.SetViewMode(50)')
        control.directory(int(sys.argv[1]), cacheToDisc=True)
Пример #23
0
Файл: views.py Проект: mpie/repo
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.databaseFile)
                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)
Пример #24
0
    def listShows(self, catid, page, limit, channel):
        url = self.shows_link % (page, limit, channel, catid)
        try: result = client.request(url)
        except: pass

        data = json.loads(result)
        paginationInfo = data['pagination']
        shows = data['data']

        for show in shows:
            title = show['media_title']
            showid = show['media_id']
            image = self.cdn % (show['image_file'])
            self.list.append({'name': title, 'showid': showid, 'image': image})

        for show in self.list:
            name = show['name']
            showid = show['showid']
            image = show['image']
            action = 'listEpisodes2'
            query = '?action=%s&name=%s&showid=%s&image=%s&page=1' % (action, name, showid, image)
            url = '%s%s' % (sysaddon, query)
            item = control.item(name, iconImage=image, thumbnailImage=image)
            if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
            item.setInfo(type="Video", infoLabels={"Title": name, "OriginalTitle": name})
            control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)

        nextPage = int(page) + 1
        if nextPage <= paginationInfo['totalPages']:
            for page in range(1, paginationInfo['totalPages']):
                action = 'listShows2'
                query = '?action=%s&page=%d&name=%s&catid=%s&limit=%s&channel=%s' % (action, page, 'Page ' + str(page), catid, limit, channel)
                url = '%s%s' % (sysaddon, query)
                item = control.item('Page ' + str(page), iconImage='', thumbnailImage='')
                if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
                item.setInfo(type="Video", infoLabels={"Title": 'Page ' + str(page), "OriginalTitle": 'Page ' + str(page)})
                control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)

        control.content(int(sys.argv[1]), 'movies')
        if control.skin == 'skin.confluence': control.execute('Container.SetViewMode(500)')
        control.directory(int(sys.argv[1]), cacheToDisc=True)
Пример #25
0
    def playItem(self, content, name, year, imdb, tvdb, source):
        try:
            control.resolve(int(sys.argv[1]), True, control.item(path=''))
            control.execute('Dialog.Close(okdialog)')

            next = [] ; prev = [] ; total = []
            meta = None

            for i in range(1,10000):
                try:
                    u = control.infoLabel('ListItem(%s).FolderPath' % str(i))
                    if u in total: raise Exception()
                    total.append(u)
                    u = dict(urlparse.parse_qsl(u.replace('?','')))
                    if 'meta' in u: meta = u['meta']
                    u = json.loads(u['source'])[0]
                    next.append(u)
                except:
                    break
            for i in range(-10000,0)[::-1]:
                try:
                    u = control.infoLabel('ListItem(%s).FolderPath' % str(i))
                    if u in total: raise Exception()
                    total.append(u)
                    u = dict(urlparse.parse_qsl(u.replace('?','')))
                    if 'meta' in u: meta = u['meta']
                    u = json.loads(u['source'])[0]
                    prev.append(u)
                except:
                    break

            items = json.loads(source)

            source, quality = items[0]['source'], items[0]['quality']
            items = [i for i in items+next+prev if i['quality'] == quality and i['source'] == source][:10]
            items += [i for i in next+prev if i['quality'] == quality and not i['source'] == source][:10]

            self.progressDialog = control.progressDialog
            self.progressDialog.create(control.addonInfo('name'), '')
            self.progressDialog.update(0)

            block = None

            for i in range(len(items)):
                try:
                    self.progressDialog.update(int((100 / float(len(items))) * i), str(items[i]['label']), str(' '))

                    if items[i]['source'] == block: raise Exception()

                    w = workers.Thread(self.sourcesResolve, items[i]['url'], items[i]['provider'])
                    w.start()

                    m = ''

                    for x in range(3600):
                        if self.progressDialog.iscanceled(): return self.progressDialog.close()
                        if xbmc.abortRequested == True: return sys.exit()
                        k = control.condVisibility('Window.IsActive(virtualkeyboard)')
                        if k: m += '1'; m = m[-1]
                        if (w.is_alive() == False or x > 30) and not k: break
                        time.sleep(1)

                    for x in range(30):
                        if m == '': break
                        if self.progressDialog.iscanceled(): return self.progressDialog.close()
                        if xbmc.abortRequested == True: return sys.exit()
                        if w.is_alive() == False: break
                        time.sleep(1)


                    if w.is_alive() == True: block = items[i]['source']

                    if self.url == None: raise Exception()

                    try: self.progressDialog.close()
                    except: pass

                    control.sleep(200)

                    if control.setting('playback_info') == 'true':
                        control.infoDialog(items[i]['label'], heading=name)

                    from resources.lib.libraries.player import player
                    player().run(content, name, self.url, year, imdb, tvdb, meta)

                    return self.url
                except:
                    pass

            try: self.progressDialog.close()
            except: pass

            raise Exception()

        except:
            control.infoDialog(control.lang(30501).encode('utf-8'))
            pass
Пример #26
0
    def resolve(self, url):
        try:
            m3u8 = [
                '#EXTM3U',
                '#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",DEFAULT=YES,AUTOSELECT=YES,NAME="Stream 1",URI="{audio_stream}"',
                '',
                '#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=0,NAME="{stream_name}",AUDIO="audio"',
                '{video_stream}'
                ]


            query = urlparse.parse_qs(url)
            query = dict([(key, query[key][0]) if query[key] else (key, '') for key in query])

            auth = 'http://streamtorrent.tv/api/torrent/%s/%s.m3u8?json=true' % (query['vid_id'], query['stream_id'])

            r = client.request(auth)
            r = json.loads(r)
            try: url = r['url']
            except: url = None


            if not url == None:

                def dialog(url):
                    try: self.disableScraper = control.yesnoDialog('To watch this video visit from any device', '[COLOR skyblue]%s[/COLOR]' % url, '', 'Torba', 'Cancel', 'Settings')
                    except: pass

                workers.Thread(dialog, url).start()
                control.sleep(3000)

                for i in range(100):
                    try:
                        if not control.condVisibility('Window.IsActive(yesnoDialog)'): break

                        r = client.request(auth)
                        r = json.loads(r)
                        try: url = r['url']
                        except: url = None

                        if url == None: break

                        workers.Thread(dialog, url).start()
                        control.sleep(3000)
                    except:
                        pass

                if self.disableScraper:
                    control.openSettings(query='2.0')
                    return ''

                control.execute('Dialog.Close(yesnoDialog)')


            if not url == None: return


            stream_name = '%sp' % (query['height'])
            video_stream = r[stream_name]

            if not 'audio' in r: return video_stream

            audio_stream = r['audio']

            content = ('\n'.join(m3u8)).format(**{'audio_stream': audio_stream, 'stream_name': stream_name, 'video_stream': video_stream})


            path = os.path.join(control.dataPath, 'torbase.m3u8')

            control.makeFile(control.dataPath) ; control.deleteFile(path)

            file = control.openFile(path, 'w') ; file.write(content) ; file.close()

            return path
        except:
            return
Пример #27
0
    (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/>.
"""
import threading

from resources.lib.libraries import control
from resources.lib.libraries import log_utils

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(
Пример #28
0
            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
Пример #29
0
    def update(self, query, info='true'):
        if query == 'tool':
            return xbmc.executebuiltin('RunPlugin(%s?action=updateLibrary)' % sys.argv[0])

        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().getSources(i['name'], i['title'], i['year'], i['imdb'], i['tmdb'], i['tvdb'], i['tvrage'], i['season'], i['episode'], i['tvshowtitle'], i['alter'], i['date'])
                        if not len(src) > 2: 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)')
Пример #30
0
    def add(self, tvshowtitle, year, imdb, tmdb, tvdb, tvrage, range=False):
        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 episodes

        items = episodes.episodes().get(tvshowtitle, year, imdb, tmdb, tvdb, tvrage, idx=False)

        try:
            items = [
                {
                    "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 items
            ]
        except:
            items = []

        try:
            if not self.dupe_setting == "true":
                raise Exception()
            if items == []:
                raise Exception()

            id = [items[0]["imdb"], items[0]["tvdb"]]
            if not items[0]["tmdb"] == "0":
                id += [items[0]["tmdb"]]

            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

        for i in items:
            try:
                if xbmc.abortRequested == True:
                    return sys.exit()

                if self.check_setting == "true":
                    if i["episode"] == "1":
                        self.block = True
                        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"],
                        )
                        if src == True:
                            self.block = False
                    if self.block == True:
                        raise Exception()

                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"],
                    )
                    if src == False:
                        raise Exception()

                self.strmFile(i)
            except:
                pass

        if range == True:
            return

        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)")
Пример #31
0
    def listShows(self, catid, page):
        limatch = []
        url = self.shows_link % (catid)

        try:
            result = client.request(url)
        except:
            pass

        pageContent = ''.join(result.splitlines()).replace('\'', '"')
        pages = re.compile('id="a_page_(.+?)" href').findall(pageContent)

        if str(page) in pages:
            pageUrl = self.shows_ajax_link % (catid, str(page))
            result = client.request(pageUrl)
            limatch += re.compile('<figure>(.+?)</a></li>').findall(result)

        for li_content in limatch:
            show = re.compile(
                '<a href=".+?id=(.+?)"><img src="(.+?)" alt="(.+?)" w'
            ).findall(li_content)
            #print show
            title = show[0][2].decode('iso-8859-11')
            showid = show[0][0]
            image = show[0][1]
            self.list.append({'name': title, 'showid': showid, 'image': image})

        for show in self.list:
            name = show['name'].encode('utf-8')
            showid = show['showid']
            image = show['image']
            action = 'listEpisodes'
            query = '?action=%s&name=%s&catid=%s&showid=%s&image=%s' % (
                action, name, catid, showid, image)
            url = '%s%s' % (sysaddon, query)
            item = control.item(name, iconImage=image, thumbnailImage=image)
            if not addonFanart == None:
                item.setProperty('Fanart_Image', addonFanart)
            item.setInfo(type="Video",
                         infoLabels={
                             "Title": name,
                             "OriginalTitle": name
                         })
            control.addItem(handle=int(sys.argv[1]),
                            url=url,
                            listitem=item,
                            isFolder=True)

        nextPage = int(page) + 1
        if nextPage <= len(pages):
            if 'first' in pages:
                pages.remove('first')
            if 'pre' in pages:
                pages.remove('pre')
            if 'next' in pages:
                pages.remove('next')
            if 'last' in pages:
                pages.remove('last')

            for page in pages:
                action = 'listShows'
                pageNumber = int(page) + 1
                query = '?action=%s&page=%d&name=%s&catid=%s' % (
                    action, int(page), 'Page ' + str(pageNumber), catid)
                url = '%s%s' % (sysaddon, query)
                item = control.item('Page ' + str(pageNumber),
                                    iconImage='',
                                    thumbnailImage='')
                if not addonFanart == None:
                    item.setProperty('Fanart_Image', addonFanart)
                item.setInfo(type="Video",
                             infoLabels={
                                 "Title": 'Page ' + str(pageNumber),
                                 "OriginalTitle": 'Page ' + str(pageNumber)
                             })
                control.addItem(handle=int(sys.argv[1]),
                                url=url,
                                listitem=item,
                                isFolder=True)

        control.content(int(sys.argv[1]), 'movies')
        if control.skin == 'skin.confluence':
            control.execute('Container.SetViewMode(500)')
        control.directory(int(sys.argv[1]), cacheToDisc=True)
def endCategory():
    if control.skin == 'skin.confluence': control.execute('Container.SetViewMode(500)')
    control.directory(int(sys.argv[1]), cacheToDisc=True)
Пример #33
0
    def resolve(self, url):
        try:
            m3u8 = [
                '#EXTM3U',
                '#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",DEFAULT=YES,AUTOSELECT=YES,NAME="Stream 1",URI="{audio_stream}"',
                '',
                '#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=0,NAME="{stream_name}",AUDIO="audio"',
                '{video_stream}'
            ]

            query = urlparse.parse_qs(url)
            query = dict([(key, query[key][0]) if query[key] else (key, '')
                          for key in query])

            auth = 'http://streamtorrent.tv/api/torrent/%s/%s.m3u8?json=true' % (
                query['vid_id'], query['stream_id'])

            r = client.request(auth)
            r = json.loads(r)
            try:
                url = r['url']
            except:
                url = None

            if not url == None:

                def dialog(url):
                    try:
                        self.disableScraper = control.yesnoDialog(
                            'To watch this video visit from any device',
                            '[COLOR skyblue]%s[/COLOR]' % url, '', 'Torba',
                            'Cancel', 'Settings')
                    except:
                        pass

                workers.Thread(dialog, url).start()
                control.sleep(3000)

                for i in range(100):
                    try:
                        if not control.condVisibility(
                                'Window.IsActive(yesnoDialog)'):
                            break

                        r = client.request(auth)
                        r = json.loads(r)
                        try:
                            url = r['url']
                        except:
                            url = None

                        if url == None: break

                        workers.Thread(dialog, url).start()
                        control.sleep(3000)
                    except:
                        pass

                if self.disableScraper:
                    control.openSettings(query='2.0')
                    return ''

                control.execute('Dialog.Close(yesnoDialog)')

            if not url == None: return

            stream_name = '%sp' % (query['height'])
            video_stream = r[stream_name]

            if not 'audio' in r: return video_stream

            audio_stream = r['audio']

            content = ('\n'.join(m3u8)).format(
                **{
                    'audio_stream': audio_stream,
                    'stream_name': stream_name,
                    'video_stream': video_stream
                })

            path = os.path.join(control.dataPath, 'torbase.m3u8')

            control.makeFile(control.dataPath)
            control.deleteFile(path)

            file = control.openFile(path, 'w')
            file.write(content)
            file.close()

            return path
        except:
            return
Пример #34
0
    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 movieCategory():
    control.content(int(sys.argv[1]), "movies")
    if control.skin == "skin.confluence":
        control.execute("Container.SetViewMode(500)")
    control.directory(int(sys.argv[1]), cacheToDisc=True)
Пример #36
0
    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"],
                        )
                        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)")
Пример #37
0
    def playItem(self, content, name, year, imdb, tvdb, source):
        try:
            control.resolve(int(sys.argv[1]), True, control.item(path=''))
            control.execute('Dialog.Close(okdialog)')

            next = []
            prev = []
            total = []
            meta = None

            for i in range(1, 10000):
                try:
                    u = control.infoLabel('ListItem(%s).FolderPath' % str(i))
                    if u in total: raise Exception()
                    total.append(u)
                    u = dict(urlparse.parse_qsl(u.replace('?', '')))
                    if 'meta' in u: meta = u['meta']
                    u = json.loads(u['source'])[0]
                    next.append(u)
                except:
                    break
            for i in range(-10000, 0)[::-1]:
                try:
                    u = control.infoLabel('ListItem(%s).FolderPath' % str(i))
                    if u in total: raise Exception()
                    total.append(u)
                    u = dict(urlparse.parse_qsl(u.replace('?', '')))
                    if 'meta' in u: meta = u['meta']
                    u = json.loads(u['source'])[0]
                    prev.append(u)
                except:
                    break

            items = json.loads(source)

            source, quality = items[0]['source'], items[0]['quality']
            items = [
                i for i in items + next + prev
                if i['quality'] == quality and i['source'] == source
            ][:10]
            items += [
                i for i in next + prev
                if i['quality'] == quality and not i['source'] == source
            ][:10]

            self.progressDialog = control.progressDialog
            self.progressDialog.create(control.addonInfo('name'), '')
            self.progressDialog.update(0)

            block = None

            for i in range(len(items)):
                try:
                    self.progressDialog.update(
                        int((100 / float(len(items))) * i),
                        str(items[i]['label']), str(' '))

                    if items[i]['source'] == block: raise Exception()

                    w = workers.Thread(self.sourcesResolve, items[i]['url'],
                                       items[i]['provider'])
                    w.start()

                    m = ''

                    for x in range(3600):
                        if self.progressDialog.iscanceled():
                            return self.progressDialog.close()
                        if xbmc.abortRequested == True: return sys.exit()
                        k = control.condVisibility(
                            'Window.IsActive(virtualkeyboard)')
                        if k:
                            m += '1'
                            m = m[-1]
                        if (w.is_alive() == False or x > 30) and not k: break
                        time.sleep(1)

                    for x in range(30):
                        if m == '': break
                        if self.progressDialog.iscanceled():
                            return self.progressDialog.close()
                        if xbmc.abortRequested == True: return sys.exit()
                        if w.is_alive() == False: break
                        time.sleep(1)

                    if w.is_alive() == True: block = items[i]['source']

                    if self.url == None: raise Exception()

                    try:
                        self.progressDialog.close()
                    except:
                        pass

                    control.sleep(200)

                    if control.setting('playback_info') == 'true':
                        control.infoDialog(items[i]['label'], heading=name)

                    from resources.lib.libraries.player import player
                    player().run(content, name, self.url, year, imdb, tvdb,
                                 meta)

                    return self.url
                except:
                    pass

            try:
                self.progressDialog.close()
            except:
                pass

            raise Exception()

        except:
            control.infoDialog(control.lang(30501).encode('utf-8'))
            pass
Пример #38
0
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?mode=startDownloadThread)' % sys.argv[0])
Пример #39
0
def endCategory():
    if control.skin == 'skin.confluence':
        control.execute('Container.SetViewMode(500)')
    control.directory(int(sys.argv[1]), cacheToDisc=True)
Пример #40
0
    def listEpisodes(self, catid, showid, page, image):
        url = self.episodes_link % (page, showid)
        try:
            result = client.request(url)
        except:
            pass
        link = ''.join(result.splitlines()).replace('\'', '"')
        link = ''.join(link.splitlines()).replace('<i class="icon-new"></i>',
                                                  '')

        episodematch = re.compile(
            '<table class="program-archive">(.+?)</table>').findall(link)
        episodes = re.compile(
            '<a href="(.+?)" >(.+?)</a>.+?</td>\t\t\t\t\t\t\t<td> \t\t\t\t\t\t\t\t<a href="(.+?)" ><img'
        ).findall(episodematch[0])

        programMeta = re.compile(
            '<div class="program-meta">(.+?)</div>').findall(link)
        image = re.compile('<img src="(.+?)" alt').findall(programMeta[0])[0]

        # episodes per page
        for episode in episodes:
            name = episode[1].decode('iso-8859-11')
            u = 'http://www.seesantv.com/seesantv_2014/' + episode[
                0] + '&bitrate=high'
            self.list.append({
                'name': name,
                'url': urllib.quote_plus(u),
                'image': image
            })

        for episode in self.list:
            name = episode['name'].encode('utf-8')
            url = episode['url']
            image = episode['image']
            action = 'sourcePage'
            query = '?action=%s&image=%s&url=%s&name=%s' % (
                action, image, url, urllib.quote_plus(name))

            url = '%s%s' % (sysaddon, query)
            item = control.item(name, iconImage=image, thumbnailImage=image)
            if not addonFanart == None:
                item.setProperty('Fanart_Image', addonFanart)
            item.setInfo(type="Video",
                         infoLabels={
                             "Title": name,
                             "OriginalTitle": name
                         })
            control.addItem(handle=int(sys.argv[1]),
                            url=url,
                            listitem=item,
                            isFolder=False)

        # Pagination
        paginator = re.compile(
            '<div class="page_list"  align="center">(.+?)</ul>').findall(
                link)[0]
        pages = re.compile('>(\d+)</a>').findall(paginator)
        nextPage = int(page) + 1
        if nextPage < len(pages):
            action = 'listEpisodes'
            query = '?action=%s&page=%d&name=%s&catid=%s&showid=%s&image=%s' % (
                action, nextPage, 'Next Page', catid, showid, image)
            url = '%s%s' % (sysaddon, query)
            item = control.item('Next Page',
                                iconImage=image,
                                thumbnailImage=image)
            if not addonFanart == None:
                item.setProperty('Fanart_Image', addonFanart)
            item.setInfo(type="Video",
                         infoLabels={
                             "Title": 'Next Page',
                             "OriginalTitle": 'Next Page'
                         })
            control.addItem(handle=int(sys.argv[1]),
                            url=url,
                            listitem=item,
                            isFolder=True)

        control.content(int(sys.argv[1]), 'movies')
        if control.skin == 'skin.confluence':
            control.execute('Container.SetViewMode(50)')
        control.directory(int(sys.argv[1]), cacheToDisc=True)