Ejemplo n.º 1
0
    def addDirectory(self, items):
        if items == None or len(items) == 0: return

        sysaddon = sys.argv[0]
        addonFanart = control.addonFanart()
        addonThumb = control.addonThumb()
        artPath = control.artPath()

        for i in items:
            try:
                try: name = control.lang(i['name']).encode('utf-8')
                except: name = i['name']

                if i['image'].startswith('http://'): thumb = i['image']
                elif not artPath == None: thumb = os.path.join(artPath, i['image'])
                else: thumb = addonThumb

                url = '%s?action=%s' % (sysaddon, i['action'])
                try: url += '&url=%s' % urllib.quote_plus(i['url'])
                except: pass

                cm = []

                try: cm.append((control.lang(30239).encode('utf-8'), 'RunPlugin(%s?action=tvshowsToLibrary&url=%s)' % (sysaddon, urllib.quote_plus(i['context']))))
                except: pass

                item = control.item(label=name, iconImage=thumb, thumbnailImage=thumb)
                item.addContextMenuItems(cm, replaceItems=False)
                if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
                control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)
            except:
                pass

        control.directory(int(sys.argv[1]), cacheToDisc=True)
Ejemplo n.º 2
0
    def addDirectoryItem(self,
                         name,
                         query,
                         thumb,
                         icon,
                         context=None,
                         isAction=True,
                         isFolder=True):
        try:
            name = control.lang(name).encode('utf-8')
        except:
            pass
        url = '%s?action=%s' % (sysaddon, query) if isAction == True else query

        if not 'http' in thumb:
            thumb = os.path.join(artPath,
                                 thumb) if not artPath == None else icon
        cm = []

        if not context == None:
            cm.append((control.lang(context[0]).encode('utf-8'),
                       'RunPlugin(%s?action=%s)' % (sysaddon, context[1])))
        item = control.item(label=name, iconImage=thumb, thumbnailImage=thumb)
        item.addContextMenuItems(cm, replaceItems=False)
        if not addonFanart == None:
            item.setProperty('Fanart_Image', addonFanart)
        control.addItem(handle=int(sys.argv[1]),
                        url=url,
                        listitem=item,
                        isFolder=isFolder)
Ejemplo n.º 3
0
def wizja_userstatus():
    s = webClient()
    r = s.get('http://wizja.tv/users/index.php').text

    #print ('result :#%s#' % r)
    if 'login_input_username' in r:
        control.log('NIEZALOGOWANY')
        return 'NIEZALOGOWANY'

    if 'Zalogowany jako' in r:
        control.log('ZALOGOWANY')
        # no premium
        if '<font color=ff0000>Brak premium' in r:
            control.log('WIZJA.TV FREE PREMIUM: %s' % '')
            control.infoDialog(control.lang(30490).encode('utf-8'), time=6000)
            control.dialog.ok(
                control.addonInfo('name') + ' - WIZJA TV',
                control.lang(30490).encode('utf-8'), '')
            return 'FREE'
        else:
            try:
                premium = re.findall('Premium aktywne do (\d{4}.*?)</font>',
                                     r)[0]
                control.set_setting('wizja.expire', premium)
                control.infoDialog('Premium Wizja.tv do: ' +
                                   premium.encode('utf-8'),
                                   time=2000)
                return 'PREMIUM%s' % premium
            except:
                pass
                return 'PREMIUM%s'

    return True
Ejemplo n.º 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)')
Ejemplo n.º 5
0
    def getVideoInfo(self, content, name, year, imdb, tvdb):
        try:
            self.loadingTime = time.time()
            self.totalTime = 0
            self.currentTime = 0
            self.folderPath = control.infoLabel('Container.FolderPath')
            self.name = name
            self.year = year
            self.content = content
            self.file = self.name + '.strm'
            self.file = self.file.translate(None, '\/:*?"<>|').strip('.')
            self.imdb = 'tt' + imdb if imdb.isdigit() else imdb
            self.tvdb = tvdb if not tvdb == None else '0'
        except:
            pass

        try:
            if self.content == 'movie':
                self.title = re.compile('(.+?) [(]\d{4}[)]$').findall(
                    self.name)[0]
            elif self.content == 'episode':
                self.tvshowtitle, self.season, self.episode = re.compile(
                    '(.+?) S(\d*)E(\d*)$').findall(self.name)[0]
                self.season, self.episode = '%01d' % int(
                    self.season), '%01d' % int(self.episode)
                self.file2 = '%s (%s) S%02dE%02d.strm' % (
                    self.tvshowtitle.translate(None, '\/:*?"<>|'), self.year,
                    int(self.season), int(self.episode))
            elif self.content == 'live':
                self.title = self.name
        except:
            pass

        try:
            if control.setting('resume_playback') == 'true':
                self.offset = bookmarks.getBookmark(self.name, self.imdb)
                if self.offset == '0': raise Exception()

                minutes, seconds = divmod(float(self.offset), 60)
                hours, minutes = divmod(minutes, 60)
                yes = control.yesnoDialog(
                    '%s %02d:%02d:%02d' % (control.lang(30461).encode('utf-8'),
                                           hours, minutes, seconds), '', '',
                    self.name,
                    control.lang(30463).encode('utf-8'),
                    control.lang(30462).encode('utf-8'))

                if yes: self.offset = '0'
        except:
            pass

        try:
            if self.content == 'movie':
                control.window.setProperty('script.trakt.ids',
                                           json.dumps({'imdb': self.imdb}))
            elif self.content == 'episode':
                control.window.setProperty('script.trakt.ids',
                                           json.dumps({'tvdb': self.tvdb}))
        except:
            pass
Ejemplo n.º 6
0
    def addDirectory(self, items):
        if items == None or len(items) == 0: return

        sysaddon = sys.argv[0]
        addonFanart = control.addonFanart()
        addonThumb = control.addonThumb()
        artPath = control.artPath()

        for i in items:
            try:
                try: name = control.lang(i['name']).encode('utf-8')
                except: name = i['name']

                if i['image'].startswith('http://'): thumb = i['image']
                elif not artPath == None: thumb = os.path.join(artPath, i['image'])
                else: thumb = addonThumb

                url = '%s?action=%s' % (sysaddon, i['action'])
                try: url += '&url=%s' % urllib.quote_plus(i['url'])
                except: pass

                cm = []

                try: cm.append((control.lang(30239).encode('utf-8'), 'RunPlugin(%s?action=tvshowsToLibrary&url=%s)' % (sysaddon, urllib.quote_plus(i['context']))))
                except: pass

                item = control.item(label=name, iconImage=thumb, thumbnailImage=thumb)
                item.addContextMenuItems(cm, replaceItems=False)
                if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
                control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)
            except:
                pass

        control.directory(int(sys.argv[1]), cacheToDisc=True)
Ejemplo n.º 7
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)')
Ejemplo n.º 8
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)')
Ejemplo n.º 9
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)')
Ejemplo n.º 10
0
 def clearCacheAll(self):
     control.idle()
     yes = control.yesnoDialog(control.lang(32056).encode('utf-8'), '', '')
     if not yes: return
     from resources.lib.libraries import cache
     cache.cache_clear_all()
     control.infoDialog(control.lang(32057).encode('utf-8'), sound=True, icon='INFO')
Ejemplo n.º 11
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)")
Ejemplo n.º 12
0
def nhlDirectory():
    dt = procTimezone(5)
    datex = int(dt.strftime('%Y%m%d'))

    url = 'http://live.nhl.com/GameData/SeasonSchedule-20142015.json'
    result = client.request(url)

    items = json.loads(result)
    items = sorted(items, key=lambda k: k['est'])

    addDirectoryItem(control.lang(30751).encode('utf-8'), 'Scoreboard', 'nhlScoreboard', '0', '0')
    addDirectoryItem(control.lang(30752).encode('utf-8'), 'Archived', 'nhlArchives', '0', '0')
    addDirectoryItem(control.lang(30753).encode('utf-8'), '0', '0', '0', '0')
    addDirectoryItem(control.lang(30754).encode('utf-8'), '0', '0', '0', '0')

    for item in items:
        try:
            est = datetime.datetime.strptime(item['est'], '%Y%m%d %H:%M:%S')
            date = int(est.strftime('%Y%m%d'))
            if not date == datex: raise Exception()

            est = procTimezone(5, est)
            name = '%s at %s  [COLOR gold](%s)[/COLOR]  [COLOR red](%s)[/COLOR]' % (item['a'], item['h'], est.strftime('%H:%M'), est.strftime('%Y-%m-%d'))
            url = str(item['id'])

            addDirectoryItem(name, url, 'nhlStreams', '0', '0')
        except:
            pass

    endDirectory()
Ejemplo n.º 13
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)')
Ejemplo n.º 14
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)')
Ejemplo n.º 15
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)')
Ejemplo n.º 16
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)')
Ejemplo n.º 17
0
    def onPlayBackStarted(self):
        for i in range(0, 200):
            if control.condVisibility('Window.IsActive(busydialog)') == 1:
                control.idle()
            else:
                break
            control.sleep(100)

        if control.setting('playback_info') == 'true':
            elapsedTime = '%s %s %s' % (control.lang(30464).encode('utf-8'),
                                        int((time.time() - self.loadingTime)),
                                        control.lang(30465).encode('utf-8'))
            control.infoDialog(elapsedTime, heading=self.name)

        try:
            if self.offset == '0': raise Exception()
            self.seekTime(float(self.offset))
        except:
            pass
        try:
            if not control.setting('subtitles') == 'true': raise Exception()
            try:
                subtitle = subtitles.get(self.name, self.imdb, self.season,
                                         self.episode)
            except:
                subtitle = subtitles.get(self.name, self.imdb, '', '')
        except:
            pass
Ejemplo n.º 18
0
def importDBFiles():
    status = True
    try:
        dBImportURL = control.setting('databaseImportURL')
        
        # Shows DB file
        fileSource = dBImportURL + 'shows.db' 
        logger.logInfo('Copying %s to %s' % (fileSource, control.showsFile))
        status = True if status is True and logger.logInfo(xbmcvfs.copy(fileSource, control.showsFile)) != 0 else False

        # Episodes DB file
        fileSource = dBImportURL + 'episodes.db' 
        logger.logInfo('Copying %s to %s' % (fileSource, control.episodesFile))
        status = True if status is True and logger.logInfo(xbmcvfs.copy(fileSource, control.episodesFile)) != 0 else False

        # Celebrities DB file
        fileSource = dBImportURL + 'celebrities.db' 
        logger.logInfo('Copying %s to %s' % (fileSource, control.celebritiesFile))
        status = True if status is True and logger.logInfo(xbmcvfs.copy(fileSource, control.celebritiesFile)) != 0 else False
    except:
        status = False
        pass
    if status is True:
        control.setSetting('showUpdateCatalog', 'false')
        control.showNotification(control.lang(57003), control.lang(50010))
    else:
        control.showNotification(control.lang(57027), control.lang(50004))
    return status
Ejemplo n.º 19
0
def nhlDirectory():
    dt = procTimezone(5)
    datex = int(dt.strftime('%Y%m%d'))

    url = 'http://live.nhl.com/GameData/SeasonSchedule-20152016.json'
    result = client.request(url)

    items = json.loads(result)
    items = sorted(items, key=lambda k: k['est'])

    addDirectoryItem(control.lang(30751).encode('utf-8'), 'Scoreboard', 'nhlScoreboard', '0', '0')
    addDirectoryItem(control.lang(30752).encode('utf-8'), 'Archived', 'nhlArchives', '0', '0')
    addDirectoryItem(control.lang(30753).encode('utf-8'), '0', '0', '0', '0')
    addDirectoryItem(control.lang(30754).encode('utf-8'), '0', '0', '0', '0')

    for item in items:
        try:
            est = datetime.datetime.strptime(item['est'], '%Y%m%d %H:%M:%S')
            date = int(est.strftime('%Y%m%d'))
            if not date == datex: raise Exception()

            est = procTimezone(5, est)
            name = '%s at %s  [COLOR gold](%s)[/COLOR]  [COLOR red](%s)[/COLOR]' % (item['a'], item['h'], est.strftime('%H:%M'), est.strftime('%Y-%m-%d'))
            url = str(item['id'])

            addDirectoryItem(name, url, 'nhlStreams', '0', '0')
        except:
            pass

    endDirectory()
Ejemplo n.º 20
0
def rdAuthorize():
    try:
        CLIENT_ID = 'TC3DG7YFNBKQK'
        USER_AGENT = 'SPECTO for Kodi/1.0'

        if not '' in credentials()['realdebrid'].values():
            if control.yesnoDialog(control.lang(32411).encode('utf-8'), control.lang(32413).encode('utf-8'), '', 'RealDebrid', control.lang(32415).encode('utf-8'), control.lang(32414).encode('utf-8')):
                control.set_setting('realdebrid_client_id','')
                control.set_setting('realdebrid_client_secret', '')
                control.set_setting('realdebrid_token', '')
                control.set_setting('realdebrid_refresh', '')
                control.set_setting('realdebrid_auth', '')
            raise Exception()

        headers = {'User-Agent': USER_AGENT}
        url = 'https://api.real-debrid.com/oauth/v2/device/code?client_id=%s&new_credentials=yes' % (CLIENT_ID)
        result = client.request(url, headers=headers)
        result = json.loads(result)
        verification_url = control.lang(30416).encode('utf-8') + '[COLOR skyblue]%s[/COLOR]' % (result['verification_url'])
        user_code = control.lang(30417).encode('utf-8') + '[COLOR skyblue]%s[/COLOR]' % (result['user_code'])
        device_code = result['device_code']
        interval = result['interval']

        progressDialog = control.progressDialog
        progressDialog.create('RealDebrid', verification_url, user_code)

        for i in range(0, 3600):
            try:
                if progressDialog.iscanceled(): break
                time.sleep(1)
                if not float(i) % interval == 0: raise Exception()
                url = 'https://api.real-debrid.com/oauth/v2/device/credentials?client_id=%s&code=%s' % (CLIENT_ID, device_code)
                result = client.request(url, headers=headers, error=True)
                result = json.loads(result)
                if 'client_secret' in result: break
            except:
                pass

        try: progressDialog.close()
        except: pass

        id, secret = result['client_id'], result['client_secret']

        url = 'https://api.real-debrid.com/oauth/v2/token'
        post = {'client_id': id, 'client_secret': secret, 'code': device_code, 'grant_type': 'http://oauth.net/grant_type/device/1.0'}

        result = client.request(url, post=post, headers=headers)
        result = json.loads(result)

        token, refresh = result['access_token'], result['refresh_token']

        control.set_setting('realdebrid_client_id', id)
        control.set_setting('realdebrid_client_secret', secret)
        control.set_setting('realdebrid_token', token)
        control.set_setting('realdebrid_refresh', refresh)
        control.set_setting('realdebrid_auth', '*************')
        raise Exception()
    except:
        control.openSettings('3.13')
Ejemplo n.º 21
0
 def showMySubscription(self):
     sub = gmatv.getUserSubscription()
     message = ''
     if sub:
         message += '%s' % (sub.get('details'))
     else:
         message = control.lang(57002)
     control.showMessage(message, control.lang(56002))
Ejemplo n.º 22
0
 def showMyTransactions(self):
     transactions = gmatv.getUserTransactions()
     message = ''
     if len(transactions) > 0:
         for t in transactions:
             message += t + "\n"
     else:
         message = control.lang(57002)
     control.showMessage(message, control.lang(56003))
Ejemplo n.º 23
0
def getCategory():
    getDirectory('0', phLink, '0', '0', '0', '0', '0', close=False)
    addCategoryItem(control.lang(30701).encode('utf-8'), 'openSettings', 'settings.png')
    addCategoryItem(control.lang(30721).encode('utf-8'), 'downloader', 'downloader.png')
    addCategoryItem(control.lang(30702).encode('utf-8'), 'search', 'search.png')

    if phTest in control.listDir(control.dataPath)[1]: addCategoryItem('Testings', 'localDirectory', 'home.png')

    endCategory()
Ejemplo n.º 24
0
    def channelDirectory(self, items):
        if items == None or len(items) == 0: return

        playbackMenu = control.lang(30292).encode('utf-8') if control.setting('autoplay') == 'true' else control.lang(30291).encode('utf-8')

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()
        addonFanart = control.addonFanart()
        sysaddon = sys.argv[0]


        for i in items:
            try:
                label = "[B]%s[/B] : %s" % (i['channel'].upper(), i['name'])
                sysname = urllib.quote_plus(i['name'])
                systitle = urllib.quote_plus(i['title'])
                imdb, tmdb, year = i['imdb'], '0', i['year']

                poster, banner = i['poster'], i['poster']
                if poster == '0': poster = addonPoster
                if banner == '0' and poster == '0': banner = addonBanner
                elif banner == '0': banner = poster

                meta = dict((k,v) for k, v in i.iteritems() if not v == '0')
                meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)})
                if i['duration'] == '0': meta.update({'duration': '120'})
                try: meta.update({'duration': str(int(meta['duration']) * 60)})
                except: pass
                sysmeta = urllib.quote_plus(json.dumps(meta))

                url = '%s?action=play&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s&meta=%s&t=%s' % (sysaddon, sysname, systitle, year, imdb, tmdb, sysmeta, self.systime)
                sysurl = urllib.quote_plus(url)

                cm = []
                cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta)))
                cm.append((control.lang(30293).encode('utf-8'), 'Action(Info)'))
                cm.append((control.lang(30294).encode('utf-8'), 'RunPlugin(%s?action=refresh)' % (sysaddon)))
                cm.append((control.lang(30295).encode('utf-8'), 'RunPlugin(%s?action=openSettings)' % (sysaddon)))
                cm.append((control.lang(30296).encode('utf-8'), 'RunPlugin(%s?action=openPlaylist)' % (sysaddon)))

                item = control.item(label=label, iconImage=poster, thumbnailImage=poster)

                try: item.setArt({'poster': poster, 'banner': banner})
                except: pass

                if not addonFanart == None:
                    item.setProperty('Fanart_Image', addonFanart)

                item.setInfo(type='Video', infoLabels = meta)
                item.setProperty('Video', 'true')
                #item.setProperty('IsPlayable', 'true')
                item.addContextMenuItems(cm, replaceItems=True)
                control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False)
            except:
                pass

        control.content(int(sys.argv[1]), 'movies')
        control.directory(int(sys.argv[1]), cacheToDisc=True)
Ejemplo n.º 25
0
def getCategory():
    getDirectory('0', phLink, '0', '0', '0', '0', '0', close=False)

    addCategoryItem('NHL', 'nhlDirectory', 'hockey.jpg')
    addCategoryItem(control.lang(30701).encode('utf-8'), 'openSettings', 'settings.png')
    addCategoryItem(control.lang(30721).encode('utf-8'), 'downloader', 'downloader.png')
    addCategoryItem(control.lang(30702).encode('utf-8'), 'search', 'search.png')

    endCategory()
Ejemplo n.º 26
0
    def channelDirectory(self, items):
        if items == None or len(items) == 0: return

        playbackMenu = control.lang(30292).encode('utf-8') if control.setting('autoplay') == 'true' else control.lang(30291).encode('utf-8')

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()
        addonFanart = control.addonFanart()
        sysaddon = sys.argv[0]


        for i in items:
            try:
                label = "[B]%s[/B] : %s" % (i['channel'].upper(), i['name'])
                sysname = urllib.quote_plus(i['name'])
                systitle = urllib.quote_plus(i['title'])
                imdb, tmdb, year = i['imdb'], '0', i['year']

                poster, banner = i['poster'], i['poster']
                if poster == '0': poster = addonPoster
                if banner == '0' and poster == '0': banner = addonBanner
                elif banner == '0': banner = poster

                meta = dict((k,v) for k, v in i.iteritems() if not v == '0')
                meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, sysname)})
                if i['duration'] == '0': meta.update({'duration': '120'})
                try: meta.update({'duration': str(int(meta['duration']) * 60)})
                except: pass
                sysmeta = urllib.quote_plus(json.dumps(meta))

                url = '%s?action=play&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s&meta=%s&t=%s' % (sysaddon, sysname, systitle, year, imdb, tmdb, sysmeta, self.systime)
                sysurl = urllib.quote_plus(url)

                cm = []
                cm.append((playbackMenu, 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % (sysaddon, sysurl, sysmeta)))
                cm.append((control.lang(30293).encode('utf-8'), 'Action(Info)'))
                cm.append((control.lang(30294).encode('utf-8'), 'RunPlugin(%s?action=refresh)' % (sysaddon)))
                cm.append((control.lang(30295).encode('utf-8'), 'RunPlugin(%s?action=openSettings)' % (sysaddon)))
                cm.append((control.lang(30296).encode('utf-8'), 'RunPlugin(%s?action=openPlaylist)' % (sysaddon)))

                item = control.item(label=label, iconImage=poster, thumbnailImage=poster)

                try: item.setArt({'poster': poster, 'banner': banner})
                except: pass

                if not addonFanart == None:
                    item.setProperty('Fanart_Image', addonFanart)

                item.setInfo(type='Video', infoLabels = meta)
                item.setProperty('Video', 'true')
                #item.setProperty('IsPlayable', 'true')
                item.addContextMenuItems(cm, replaceItems=True)
                control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=False)
            except:
                pass

        control.content(int(sys.argv[1]), 'movies')
        control.directory(int(sys.argv[1]), cacheToDisc=True)
Ejemplo n.º 27
0
    def firstInstall(self):
        if control.setting('showWelcomeMessage') == 'true':
            control.showMessage(control.lang(57016), control.lang(57018))
            control.setSetting('showWelcomeMessage', 'false')

        self.addDirectoryItem(control.lang(56025), config.uri.get('base'),
                              config.LOGINWITHTFC, control.addonIcon())
        self.addDirectoryItem(control.lang(56024), config.uri.get('base'),
                              config.LOGINWITHFB, control.facebookIcon())
        self.endDirectory()
Ejemplo n.º 28
0
Archivo: livetv.py Proyecto: mpie/repo
 def addDirectoryItem(self, name, query, thumb, icon, context=None, isAction=True, isFolder=True):
     try: name = control.lang(name).encode('utf-8')
     except: pass
     url = '%s?action=%s' % (sysaddon, query) if isAction == True else query
     thumb = os.path.join(artPath, thumb) if not artPath == None else icon
     cm = []
     if not context == None: cm.append((control.lang(context[0]).encode('utf-8'), 'RunPlugin(%s?action=%s)' % (sysaddon, context[1])))
     item = control.item(label=name, iconImage=thumb, thumbnailImage=thumb)
     item.addContextMenuItems(cm, replaceItems=False)
     if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
     control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=isFolder)
Ejemplo n.º 29
0
def getCategory():
    getDirectory('0', phLink, '0', '0', '0', '0', '0', close=False)

    addCategoryItem('NHL', 'nhlDirectory', 'hockey.jpg')
    addCategoryItem(
        control.lang(30701).encode('utf-8'), 'openSettings', 'settings.png')
    addCategoryItem(
        control.lang(30721).encode('utf-8'), 'downloader', 'downloader.png')
    addCategoryItem(
        control.lang(30702).encode('utf-8'), 'search', 'search.png')

    endCategory()
Ejemplo n.º 30
0
def addDirectoryItem(name, url, action, image, image2, fanart, content, data, tvshow='0', totalItems=0, isFolder=True):
    if not str(image).lower().startswith('http'): image = control.addonInfo('icon')

    if not str(image2).lower().startswith('http'): image2 = control.addonInfo('icon')

    if not str(fanart).lower().startswith('http'): fanart = control.addonInfo('fanart')

    if content in ['movies', 'episodes']: playable = 'true'
    else: playable = 'false'

    sysaddon = sys.argv[0]

    if url.startswith('$base64'):
        import base64 ; url = base64.b64decode(re.compile('\$base64\[(.+?)\]$').findall(url)[0])
    u = '%s?name=%s&url=%s&tvdb=&imdb=&source=GVideo&provider=Mpie&content=%s&action=playItem' % (sysaddon, urllib.quote_plus(name), urllib.quote_plus(url), str(content))

    cm = []

    if content == 'movies':
        cm.append((control.lang(30708).encode('utf-8'), 'XBMC.Action(Info)'))
    elif content in ['tvshows', 'seasons']:
        cm.append((control.lang(30709).encode('utf-8'), 'XBMC.Action(Info)'))
    elif content == 'episodes':
        cm.append((control.lang(30710).encode('utf-8'), 'XBMC.Action(Info)'))


    if content == 'movies' and not isFolder == True:
        downloadFile = name
        try: downloadFile = '%s (%s)' % (data['title'], data['year'])
        except: pass
        cm.append((control.lang(30722).encode('utf-8'), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(downloadFile), urllib.quote_plus(url), urllib.quote_plus(image))))

    elif content == 'episodes' and not isFolder == True:
        downloadFile = name
        try: downloadFile = '%s S%02dE%02d' % (data['tvshowtitle'], int(data['season']), int(data['episode']))
        except: pass
        cm.append((control.lang(30722).encode('utf-8'), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(downloadFile), urllib.quote_plus(url), urllib.quote_plus(image))))


    if content == 'movies':
        cm.append((control.lang(30711).encode('utf-8'), 'RunPlugin(%s?action=addView&content=movies)' % sysaddon))
    elif content == 'tvshows':
        cm.append((control.lang(30712).encode('utf-8'), 'RunPlugin(%s?action=addView&content=tvshows)' % sysaddon))
    elif content == 'seasons':
        cm.append((control.lang(30713).encode('utf-8'), 'RunPlugin(%s?action=addView&content=seasons)' % sysaddon))
    elif content == 'episodes':
        cm.append((control.lang(30714).encode('utf-8'), 'RunPlugin(%s?action=addView&content=episodes)' % sysaddon))


    item = control.item(name, iconImage='DefaultFolder.png', thumbnailImage=image)
    try: item.setArt({'poster': image2, 'tvshow.poster': image2, 'season.poster': image2, 'banner': image, 'tvshow.banner': image, 'season.banner': image})
    except: pass
    item.addContextMenuItems(cm, replaceItems=False)
    item.setProperty('Fanart_Image', fanart)
    if playable == 'true': item.setProperty('IsPlayable', 'true')
    item.setInfo(type='Video', infoLabels=data)

    control.addItem(handle=int(sys.argv[1]),url=u,listitem=item,totalItems=totalItems,isFolder=isFolder)
Ejemplo n.º 31
0
def authTrakt():
    try:
        if getTraktCredentialsInfo() == True:
            if control.yesnoDialog(control.lang(32511).encode('utf-8'), control.lang(32512).encode('utf-8'), '',
                                   'Trakt'):
                control.setSetting(id='trakt.user', value='')
                control.setSetting(id='trakt.token', value='')
                control.setSetting(id='trakt.refresh', value='')
            raise Exception()

        result = getTraktAsJson('/oauth/device/code', {'client_id': V2_API_KEY})
        verification_url = (control.lang(32513) % result['verification_url']).encode('utf-8')
        user_code = (control.lang(32514) % result['user_code']).encode('utf-8')
        expires_in = int(result['expires_in'])
        device_code = result['device_code']
        interval = result['interval']

        progressDialog = control.progressDialog
        progressDialog.create('Trakt', verification_url, user_code)

        for i in range(0, expires_in):
            try:
                if progressDialog.iscanceled(): break
                time.sleep(1)
                if not float(i) % interval == 0: raise Exception()
                r = getTraktAsJson('/oauth/device/token',
                                   {'client_id': V2_API_KEY, 'client_secret': CLIENT_SECRET, 'code': device_code})
                if 'access_token' in r: break
            except:
                pass

        try:
            progressDialog.close()
        except:
            pass

        token, refresh = r['access_token'], r['refresh_token']

        headers = {'Content-Type': 'application/json', 'trakt-api-key': V2_API_KEY, 'trakt-api-version': 2,
                   'Authorization': 'Bearer %s' % token}

        result = client.request(urlparse.urljoin(BASE_URL, '/users/me'), headers=headers)
        result = utils.json_loads_as_str(result)

        user = result['username']

        control.setSetting(id='trakt.user', value=user)
        control.setSetting(id='trakt.token', value=token)
        control.setSetting(id='trakt.refresh', value=refresh)
        raise Exception()
    except:
        control.openSettings('3.1')
def getCategory():
    getDirectory('0', phLink, '0', '0', '0', '0', '0', close=False)
    addCategoryItem('VinMan FM', 'radioDirectory', 'radios.png')
    addCategoryItem('Cartoon Crazy','CartoonDirectory','cartoon.png')
    addCategoryItem('NHL', 'nhlDirectory', 'hockey.jpg')
    addCategoryItem('News Updates', 'dmode&url=%s' % phNews, 'news.gif')
    addCategoryItem(control.lang(30701).encode('utf-8'), 'openSettings', 'settings.png')
    addCategoryItem(control.lang(30721).encode('utf-8'), 'downloader', 'downloader.png')
    addCategoryItem(control.lang(30702).encode('utf-8'), 'search', 'search.png')

    if phTest in control.listDir(control.dataPath)[1]: addCategoryItem('Testings', 'localDirectory', 'home.png')

    endCategory()
Ejemplo n.º 33
0
 def showMyInfo(self):
     loggedIn = gmatv.isLoggedIn()
     message = control.lang(57002)
     if loggedIn == True:
         try:
             user = gmatv.getUserInfo()
             message = 'First name: %s\nLast name: %s\nEmail: %s\nState: %s\nCountry: %s\nMember since: %s\n\n' % (
                 user.get('firstName', ''), user.get('lastName', ''),
                 user.get('email', ''), user.get('state', ''),
                 user.get('country', ''), user.get('memberSince', ''))
         except:
             pass
     control.showMessage(message, control.lang(56001))
Ejemplo n.º 34
0
def getCategory():
    getDirectory('0', phLink, '0', '0', '0', '0', '0', close=False)
    addCategoryItem(
        control.lang(30701).encode('utf-8'), 'openSettings', 'settings.png')
    addCategoryItem(
        control.lang(30721).encode('utf-8'), 'downloader', 'downloader.png')
    addCategoryItem(
        control.lang(30702).encode('utf-8'), 'search', 'search.png')

    if phTest in control.listDir(control.dataPath)[1]:
        addCategoryItem('Testings', 'localDirectory', 'home.png')

    endCategory()
Ejemplo n.º 35
0
 def showMyList(self):
     self.addDirectoryItem(control.lang(50213),
                           '/',
                           config.MYLISTSHOWLASTEPISODES,
                           control.addonFolderIcon(control.lang(50213)),
                           isFolder=True,
                           **self.formatMenu())
     categories = gmatv.getMyListCategories()
     for c in categories:
         self.addDirectoryItem(c.get('name'), str(c.get('id')),
                               config.LISTCATEGORY,
                               control.addonFolderIcon(c.get('name')),
                               **self.formatMenu())
     self.endDirectory()
def getSearch():
    addDirectoryItem('%s...' % control.lang(30702).encode('utf-8'), '0', 'searchDirectory', '0', '0', '0', '0', '0', {})
    addDirectoryItem(control.lang(30703).encode('utf-8'), '0', 'clearSearch', '0', '0', '0', '0', '0', {})

    try:
        def search(): return
        result = cache.get(search, 600000000, table='rel_srch')
        for q in result:
                try: addDirectoryItem('%s...' % q, q, 'searchDirectory2', '0', '0', '0', '0', '0', {})
                except: pass
    except:
        pass

    control.directory(int(sys.argv[1]), cacheToDisc=True)
Ejemplo n.º 37
0
Archivo: trakt.py Proyecto: mpie/repo
def authTrakt():
    try:
        if getTraktCredentialsInfo() == True:
            if control.yesnoDialog(control.lang(32511).encode('utf-8'), control.lang(32512).encode('utf-8'), '', 'Trakt'):
                control.setSetting(id='trakt.user', value='')
                control.setSetting(id='trakt.token', value='')
                control.setSetting(id='trakt.refresh', value='')
            raise Exception()

        result = getTrakt('/oauth/device/code', {'client_id': 'c029c80fd3d3a5284ee820ba1cf7f0221da8976b8ee5e6c4af714c22fc4f46fa'})
        result = json.loads(result)
        verification_url = (control.lang(32513) % result['verification_url']).encode('utf-8')
        user_code = (control.lang(32514) % result['user_code']).encode('utf-8')
        expires_in = int(result['expires_in'])
        device_code = result['device_code']
        interval = result['interval']

        progressDialog = control.progressDialog
        progressDialog.create('Trakt', verification_url, user_code)

        for i in range(0, expires_in):
            try:
                if progressDialog.iscanceled(): break
                time.sleep(1)
                if not float(i) % interval == 0: raise Exception()
                r = getTrakt('/oauth/device/token', {'client_id': 'c029c80fd3d3a5284ee820ba1cf7f0221da8976b8ee5e6c4af714c22fc4f46fa', 'client_secret': '90a1840447a1e39d350023263902fe7010338d19789e6260f18df56a8b07a68a', 'code': device_code})
                r = json.loads(r)
                if 'access_token' in r: break
            except:
                pass

        try: progressDialog.close()
        except: pass

        token, refresh = r['access_token'], r['refresh_token']

        headers = {'Content-Type': 'application/json', 'trakt-api-key': 'c029c80fd3d3a5284ee820ba1cf7f0221da8976b8ee5e6c4af714c22fc4f46fa', 'trakt-api-version': '2', 'Authorization': 'Bearer %s' % token}

        result = client.request('http://api-v2launch.trakt.tv/users/me', headers=headers)
        result = json.loads(result)

        user = result['username']

        control.setSetting(id='trakt.user', value=user)
        control.setSetting(id='trakt.token', value=token)
        control.setSetting(id='trakt.refresh', value=refresh)
        raise Exception()
    except:
        control.openSettings('3.1')
Ejemplo n.º 38
0
def authTrakt():
    try:
        if getTraktCredentialsInfo() == True:
            if control.yesnoDialog(control.lang(30479).encode('utf-8'), control.lang(30481).encode('utf-8'), '', 'Trakt', control.lang(30483).encode('utf-8'), control.lang(30482).encode('utf-8')):
                control.setSetting(id='trakt.user', value='')
                control.setSetting(id='trakt.token', value='')
                control.setSetting(id='trakt.refresh', value='')
            raise Exception()

        result = getTrakt('/oauth/device/code', {'client_id': control.trakt_key })
        result = json.loads(result)
        verification_url = (control.lang(30416) + '[COLOR skyblue]%s[/COLOR]' % result['verification_url']).encode('utf-8')
        user_code = (control.lang(30417) + '[COLOR skyblue]%s[/COLOR]' % result['user_code']).encode('utf-8')
        expires_in = int(result['expires_in'])
        device_code = result['device_code']
        interval = result['interval']

        progressDialog = control.progressDialog
        progressDialog.create('Trakt', verification_url, user_code)

        for i in range(0, expires_in):
            try:
                if progressDialog.iscanceled(): break
                time.sleep(1)
                if not float(i) % interval == 0: raise Exception()
                r = getTrakt('/oauth/device/token', {'client_id': control.trakt_key , 'client_secret': control.trakt_secret, 'code': device_code})
                r = json.loads(r)
                if 'access_token' in r: break
            except:
                pass

        try: progressDialog.close()
        except: pass

        token, refresh = r['access_token'], r['refresh_token']

        headers = {'Content-Type': 'application/json', 'trakt-api-key': control.trakt_key , 'trakt-api-version': '2', 'Authorization': 'Bearer %s' % token}

        result = client.request('http://api-v2launch.trakt.tv/users/me', headers=headers)
        result = json.loads(result)

        user = result['username']

        control.setSetting(id='trakt.user', value=user)
        control.setSetting(id='trakt.token', value=token)
        control.setSetting(id='trakt.refresh', value=refresh)
        raise Exception()
    except:
        control.openSettings('3.1')
Ejemplo n.º 39
0
    def clearSources(self):
        try:
            yes = control.yesnoDialog(control.lang(30510).encode('utf-8'), '', '')
            if not yes: return

            control.makeFile(control.dataPath)
            dbcon = database.connect(control.sourcescacheFile)
            dbcur = dbcon.cursor()
            dbcur.execute("DROP TABLE IF EXISTS rel_src")
            dbcur.execute("VACUUM")
            dbcon.commit()

            control.infoDialog(control.lang(30511).encode('utf-8'))
        except:
            pass
Ejemplo n.º 40
0
    def clearSources(self):
        try:
            yes = control.yesnoDialog(control.lang(30510).encode('utf-8'), '', '')
            if not yes: return

            control.makeFile(control.dataPath)
            dbcon = database.connect(control.sourcescacheFile)
            dbcur = dbcon.cursor()
            dbcur.execute("DROP TABLE IF EXISTS rel_src")
            dbcur.execute("VACUUM")
            dbcon.commit()

            control.infoDialog(control.lang(30511).encode('utf-8'))
        except:
            pass
Ejemplo n.º 41
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)")
Ejemplo n.º 42
0
def nhlResolve(url):
    try:
        try:
            url, selectGame, side = re.compile(
                '(.+?)x0xe(.+?)x0xe(.+?)$').findall(url)[0]
        except:
            selectGame, side = None, None

        header = '|' + urllib.urlencode(
            {'User-Agent': 'PS4 libhttp/1.76 (PlayStation 4)'})
        base = re.compile('(.*/).+[.]m3u8').findall(url)

        if not url.endswith('m3u8'):
            return player().run(url + header, selectGame, side)

        result = client.request(url)

        result = re.compile('BANDWIDTH=(\d*)\n(.+?[.]m3u8)').findall(result)
        result = [(int(int(i[0]) / 1000), i[1]) for i in result]
        result = sorted(result, reverse=True)
        result = [(str(i[0]), base[0] + i[1]) for i in result]

        q = [i[0] for i in result]
        u = [i[1] for i in result]
        select = control.selectDialog(q, control.lang(30756).encode('utf-8'))
        if select == -1: return
        url = u[select]

        player().run(url + header, selectGame, side)
    except:
        return
Ejemplo n.º 43
0
def upgradeDB():

    # Load DB

    # DB upgrades per version
    if control.setting('lastVersion') == '1.0.0-beta' and control.addonInfo(
            'version') == '1.0.0':
        episodeDB = episodes.Episode(control.episodesFile)
        showDB = shows.Show(control.showsFile)
        libraryDB = library.Library(control.libraryFile)

        control.showNotification('Upgrading databases...', control.lang(50002))
        logger.logDebug(
            episodeDB.upgrade([
                'ALTER TABLE `EPISODE` ADD COLUMN `TYPE` TEXT',
                'UPDATE `EPISODE` SET TYPE = \'episode\' WHERE TYPE IS NULL'
            ]))
        logger.logDebug(
            showDB.upgrade([
                'ALTER TABLE `SHOW` ADD COLUMN `TYPE` TEXT',
                'UPDATE `SHOW` SET TYPE = \'show\' WHERE TYPE IS NULL'
            ]))

    elif control.setting('lastVersion') in (
            '1.0.0', '1.0.1',
            '1.1.0') and control.addonInfo('version') == '1.2.0':
        # Check if installation is complete
        logger.logNotice('Checking installation')
        tools.checkInstallDB(True)
Ejemplo n.º 44
0
Archivo: views.py Proyecto: mpie/repo
def addView(content):
    try:
        skin = control.skin
        skinPath = control.skinPath
        xml = os.path.join(skinPath,'addon.xml')
        file = control.openFile(xml)
        read = file.read().replace('\n','')
        file.close()
        try: src = re.compile('defaultresolution="(.+?)"').findall(read)[0]
        except: src = re.compile('<res.+?folder="(.+?)"').findall(read)[0]
        src = os.path.join(skinPath, src)
        src = os.path.join(src, 'MyVideoNav.xml')
        file = control.openFile(src)
        read = file.read().replace('\n','')
        file.close()
        views = re.compile('<views>(.+?)</views>').findall(read)[0]
        views = [int(x) for x in views.split(',')]
        for view in views:
            label = control.infoLabel('Control.GetLabel(%s)' % (view))
            if not (label == '' or label == None): break
        record = (skin, content, str(view))
        control.makeFile(control.dataPath)
        dbcon = database.connect(control.databaseFile)
        dbcur = dbcon.cursor()
        dbcur.execute("CREATE TABLE IF NOT EXISTS views (""skin TEXT, ""view_type TEXT, ""view_id TEXT, ""UNIQUE(skin, view_type)"");")
        dbcur.execute("DELETE FROM views WHERE skin = '%s' AND view_type = '%s'" % (record[0], record[1]))
        dbcur.execute("INSERT INTO views Values (?, ?, ?)", record)
        dbcon.commit()
        viewName = control.infoLabel('Container.Viewmode')

        control.infoDialog(control.lang(30491).encode('utf-8'), heading=viewName)
    except:
        return
Ejemplo n.º 45
0
    def root(self):
        self.addDirectoryItem(30001, 'movieNavigator', 'movies.jpg', 'DefaultMovies.png')
        self.addDirectoryItem(30002, 'tvNavigator', 'tvshows.jpg', 'DefaultTVShows.png')
        self.addDirectoryItem(30003, 'channels', 'channels.jpg', 'DefaultMovies.png')
        self.addDirectoryItem(30004, 'myNavigator', 'myspecto.jpg', 'DefaultVideoPlaylists.png')

        if not control.setting('movie_widget') == '0':
            self.addDirectoryItem(30005, 'movieWidget', 'moviesAdded.jpg', 'DefaultRecentlyAddedMovies.png')

        if (traktMode == True and not control.setting('tv_alt_widget') == '0') or (traktMode == False and not control.setting('tv_widget') == '0'):
            #self.addDirectoryItem(30006, 'tvWidget', 'calendarsAdded.jpg', 'DefaultRecentlyAddedEpisodes.png')
            self.addDirectoryItem(30006, 'calendar&url=added', 'calendarsAdded.jpg', 'DefaultRecentlyAddedEpisodes.png')


        if not control.setting('calendar_widget') == '0':
            self.addDirectoryItem(30007, 'calendars', 'calendar.jpg', 'DefaultRecentlyAddedEpisodes.png')

        self.addDirectoryItem(30008, 'toolNavigator', 'tools.jpg', 'DefaultAddonProgram.png')

        self.addDirectoryItem(30009, 'searchNavigator', 'search.jpg', 'DefaultFolder.png')

        self.endDirectory()

        if ntptime.checkDate():
            control.log('Error date time setup')
            msg = control.lang(32020).encode('utf-8')
            msg1 ='Go to settings, set your correct date and time'.encode('utf-8')
            msg = 'You have to set your clock in your tv box.'.encode('utf-8')
            control.dialog.ok(control.addonInfo('name'),'',msg, msg1 )


        from resources.lib.libraries import cache
        from resources.lib.libraries import changelog
Ejemplo n.º 46
0
 def showWebsiteSectionContent(self, section, page=1):
     itemsPerPage = int(control.setting('itemsPerPage'))
     content = gmatv.getWebsiteSectionContent(section, page, itemsPerPage)
     for e in content:
         if e['type'] == 'show':
             image = e.get('logo') if control.setting(
                 'useShowLogo') == 'true' else e.get('image')
             self.addDirectoryItem(e.get('name'),
                                   str(e.get('id')),
                                   config.SHOWEPISODES,
                                   image,
                                   isFolder=True,
                                   **self.formatShowInfo(e))
         elif e['type'] == 'episode':
             title = '%s - %s' % (
                 e.get('show'), e.get('dateaired')
             )  # if e.get('type') == 'movie' else '%s - Ep.%s - %s' % (e.get('show'), e.get('episodenumber'), e.get('dateaired'))
             self.addDirectoryItem(title,
                                   str(e.get('id')),
                                   config.PLAY,
                                   e.get('image'),
                                   isFolder=False,
                                   query='title=%s' % title,
                                   **self.formatVideoInfo(e))
     if len(content) == itemsPerPage:
         self.addDirectoryItem(control.lang(56008), section,
                               config.SECTIONCONTENT, '', page + 1)
     self.endDirectory()
Ejemplo n.º 47
0
    def silent(self, url):
        control.idle()

        if not control.condVisibility(
                'Window.IsVisible(infodialog)') and not control.condVisibility(
                    'Player.HasVideo'):
            control.infoDialog(control.lang(32608).encode('utf-8'),
                               time=10000000)
            self.infoDialog = True
            self.silentDialog = 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 is True:
            self.silentDialog = False
            control.infoDialog("Trakt TV Show Sync Complete", time=1)
Ejemplo n.º 48
0
def nhlResolve(url):
    try:
        try: url, selectGame, side = re.compile('(.+?)x0xe(.+?)x0xe(.+?)$').findall(url)[0]
        except: selectGame, side = None, None

        header = '|' + urllib.urlencode({'User-Agent': 'PS4 libhttp/1.76 (PlayStation 4)'})
        base = re.compile('(.*/).+[.]m3u8').findall(url)

        if not url.endswith('m3u8'):
            return player().run(url + header, selectGame ,side)

        result = client.request(url)

        result = re.compile('BANDWIDTH=(\d*)\n(.+?[.]m3u8)').findall(result)
        result = [(int(int(i[0]) / 1000), i[1]) for i in result]
        result = sorted(result, reverse=True)
        result = [(str(i[0]), base[0] + i[1]) for i in result]

        q = [i[0] for i in result]
        u = [i[1] for i in result]
        select = control.selectDialog(q, control.lang(30756).encode('utf-8'))
        if select == -1: return
        url = u[select]

        player().run(url + header, selectGame ,side)
    except:
        return
Ejemplo n.º 49
0
    def addDirectory(self, items):
        if items == None or len(items) == 0: return
        sysaddon = sys.argv[0]
        addonFanart = control.addonFanart()
        addonThumb = control.addonThumb()
        artPath = control.artPath()

        for i in items:
            try:
                try: name = control.lang(i['name']).encode('utf-8')
                except: name = i['name']

                if i['image'].startswith('http://'): thumb = i['image']
                elif not artPath == None: thumb = os.path.join(artPath, i['image'])
                else: thumb = addonThumb

                url = '%s?action=%s' % (sysaddon, i['action'])
                try: url += '&url=%s' % urllib.quote_plus(i['url'])
                except: pass

                cm = []

                item = control.item(label=name, iconImage=thumb, thumbnailImage=thumb)
                item.addContextMenuItems(cm, replaceItems=False)
                if not addonFanart == None: item.setProperty('Fanart_Image', addonFanart)
                control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)
            except:
                pass
        views.setView('movies', {'skin.confluence': control.viewMode['thumbnails']})
        control.directory(int(sys.argv[1]), cacheToDisc=True)
Ejemplo n.º 50
0
def deleteFavourite(meta, content):
    try:
        meta = json.loads(meta)
        imdb = meta['imdb']
        if 'title' in meta: title = meta['title']
        if 'tvshowtitle' in meta: title = meta['tvshowtitle']

        try:
            dbcon = database.connect(control.favouritesFile)
            dbcur = dbcon.cursor()
            dbcur.execute("DELETE FROM %s WHERE id = '%s'" % (content, imdb))
            dbcon.commit()
        except:
            pass
        try:
            dbcon = database.connect(control.databaseFile)
            dbcur = dbcon.cursor()
            dbcur.execute("DELETE FROM favourites WHERE imdb_id = '%s'" % imdb)
            dbcon.commit()
        except:
            pass

        control.refresh()
        control.infoDialog(control.lang(30412).encode('utf-8'), heading=title)
    except:
        return
Ejemplo n.º 51
0
    def sourcesDialog(self):
        try:
            sources = [{'label': '00 | [B]%s[/B]' % control.lang(30509).encode('utf-8').upper()}] + self.sources

            labels = [i['label'] for i in sources]

            select = control.selectDialog(labels)
            if select == 0: return self.sourcesDirect()
            if select == -1: return 'close://'

            items = [self.sources[select-1]]

            source, quality = items[0]['source'], items[0]['quality']
            next = [y for x,y in enumerate(self.sources) if x >= select]
            prev = [y for x,y in enumerate(self.sources) if x < select][::-1]
            items = [i for i in items+next+prev if i['quality'] == quality and i['source'] == source]
            items += [i for i in next+prev if i['quality'] == quality and not i['source'] == source]
            items = items[:30]

            for i in items:
                try:
                    url = self.sourcesResolve(i['url'], i['provider'])
                    if url == None: raise Exception()

                    self.selectedSource = i['label']
                    return url
                except:
                    pass

        except:
            return
Ejemplo n.º 52
0
def addFavourite(meta, content, query):
    try:
        item = dict()
        meta = json.loads(meta)
        imdb = item['imdb'] = meta['imdb']
        if 'title' in meta: title = item['title'] = meta['title']
        if 'tvshowtitle' in meta: title = item['title'] = meta['tvshowtitle']
        if 'year' in meta: item['year'] = meta['year']
        if 'poster' in meta: item['poster'] = meta['poster']
        if 'fanart' in meta: item['fanart'] = meta['fanart']
        if 'tmdb' in meta: item['tmdb'] = meta['tmdb']
        if 'tvdb' in meta: item['tvdb'] = meta['tvdb']
        if 'tvrage' in meta: item['tvrage'] = meta['tvrage']

        control.makeFile(control.dataPath)
        dbcon = database.connect(control.favouritesFile)
        dbcur = dbcon.cursor()
        dbcur.execute("CREATE TABLE IF NOT EXISTS %s (""id TEXT, ""items TEXT, ""UNIQUE(id)"");" % content)
        dbcur.execute("DELETE FROM %s WHERE id = '%s'" % (content, imdb))
        dbcur.execute("INSERT INTO %s Values (?, ?)" % content, (imdb, repr(item)))
        dbcon.commit()

        if query == None: control.refresh()
        control.infoDialog(control.lang(30411).encode('utf-8'), heading=title)
    except:
        return
Ejemplo n.º 53
0
def download(name, image, url):

    if type(url) is list:
        url = url[0]

    from resources.lib.libraries import control

    if url == None:
        return control.infoDialog(control.lang(30501).encode('utf-8'))

    try: headers = dict(urlparse.parse_qsl(url.rsplit('|', 1)[1]))
    except: headers = dict('')

    url = url.split('|')[0]

    content = re.compile('(.+?)\sS(\d*)E\d*$').findall(name)
    transname = name.translate(None, '\/:*?"<>|').strip('.')
    levels =['../../../..', '../../..', '../..', '..']

    if len(content) == 0:
        dest = control.setting('movie.download.path')
        dest = control.transPath(dest)
        for level in levels:
            try: control.makeFile(os.path.abspath(os.path.join(dest, level)))
            except: pass
        control.makeFile(dest)
        dest = os.path.join(dest, transname)
        control.makeFile(dest)
    else:
        dest = control.setting('tv.download.path')
        dest = control.transPath(dest)
        for level in levels:
            try: control.makeFile(os.path.abspath(os.path.join(dest, level)))
            except: pass
        control.makeFile(dest)
        transtvshowtitle = content[0][0].translate(None, '\/:*?"<>|').strip('.')
        dest = os.path.join(dest, transtvshowtitle)
        control.makeFile(dest)
        dest = os.path.join(dest, 'Season %01d' % int(content[0][1]))
        control.makeFile(dest)

    ext = os.path.splitext(urlparse.urlparse(url).path)[1][1:]
    if not ext in ['mp4', 'mkv', 'flv', 'avi', 'mpg']: ext = 'mp4'
    dest = os.path.join(dest, transname + '.' + ext)

    sysheaders = urllib.quote_plus(json.dumps(headers))

    sysurl = urllib.quote_plus(url)

    systitle = urllib.quote_plus(name)

    sysimage = urllib.quote_plus(image)

    sysdest = urllib.quote_plus(dest)

    script = inspect.getfile(inspect.currentframe())
    cmd = 'RunScript(%s, %s, %s, %s, %s, %s)' % (script, sysurl, sysdest, systitle, sysimage, sysheaders)

    xbmc.executebuiltin(cmd)
Ejemplo n.º 54
0
    def play(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date, url):
        try:
            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)

            from resources.lib.libraries.player import player

            player().run(content, name, url, imdb, tvdb)

            return url
        except:
            control.infoDialog(control.lang(30501).encode("utf-8"))
            pass
Ejemplo n.º 55
0
    def playItem(self, content, name, imdb, tvdb, source):
        try:
            next = []
            prev = []

            for i in range(1,1000000):
                try:
                    u = control.infoLabel('ListItem(%s).FolderPath' % str(i))
                    u = json.loads(dict(urlparse.parse_qsl(u.replace('?','')))['source'])[0]
                    next.append(u)
                except:
                    break
            for i in range(-1000000,0)[::-1]:
                try:
                    u = control.infoLabel('ListItem(%s).FolderPath' % str(i))
                    u = json.loads(dict(urlparse.parse_qsl(u.replace('?','')))['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][:15]
            items += [i for i in next+prev if i['quality'] == quality and not i['source'] == source][:35]

            block = None

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

                    w = workers.Thread(self.sourcesResolve, i['url'], i['provider'])
                    w.start() ; time.sleep(20)

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

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

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

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

                    return self.url
                except:
                    pass

            raise Exception()

        except:
            control.infoDialog(control.lang(30501).encode('utf-8'))
            pass
Ejemplo n.º 56
0
    def sourcesDialog(self):
        try:
            sources = [{'label': '00 | [B]%s[/B]' % control.lang(30509).encode('utf-8').upper()}] + self.sources

            labels = [i['label'] for i in sources]

            select = control.selectDialog(labels)
            if select == 0: return self.sourcesDirect()
            if select == -1: return 'close://'

            items = [self.sources[select-1]]

            next = [y for x,y in enumerate(self.sources) if x >= select]
            prev = [y for x,y in enumerate(self.sources) if x < select][::-1]

            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()

                    for x in range(0, 15 * 2):
                        if self.progressDialog.iscanceled(): return self.progressDialog.close()

                        if xbmc.abortRequested == True: return sys.exit()
                        if w.is_alive() == False: break
                        time.sleep(0.5)

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

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

                    self.selectedSource = items[i]['label']

                    return self.url
                except:
                    pass

        except:
            return