Exemplo n.º 1
0
    def search(self, query=None):
        try:
            if control.infoLabel('Container.PluginName') == '':
                return control.dialog.ok('Exodus', control.lang(30518).encode('utf-8'), '', '')

            if not control.infoLabel('ListItem.Title') == '':
                self.query = control.window.getProperty('%s.movie.search' % control.addonInfo('id'))

            elif query == None:
                t = control.lang(30201).encode('utf-8')
                k = control.keyboard('', t) ; k.doModal()
                self.query = k.getText() if k.isConfirmed() else None

            else:
                self.query = query

            if (self.query == None or self.query == ''): return

            control.window.setProperty('%s.movie.search' % control.addonInfo('id'), self.query)

            url = self.search_link % urllib.quote_plus(self.query)
            self.list = cache.get(self.trakt_list, 0, url)

            self.worker()
            self.movieDirectory(self.list)
            return self.list
        except:
            return
Exemplo n.º 2
0
def add_last_visited(anime_id):
    try:
        c = cache.get(masterani.get_anime_details, 8, anime_id)
        
        lastEpisode = watched.Watched().watched(anime_id)
        
        plot = c['plot']
        premiered = c['premiered']
        genre = c['genre']
        
        type = c['type']

        sysaddon = sys.argv[0]
        addon_poster = addon_banner = control.addonInfo('icon')
        addon_fanart = control.addonInfo('fanart')

        item = control.item("Last Played: [I]%s[/I]" % (c['title']))

        poster = "http://cdn.masterani.me/poster/%s" % c['poster']
        fanart = "http://cdn.masterani.me/wallpaper/0/%s" % c['fanart'][0]
        item.setArt({'poster': poster})
        item.setProperty("Fanart_Image", fanart)
        item.setInfo(type='Video', infoLabels={
            'Plot': plot, 'Year': premiered, 'premiered': premiered,
            'genre': genre, 'mediatype': 'tvshow' 
        })

        url = '%s?action=get_episodes' % sysaddon
        try: url += '&anime_id=%s' % anime_id
        except: pass

        control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)
    except:
        pass
Exemplo n.º 3
0
def addCategoryItem(name, action, image, isFolder=True):
    u = '%s?action=%s' % (sys.argv[0], str(action))
    image = control.addonInfo('path') + '/resources/media/LwSLive/' + image
    item = control.item(name, iconImage=image, thumbnailImage=image)
    item.addContextMenuItems([], replaceItems=False)
    item.setProperty('Fanart_Image', control.addonInfo('fanart'))
    control.addItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=isFolder)
Exemplo n.º 4
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)
Exemplo n.º 5
0
    def onPlayBackStopped(self):

        from resources.lib.modules import utils;

        try:

            pname = '%s.player.overlay' % control.addonInfo('id');
            rname = '%s.player.resumetime' % control.addonInfo('id');

            rtime = str(int(self.currentTime));

            watcher = ((self.currentTime / self.totalTime) >= .9);
            property = control.window.getProperty(pname);

            '''self.item.setProperty("resumetime", str(1000))
            control.window.setProperty(rname, str(1000));

            self.item.setInfo(type='Video', infoLabels = {'resumetime':str(1000)});
            control.refresh();'''

            if watcher == True and not property == '7':

                try:
                    control.window.setProperty(pname, '7');

                except Exception as inst:
                    logger.error(inst);
                    pass;

                utils.syncdbprogress(self.show_id, self.asset_id, self.content, self.currentTime, self.totalTime, True, '7');

            elif watcher == False and not property == '6':

                try:
                    control.window.setProperty(pname, '6');

                except Exception as inst:
                    logger.error(inst);
                    pass;
                    
                utils.syncdbprogress(self.show_id, self.asset_id, self.content, self.currentTime, self.totalTime, True, '6');

            else:
                utils.syncdbprogress(self.show_id, self.asset_id, self.content, self.currentTime, self.totalTime, True, property);

            '''else:
                #We want to show the inprogress tag but it is not working
                control.window.setProperty(rname, rtime);
                control.refresh();'''


            control.refresh();          

        except Exception as inst:
            logger.error(inst);

            pass;
Exemplo n.º 6
0
def add_favorites():
    try:
        favorite = favorites.Favorites().list()
        if len(favorite) > 0:
            sysaddon = sys.argv[0]
            addon_poster = addon_banner = control.addonInfo('icon')
            addon_fanart = control.addonInfo('fanart')
            item = control.item("Favorites")
            url = '%s?action=%s' % (sysaddon, "favorites")

            item.setArt({'poster': addon_poster, 'banner': addon_banner})
            item.setProperty('Fanart_Image', addon_fanart)
            control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)
    except:
        pass
Exemplo n.º 7
0
    def worker(self):
        try:
            total = len(self.list)

            threads = []
            for i in range(0, total):
                if i <= total: threads.append(workers.Thread(self.get_fanart, i))
            [i.start() for i in threads]

            timeout = 30
            progress = control.progressDialog
            progress.create(control.addonInfo('name'), '')
            progress.update(0, line1="%s shows found." % total, line2="Loading information.")

            print "Adding progress dialog with %s total shows" % total
            for i in range(timeout * 2):
                if xbmc.abortRequested == True: return sys.exit()

                progress.update(int((100 / float(len(threads))) * len([x for x in threads if x.is_alive() is False])),
                                line3="%s remaining." % len([x for x in threads if x.is_alive() is True]))
                if progress.iscanceled(): break

                is_alive = [x.is_alive() for x in threads]
                if all(x is False for x in is_alive): break
                xbmc.sleep(100)
            progress.close()
        except:
            pass
Exemplo n.º 8
0
    def sourcesDirect(self, progress=True):
        filter = [i for i in self.sources if i['source'].lower() in self.hostcapDict and i['debrid'] == '']
        self.sources = [i for i in self.sources if not i in filter]

        self.sources = [i for i in self.sources if ('autoplay' in i and i['autoplay'] == True) or not 'autoplay' in i]

        if control.setting("autoplay.sd") == 'true':
            self.sources = [i for i in self.sources if not i['quality'] in ['1080p', 'HD']]

        u = None

        if progress == True:
            self.progressDialog = control.progressDialog
            self.progressDialog.create(control.addonInfo('name'), '')
            self.progressDialog.update(0)

        for i in range(len(self.sources)):
            try:
                if progress == True:
                    if self.progressDialog.iscanceled(): break
                    self.progressDialog.update(int((100 / float(len(self.sources))) * i), str(self.sources[i]['label']), str(' '))

                if xbmc.abortRequested == True: return sys.exit()

                url = self.sourcesResolve(self.sources[i])
                if u == None: u = url
                if not url == None: break
            except:
                pass

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

        return u
Exemplo n.º 9
0
    def root(self):
        self.addDirectoryItem(30001, 'movieNavigator', 'movies.png', 'DefaultMovies.png')
        self.addDirectoryItem(30002, 'tvNavigator', 'tvshows.png', 'DefaultTVShows.png')
        self.addDirectoryItem(30003, 'channels', 'channels.png', 'DefaultMovies.png')

        if not control.setting('lists.widget') == '0':
            self.addDirectoryItem(30004, 'myNavigator', 'userlists.png', 'DefaultVideoPlaylists.png')

        if not control.setting('movie.widget') == '0':
            self.addDirectoryItem(30005, 'movieWidget', 'latest-movies.png', 'DefaultRecentlyAddedMovies.png', queue=True)

        if (traktIndicators == True and not control.setting('tv.widget.alt') == '0') or (traktIndicators == False and not control.setting('tv.widget') == '0'):
            self.addDirectoryItem(30006, 'tvWidget', 'latest-episodes.png', 'DefaultRecentlyAddedEpisodes.png', queue=True)

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

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

        downloads = True if control.setting('downloads') == 'true' and (len(control.listDir(control.setting('movie.download.path'))[0]) > 0 or len(control.listDir(control.setting('tv.download.path'))[0]) > 0) else False
        if downloads == True:
            self.addDirectoryItem(30010, 'downloadNavigator', 'downloads.png', 'DefaultFolder.png')

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

        self.endDirectory()

        from resources.lib.modules import cache
        from resources.lib.modules import changelog
        cache.get(changelog.get, 600000000, control.addonInfo('version'), table='changelog')
Exemplo n.º 10
0
def tvshows(tvshowtitle, imdb, tvdb, season, watched):
    control.busy()
    try:
        import sys,xbmc

        if not trakt.getTraktIndicatorsInfo() == False: raise Exception()

        from metahandler import metahandlers
        from resources.lib.indexers import episodes

        metaget = metahandlers.MetaData(preparezip=False)

        name = control.addonInfo('name')

        dialog = control.progressDialogBG
        dialog.create(str(name), str(tvshowtitle))
        dialog.update(0, str(name), str(tvshowtitle))

        metaget.get_meta('tvshow', name='', imdb_id=imdb)

        items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, '0', idx=False)
        try: items = [i for i in items if int('%01d' % int(season)) == int('%01d' % int(i['season']))]
        except: pass
        items = [{'label': '%s S%02dE%02d' % (tvshowtitle, int(i['season']), int(i['episode'])), 'season': int('%01d' % int(i['season'])), 'episode': int('%01d' % int(i['episode']))} for i in items]

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

            dialog.update(int((100 / float(len(items))) * i), str(name), str(items[i]['label']))

            season, episode = items[i]['season'], items[i]['episode']
            metaget.get_episode_meta('', imdb_id=imdb, season=season, episode=episode)
            metaget.change_watched('episode', '', imdb_id=imdb, season=season, episode=episode, watched=int(watched))

        try: dialog.close()
        except: pass
    except:
        try: dialog.close()
        except: pass


    try:
        if trakt.getTraktIndicatorsInfo() == False: raise Exception()

        if season:
            from resources.lib.indexers import episodes
            items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, season, idx=False)
            items = [(int(i['season']), int(i['episode'])) for i in items]
            items = [i[1] for i in items if int('%01d' % int(season)) == int('%01d' % i[0])]
            for i in items:
                if int(watched) == 7: trakt.markEpisodeAsWatched(tvdb, season, i)
                else: trakt.markEpisodeAsNotWatched(tvdb, season, i)
        else:
            if int(watched) == 7: trakt.markTVShowAsWatched(tvdb)
            else: trakt.markTVShowAsNotWatched(tvdb)
        trakt.cachesyncTVShows()
    except:
        pass

    control.refresh()
Exemplo n.º 11
0
def addCategoryItem(name, action, image, isFolder=True):
    u = '%s?action=%s' % (sys.argv[0], str(action))
    item = control.item(name, iconImage=image, thumbnailImage=image)
    try: item.setArt({'icon': image})
    except: pass
    item.addContextMenuItems([], replaceItems=False)
    item.setProperty('Fanart_Image', control.addonInfo('fanart'))
    control.addItem(handle=int(sys.argv[1]),url=u,listitem=item,isFolder=isFolder)
Exemplo n.º 12
0
def add_directory(items):
    if items is None or len(items) == 0: return

    sysaddon = sys.argv[0]
    addon_poster = addon_banner = control.addonInfo('icon')
    addon_fanart = control.addonInfo('fanart')

    for i in items:
        item = control.item(i['name'])
        url = '%s?action=%s' % (sysaddon, i['action'])

        item.setArt({'poster': addon_poster, 'banner': addon_banner})
        item.setProperty('Fanart_Image', addon_fanart)
        control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)

    control.directory(int(sys.argv[1]), cacheToDisc=True)
    control.content(int(sys.argv[1]), 'files')
Exemplo n.º 13
0
    def __init__(self):
        self.library_folder = os.path.join(control.transPath(control.setting("tv_library")), "")

        self.library_setting = control.setting("update_library") or "true"
        self.property = "%s_service_property" % control.addonInfo("name").lower()

        self.datetime = datetime.datetime.utcnow() - datetime.timedelta(hours=5)
        self.date = (self.datetime - datetime.timedelta(hours=24)).strftime("%Y%m%d")

        self.infoDialog = False
Exemplo n.º 14
0
    def __init__(self):
        self.library_folder = os.path.join(control.transPath(control.setting('library.tv')),'')

        self.library_setting = control.setting('library.update') or 'true'
        self.include_unknown = control.setting('library.include_unknown') or 'true'
        self.property = '%s_service_property' % control.addonInfo('name').lower()

        self.datetime = (datetime.datetime.utcnow() - datetime.timedelta(hours = 5))
        self.date = (self.datetime - datetime.timedelta(hours = 24)).strftime('%Y%m%d')

        self.infoDialog = False
Exemplo n.º 15
0
def Addtypes():
   addDir('Live On Air' ,playlist,2,icon ,  FANART,'','','','')
   addDir('Recent' ,API+'recent',9,icon ,  FANART,'','','','')
   addDir('Popular' ,API+'popular',9,icon ,  FANART,'','','','')
   addDir('Weekend Mix' ,'http://pastebin.com/raw/C0H0i8f9',5,icon ,  FANART,'','','','')
   addDir('Daily Mix' ,'http://pastebin.com/raw/Sv1vLn0X',5,icon ,  FANART,'','','','')
   #addDir('Top 3' ,'top3',4,icon ,  FANART,'','','','')
   addDir('Playlist' ,'top3',6,icon ,  FANART,'','','','')
   addDir('VideoClips' ,'jukebox',8,icon ,  FANART,'','','','')
   addDir('Search' ,'Search',12,icon ,  FANART,'','','','')
   from resources.lib.modules import cache, control, changelog
   cache.get(changelog.get, 600000000, control.addonInfo('version'), table='changelog')
Exemplo n.º 16
0
def promptForLogin(prompt=None):
    import xbmcgui;
    from resources.lib.modules import control;

    __settings__ = xbmcaddon.Addon(control.addonInfo('id'))

    if prompt:
        if xbmcgui.Dialog().yesno(control.lang(32755).encode('utf-8'), control.lang(32756).encode('utf-8'), control.lang(32757).encode('utf-8')):
            __settings__.openSettings();

    else:
        __settings__.openSettings();
Exemplo n.º 17
0
def add_last_visited(anime_id):
    try:
        c = cache.get(masterani.get_anime_details, 8, anime_id)

        sysaddon = sys.argv[0]
        addon_poster = addon_banner = control.addonInfo('icon')
        addon_fanart = control.addonInfo('fanart')

        item = control.item("Last Played: [I]%s[/I]" % c['title'])

        poster = "http://cdn.masterani.me/poster/%s" % c['poster']
        fanart = "http://cdn.masterani.me/wallpaper/0/%s" % c['fanart'][0]
        item.setArt({'poster': poster})
        item.setProperty("Fanart_Image", fanart)

        url = '%s?action=get_episodes' % sysaddon
        try: url += '&anime_id=%s' % anime_id
        except: pass

        control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)
    except:
        pass
Exemplo n.º 18
0
    def getURISource(self, url):
        u = None

        sourceDict = []
        for package, name, is_pkg in pkgutil.walk_packages(__path__): sourceDict.append((name, is_pkg))
        sourceDict = [i[0] for i in sourceDict if i[1] == False]
        sourceDict = [(i, __import__(i, globals(), locals(), [], -1).source()) for i in sourceDict]

        domain = re.sub('^www\.|^www\d+\.', '', urlparse.urlparse(url.strip().lower()).netloc)

        domains = [(i[0], i[1].domains) for i in sourceDict]
        domains = [i[0] for i in domains if any(x in domain for x in i[1])]

        if not domains: return False

        call = [i[1] for i in sourceDict if i[0] == domains[0]][0]

        progressDialog = control.progressDialog
        progressDialog.create(control.addonInfo('name'), control.lang(30726).encode('utf-8'))
        progressDialog.update(0)

        progressDialog.update(0, control.lang(30726).encode('utf-8'), control.lang(30731).encode('utf-8'))

        self.sources = call.sources(url, self.hostDict, self.hostprDict)

        progressDialog.update(50, control.lang(30726).encode('utf-8'), control.lang(30731).encode('utf-8'))

        items = self.sourcesFilter()

        filter = [i for i in items if i['source'].lower() in self.hostcapDict and i['debrid'] == '']
        items = [i for i in items if not i in filter]

        filter = [i for i in items if i['source'].lower() in self.hostblockDict and i['debrid'] == '']
        items = [i for i in items if not i in filter]

        items = [i for i in items if ('autoplay' in i and i['autoplay'] == True) or not 'autoplay' in i]

        for i in range(len(items)):
            try:
                if progressDialog.iscanceled(): break
                if xbmc.abortRequested == True: return sys.exit()
                url = self.sourcesResolve(items[i])
                if u == None: u = url
                if not url == None: break
            except:
                pass

        try: progressDialog.close()
        except: pass

        return u
Exemplo n.º 19
0
    def search(self, query=None):
        try:
            if not control.infoLabel('ListItem.Title') == '':
                self.query = control.window.getProperty('%s.tvshow.search' % control.addonInfo('id'))

            elif query == None:
                t = control.lang(30231).encode('utf-8')
                k = control.keyboard('', t) ; k.doModal()
                self.query = k.getText() if k.isConfirmed() else None
            else:
                self.query = query

            if (self.query == None or self.query == ''): return

            control.window.setProperty('%s.tvshow.search' % control.addonInfo('id'), self.query)

            url = self.search_link % urllib.quote_plus(self.query)
            self.list = cache.get(self.trakt_list, 0, url)

            self.worker()
            self.tvshowDirectory(self.list)
            return self.list
        except:
            return
Exemplo n.º 20
0
    def __init__(self):
        self.priority = 1
        self.language = ['ab', 'aa', 'af', 'ak', 'sq', 'am', 'ar', 'an', 'hy', 'as', 'av', 'ae', 'ay', 'az', 'bm', 'ba', 'eu', 'be', 'bn', 'bh', 'bi', 'nb', 'bs', 'br', 'bg', 'my', 'ca', 'ch', 'ce', 'ny', 'zh', 'cv', 'kw', 'co', 'cr', 'hr', 'cs', 'da', 'dv', 'nl', 'dz', 'en', 'eo', 'et', 'ee', 'fo', 'fj', 'fi', 'fr', 'ff', 'gd', 'gl', 'lg', 'ka', 'de', 'el', 'gn', 'gu', 'ht', 'ha', 'he', 'hz', 'hi', 'ho', 'hu', 'is', 'io', 'ig', 'id', 'ia', 'ie', 'iu', 'ik', 'ga', 'it', 'ja', 'jv', 'kl', 'kn', 'kr', 'ks', 'kk', 'km', 'ki', 'rw', 'rn', 'kv', 'kg', 'ko', 'ku', 'kj', 'ky', 'lo', 'la', 'lv', 'li', 'ln', 'lt', 'lu', 'lb', 'mk', 'mg', 'ms', 'ml', 'mt', 'gv', 'mi', 'mr', 'mh', 'mn', 'na', 'nv', 'ng', 'ne', 'nd', 'se', 'no', 'ii', 'nn', 'oc', 'oj', 'or', 'om', 'os', 'pi', 'ps', 'fa', 'pl', 'pt', 'pa', 'qu', 'ro', 'rm', 'ru', 'sm', 'sg', 'sa', 'sc', 'sr', 'sn', 'sd', 'si', 'cu', 'sk', 'sl', 'so', 'nr', 'st', 'es', 'su', 'sw', 'ss', 'sv', 'tl', 'ty', 'tg', 'ta', 'tt', 'te', 'th', 'bo', 'ti', 'to', 'ts', 'tn', 'tr', 'tk', 'tw', 'uk', 'ur', 'ug', 'uz', 've', 'vi', 'vo', 'wa', 'cy', 'fy', 'wo', 'xh', 'yi', 'yo', 'za', 'zu']
        self.key = 'VkZOQ1MwbEZXV2RUZVVKUFNVVnpaMVZEUWxGSlJWVm5VVk5CTWtsRlZXZFNVMEUxU1VVMFoxTkRRbEpKUlRCblVYbENWRWxGVVdkU1UwRXhTVVZaWjA1NVFrbEpSVEJuVmxOQ1JVbEdRV2RTYVVKSg=='
        self.domains = ['https://orionoid.com']
        self.providers = []
        self.cachePath = os.path.join(xbmc.translatePath(control.addonInfo('profile').decode('utf-8')), 'orion.cache')
        self.cacheData = None
        self.resolvers = None
        self.settingInfo = int(control.setting('provider.orionoid.info'))
        self.settingStreamtype = int(control.setting('orionoid.streamtype'))

        if self.settingStreamtype == 0: self.StreamType = Orion.StreamHoster
        elif self.settingStreamtype == 1: self.StreamType = Orion.StreamTorrent
        else: self.StreamType = Orion.StreamHoster + Orion.StreamTorrent
Exemplo n.º 21
0
    def __init__(self):
        self.library_folder = os.path.join(control.transPath(control.setting('library.tv')),'')

        self.library_setting = control.setting('library.update') or 'true'
        self.include_unknown = control.setting('library.include_unknown') or 'true'
        self.include_special = control.setting('library.include_special')
        self.property = '%s_service_property' % control.addonInfo('name').lower()

        self.datetime = datetime.datetime.utcnow()
        if control.setting('library.importdelay') != 'true':
            self.date = self.datetime.strftime('%Y%m%d')
        else:
            self.date = (self.datetime - datetime.timedelta(hours=24)).strftime('%Y%m%d')

        self.infoDialog = False
Exemplo n.º 22
0
def tvshows(tvshowtitle, imdb, tvdb, season, watched):
    try:
        import sys,xbmc

        if not trakt.getTraktIndicatorsInfo() == False: raise Exception()

        from metahandler import metahandlers
        from resources.lib.indexers import episodes

        metaget = metahandlers.MetaData(preparezip=False)

        dialog = control.progressDialog
        dialog.create(control.addonInfo('name'), str(tvshowtitle))
        dialog.update(0, str(tvshowtitle), control.lang(30451).encode('utf-8') + '...')

        metaget.get_meta('tvshow', name='', imdb_id=imdb)

        items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, '0', idx=False)
        try: items = [i for i in items if int('%01d' % int(season)) == int('%01d' % int(i['season']))]
        except: pass
        items = [{'label': '%s S%02dE%02d' % (tvshowtitle, int(i['season']), int(i['episode'])), 'season': int('%01d' % int(i['season'])), 'episode': int('%01d' % int(i['episode']))} for i in items]

        for i in range(len(items)):
            if xbmc.abortRequested == True: return sys.exit()
            if dialog.iscanceled(): return dialog.close()

            dialog.update(int((100 / float(len(items))) * i), str(tvshowtitle), str(items[i]['label']))

            season, episode = items[i]['season'], items[i]['episode']
            metaget.get_episode_meta('', imdb_id=imdb, season=season, episode=episode)
            metaget.change_watched('episode', '', imdb_id=imdb, season=season, episode=episode, watched=int(watched))

        try: dialog.close()
        except: pass
    except:
        try: dialog.close()
        except: pass


    try:
        if trakt.getTraktIndicatorsInfo() == False: raise Exception()
        if int(watched) == 7: trakt.markTVShowAsWatched(tvdb)
        else: trakt.markTVShowAsNotWatched(tvdb)
        trakt.cachesyncTVShows()
    except:
        pass

    control.refresh()
Exemplo n.º 23
0
    def __init__(self):
        self.library_folder = os.path.join(
            control.transPath(control.setting('tv_library')), '')

        self.library_setting = control.setting('update_library') or 'true'
        self.include_unknown = control.setting(
            'library.include_unknown') or 'true'
        self.property = '%s_service_property' % control.addonInfo(
            'name').lower()

        self.datetime = (datetime.datetime.utcnow() -
                         datetime.timedelta(hours=5))
        self.date = (self.datetime -
                     datetime.timedelta(hours=24)).strftime('%Y%m%d')

        self.infoDialog = False
Exemplo n.º 24
0
    def sourcesDirect(self, items):
        filter = [i for i in items if i['source'].lower() in self.hostcapDict and i['debrid'] == '']
        items = [i for i in items if not i in filter]

        filter = [i for i in items if i['source'].lower() in self.hostblockDict and i['debrid'] == '']
        items = [i for i in items if not i in filter]

        items = [i for i in items if ('autoplay' in i and i['autoplay'] == True) or not 'autoplay' in i]

        if control.setting('autoplay.sd') == 'true':
            items = [i for i in items if not i['quality'] in ['4K', '1440p', '1080p', 'HD']]

        u = None

        header = control.addonInfo('name')
        header2 = header.upper()

        try:
            control.sleep(1000)

            progressDialog = control.progressDialog if control.setting('progress.dialog') == '0' else control.progressDialogBG
            progressDialog.create(header, '')
            progressDialog.update(0)
        except:
            pass

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

            try:
                if xbmc.abortRequested == True: return sys.exit()

                url = self.sourcesResolve(items[i])
                if u == None: u = url
                if not url == None: break
            except:
                pass

        try: progressDialog.close()
        except: pass

        return u
Exemplo n.º 25
0
def run(params):
    from resources.lib.modules import control

    params = params or {}

    control.log('[BRplay] - PARAMS: %s' % params)

    # Parameters
    action = params.get('action')

    meta = params.get('meta')

    try:
        meta_json = json.loads(meta) if meta else None
    except:
        control.log(traceback.format_exc(), control.LOGERROR)
        meta_json = {}

    # Actions
    if not action:
        from resources.lib.indexers import navigator, indexer
        syshandle = int(sys.argv[1])
        indexer.create_directory(navigator.root(), cache_to_disk=False)
        control.category(handle=syshandle, category=control.addonInfo('name'))

    elif action == 'settings':
        from resources.lib.indexers import navigator
        navigator.open_settings()

    elif action == 'clear':
        from resources.lib.indexers import navigator
        navigator.clear_cache()

    elif action == 'clearAuth':
        from resources.lib.indexers import navigator
        navigator.clear_credentials()

    elif action == 'refresh':
        from resources.lib.modules import control
        control.refresh()

    # Generic Tree

    elif action == 'generic':
        from resources.lib.indexers import indexer
        indexer.handle_route(meta_json)
Exemplo n.º 26
0
    def sourcesDirect(self, items):
        # filter = [i for i in items if i['source'].lower() in self.hostcapDict and i['debrid'] == '']
        # items = [i for i in items if not i in filter]

        # filter = [i for i in items if i['source'].lower() in self.hostblockDict and i['debrid'] == '']
        items = [i for i in items]

        # items = [i for i in items if ('autoplay' in i and i['autoplay'] == True) or not 'autoplay' in i]

        if control.setting('autoplay.sd') == 'true':
            items = [i for i in items if not i['quality'] in ['1080p', 'HD']]

        u = None

        header = control.addonInfo('name')
        header2 = header.upper()

        try:
            control.sleep(1000)

            progressDialog = control.progressDialog if control.setting('progress.dialog') == '0' else control.progressDialogBG
            progressDialog.create(header, '')
            progressDialog.update(0)
        except:
            pass

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

            try:
                if xbmc.abortRequested == True: return sys.exit()

                url = self.sourcesResolve(items[i])
                if u == None: u = url
                if not url == None: break
            except:
                pass

        try: progressDialog.close()
        except: pass

        return u
Exemplo n.º 27
0
    def sourcesDirect(self, progress=True):
        filter = [
            i for i in self.sources
            if i['source'].lower() in self.hostcapDict and i['debrid'] == ''
        ]
        self.sources = [i for i in self.sources if not i in filter]

        self.sources = [
            i for i in self.sources if
            ('autoplay' in i and i['autoplay'] == True) or not 'autoplay' in i
        ]

        if control.setting("autoplay.sd") == 'true':
            self.sources = [
                i for i in self.sources if not i['quality'] in ['1080p', 'HD']
            ]

        u = None

        if progress == True:
            self.progressDialog = control.progressDialog
            self.progressDialog.create(control.addonInfo('name'), '')
            self.progressDialog.update(0)

        for i in range(len(self.sources)):
            try:
                if progress == True:
                    if self.progressDialog.iscanceled(): break
                    self.progressDialog.update(
                        int((100 / float(len(self.sources))) * i),
                        str(self.sources[i]['label']), str(' '))

                if xbmc.abortRequested == True: return sys.exit()

                url = self.sourcesResolve(self.sources[i])
                if u == None: u = url
                if not url == None: break
            except:
                pass

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

        return u
Exemplo n.º 28
0
def tvshows(tvshowtitle, imdb, tvdb, season, watched):
	watched = int(watched)
	try:
		if traktIndicators:
			if watched == 5: trakt.watch(name=tvshowtitle, imdb=imdb, tvdb=tvdb, season=season, refresh=True)
			else: trakt.unwatch(name=tvshowtitle, imdb=imdb, tvdb=tvdb, season=season, refresh=True)
		else:
			from metahandler import metahandlers
			from resources.lib.menus import episodes
			from sys import exit as sysexit

			name = addonInfo('name')
			dialog = progressDialogBG
			dialog.create(str(name), str(tvshowtitle))
			dialog.update(0, str(name), str(tvshowtitle))

			metaget = metahandlers.MetaData(tmdb_api_key, omdb_api_key, tvdb_api_key)
			metaget.get_meta('tvshow', name='', imdb_id=imdb)

			items = episodes.Episodes().get(tvshowtitle, '0', imdb, tvdb, {}, create_directory=False)

			for i in range(len(items)):
				items[i]['season'] = int(items[i]['season'])
				items[i]['episode'] = int(items[i]['episode'])
			try: items = [i for i in items if int('%01d' % int(season)) == int('%01d' % i['season'])]
			except: pass

			items = [{'label': '%s S%02dE%02d' % (tvshowtitle, i['season'], i['episode']), 'season': int('%01d' % i['season']), 'episode': int('%01d' % i['episode'])} for i in items]
			count = len(items)
			for i in range(count):
				if monitor.abortRequested(): return sysexit()
				dialog.update(int(100.0 / count * i), str(name), str(items[i]['label']))
				season, episode = items[i]['season'], items[i]['episode']
				metaget.get_episode_meta('', imdb_id=imdb, season=season, episode=episode)
				metaget.change_watched('episode', '', imdb_id=imdb, season=season, episode=episode, watched=watched)
			tvshowsUpdate(imdb=imdb, tvdb=tvdb)

			try: dialog.close()
			except: pass
			del dialog
	except:
		from resources.lib.modules import log_utils
		log_utils.error()
Exemplo n.º 29
0
def tvshowsUpdate(imdb, tvdb):
	try:
		if traktIndicators is True:
			return

		from metahandler import metahandlers
		from resources.lib.menus import episodes

		name = control.addonInfo('name')
		metaget = metahandlers.MetaData()
		metaget.get_meta('tvshow', name='', imdb_id=imdb)

		items = episodes.Episodes().get('', '0', imdb, tvdb, idx=False)

		for i in range(len(items)):
			items[i]['season'] = int(items[i]['season'])
			items[i]['episode'] = int(items[i]['episode'])

		seasons = {}

		for i in items:
			if i['season'] not in seasons:
				seasons[i['season']] = []
			seasons[i['season']].append(i)

		countSeason = 0

		metaget.get_seasons('', imdb, seasons.keys()) # Must be called to initialize the database.

		for key, value in seasons.iteritems():
			countEpisode = 0

			for i in value:
				countEpisode += int(metaget._get_watched_episode({'imdb_id': i['imdb'], 'season': i['season'], 'episode': i['episode'], 'premiered': ''}) == 7)

			countSeason += int(countEpisode == len(value))
			metaget.change_watched('season', '', imdb_id = imdb, season = key, watched = 7 if countEpisode == len(value) else 6)
		metaget.change_watched('tvshow', '', imdb_id = imdb, watched = 7 if countSeason == len(seasons.keys()) else 6)
	except:
		log_utils.error()

	control.refresh()
Exemplo n.º 30
0
def get():
    changelogfile = os.path.join(control.addonPath, 'changelog.txt')
    r = open(changelogfile)
    text = r.read()
    id = 10147
    control.execute('ActivateWindow(%d)' % id)
    control.sleep(500)
    win = xbmcgui.Window(id)
    retry = 50
    while (retry > 0):
        try:
            control.sleep(10)
            retry -= 1
            win.getControl(1).setLabel(
                ' [COLOR gold] TheOath [/COLOR]v%s Changelog' %
                (control.addonInfo('version')))
            win.getControl(5).setText(text)
            return
        except:
            pass
Exemplo n.º 31
0
def tvshows(tvshowtitle, imdb, tvdb, season, watched):
    try:
        import sys,xbmc

        if not trakt.getTraktIndicatorsInfo() == False: raise Exception()
        watched=int(watched)
        from metahandler import metahandlers
        from resources.lib.indexers import episodes
        imdb = imdb.encode('utf-8')
        metaget = metahandlers.MetaData(preparezip=False)

        name = control.addonInfo('name')

        dialog = control.progressDialogBG
        dialog.create(str(name), str(tvshowtitle))
        dialog.update(0, str(name), str(tvshowtitle))

        items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, '0', idx=False)
        try: items = [i for i in items if int('%01d' % int(season)) == int('%01d' % int(i['season']))]
        except: pass
        items = [{'label': '%s S%02dE%02d' % (tvshowtitle, int(i['season']), int(i['episode'])), 'season': int('%01d' % int(i['season'])), 'episode': int('%01d' % int(i['episode']))} for i in items]

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

            dialog.update(int((100 / float(len(items))) * i), str(name), str(items[i]['label']))

            season, episode = items[i]['season'], items[i]['episode']
            metaget.get_episode_meta('', imdb, season, episode)
            metaget.change_watched('episode', '', imdb, season=season, episode=episode, year='', watched=watched)

        try: dialog.close()
        except: pass
    except:
        try: dialog.close()
        except: pass


    control.refresh()
Exemplo n.º 32
0
def tvshows(tvshowtitle, imdb, tvdb, season, watched):
    try:
        import sys,xbmc

        if not trakt.getTraktIndicatorsInfo() == False: raise Exception()
        watched=int(watched)
        from metahandler import metahandlers
        from resources.lib.indexers import episodes
        imdb = imdb.encode('utf-8')
        metaget = metahandlers.MetaData(preparezip=False)

        name = control.addonInfo('name')

        dialog = control.progressDialogBG
        dialog.create(str(name), str(tvshowtitle))
        dialog.update(0, str(name), str(tvshowtitle))

        items = episodes.episodes().get(tvshowtitle, '0', imdb, tvdb, '0', idx=False)
        try: items = [i for i in items if int('%01d' % int(season)) == int('%01d' % int(i['season']))]
        except: pass
        items = [{'label': '%s S%02dE%02d' % (tvshowtitle, int(i['season']), int(i['episode'])), 'season': int('%01d' % int(i['season'])), 'episode': int('%01d' % int(i['episode']))} for i in items]

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

            dialog.update(int((100 / float(len(items))) * i), str(name), str(items[i]['label']))

            season, episode = items[i]['season'], items[i]['episode']
            metaget.get_episode_meta('', imdb, season, episode)
            metaget.change_watched('episode', '', imdb, season=season, episode=episode, year='', watched=watched)

        try: dialog.close()
        except: pass
    except:
        try: dialog.close()
        except: pass


    control.refresh()
Exemplo n.º 33
0
def hideItem(name, imdb=None, tvdb=None, season=None, episode=None, refresh=True):
	sections = ['progress_watched', 'calendar']
	sections_display = [control.lang(40072), control.lang(40073)]
	selection = control.selectDialog([i for i in sections_display], heading = control.addonInfo('name') + ' - ' + control.lang(40074))

	if selection == -1:
		return

	section = sections[selection]

	if episode is not None:
		post = {"shows": [{"ids": {"tvdb": tvdb}}]}
	else:
		post = {"movies": [{"ids": {"imdb": imdb}}]}

	getTrakt('users/hidden/%s' % section, post = post)[0]

	if refresh:
		control.refresh()
	control.trigger_widget_refresh()
	if control.setting('trakt.general.notifications') == 'true':
		control.notification(title=32315, message=control.lang(33053) % (name, sections_display[selection]), icon='default', sound=(control.setting('notification.sound') == 'true'))
Exemplo n.º 34
0
    def play(self, title, year, imdb, tvdb, season, episode, tvshowtitle, premiered, meta, url):
        try:
            if not control.addonInfo('id').lower() == control.infoLabel('Container.PluginName').lower():
                progress = True if control.setting('progress.dialog') == '1' else False
            else:
                control.resolve(int(sys.argv[1]), True, control.item(path=''))
                control.execute('Dialog.Close(okdialog)')
                progress = True

            if 'super.fav' in control.infoLabel('Container.PluginName'):
                return control.dialog.ok('Exodus', control.lang(30518).encode('utf-8'), '', '')

            self.sources = self.getSources(title, year, imdb, tvdb, season, episode, tvshowtitle, premiered, progress=progress)
            self.sources = self.sourcesFilter()

            if control.window.getProperty('PseudoTVRunning') == 'True':
                return control.resolve(int(sys.argv[1]), True, control.item(path=str(self.sourcesDirect(progress=progress))))

            if self.sources == []: raise Exception()

            if url == 'direct://': url = self.sourcesDirect(progress=progress)
            elif url == 'dialog://': url = self.sourcesDialog(progress=progress)
            elif control.setting('autoplay') == 'false': url = self.sourcesDialog(progress=progress)
            else: url = self.sourcesDirect(progress=progress)

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

            control.sleep(200)

            if not tvshowtitle == None: title = tvshowtitle

            from resources.lib.modules.player import player
            player().run(title, year, season, episode, imdb, tvdb, meta, url)

            return url
        except:
            control.infoDialog(control.lang(30501).encode('utf-8'))
Exemplo n.º 35
0
    def play(self, title, year, imdb, tmdb, tvdb, season, episode, tvshowtitle, premiered, meta, url):
        try:
            if not control.addonInfo('id').lower() == control.infoLabel('Container.PluginName').lower():
                progress = True if control.setting('progress.dialog') == '1' else False
            else:
                control.resolve(int(sys.argv[1]), True, control.item(path=''))
                control.execute('Dialog.Close(okdialog)')
                progress = True

            if 'super.fav' in control.infoLabel('Container.PluginName'):
                return control.dialog.ok('Exodus', control.lang(30518).encode('utf-8'), '', '')

            self.sources = self.getSources(title, year, imdb, tmdb, tvdb, season, episode, tvshowtitle, premiered, progress=progress)
            self.sources = self.sourcesFilter()

            if control.window.getProperty('PseudoTVRunning') == 'True':
                return control.resolve(int(sys.argv[1]), True, control.item(path=str(self.sourcesDirect(progress=progress))))

            if self.sources == []: raise Exception()

            if url == 'direct://': url = self.sourcesDirect(progress=progress)
            elif url == 'dialog://': url = self.sourcesDialog(progress=progress)
            elif control.setting('autoplay') == 'false': url = self.sourcesDialog(progress=progress)
            else: url = self.sourcesDirect(progress=progress)

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

            control.sleep(200)

            if not tvshowtitle == None: title = tvshowtitle

            from resources.lib.modules.player import player
            player().run(title, year, season, episode, imdb, tmdb, tvdb, meta, url)

            return url
        except:
            control.infoDialog(control.lang(30501).encode('utf-8'))
Exemplo n.º 36
0
def playlistManager(name=None, url=None, meta=None, art=None):
    try:
        items = []
        items += [(control.lang(32065).encode('utf-8'), 'playlistAdd')]
        items += [(control.lang(35518).encode('utf-8'), 'playlistRemove')]
        items += [(control.lang(35517).encode('utf-8'), 'playlistShow')]
        items += [(control.lang(35516).encode('utf-8'), 'playlistClear')]

        control.hide()
        select = control.selectDialog([i[0] for i in items],
                                      heading=control.addonInfo('name') +
                                      ' - ' +
                                      control.lang(35522).encode('utf-8'))

        if select == -1:
            return
        if select >= 0:
            if select == 0:
                control.busy()
                playlistAdd(name, url, meta, art)
                control.hide()
            elif select == 1:
                control.busy()
                playlistRemove(name)
                control.hide()
            elif select == 2:
                control.busy()
                playlistShow()
                control.hide()
            elif select == 3:
                control.busy()
                playlistClear()
                control.hide()
    except:
        import traceback
        traceback.print_exc()
        control.hide()
Exemplo n.º 37
0
    def worker(self):
        total = len(self.list)

        threads = []
        for r in range(0, total, 30):
            for i in range(r, r + 30):
                if i <= total: threads.append(workers.Thread(self.get_fanart, i))
        [i.start() for i in threads]

        timeout = 60
        progress = control.progressDialog
        progress.create(control.addonInfo('name'), '')
        progress.update(0, line1="%s episodes found." % total, line2="Loading recent information.")

        for i in range(timeout * 10):
            if xbmc.abortRequested is True: return sys.exit()

            progress.update(int((100 / float(len(threads))) * len([x for x in threads if x.is_alive() is False])),
                            line3="%s animes remaining." % len([x for x in threads if x.is_alive() is True]))
            if progress.iscanceled(): break

            is_alive = [x.is_alive() for x in threads]
            if all(x is False for x in is_alive): break
            xbmc.sleep(100)
Exemplo n.º 38
0
    def addItem(self, title, year, imdb, tvdb, season, episode, tvshowtitle, premiered, meta):
        try:
            if 'super.fav' in control.infoLabel('Container.PluginName'):
                return control.dialog.ok('Exodus', control.lang(30518).encode('utf-8'), '', '')

            self.sources = self.getSources(title, year, imdb, tvdb, season, episode, tvshowtitle, premiered)
            if self.sources == []: raise Exception()

            self.progressDialog = control.progressDialog
            self.progressDialog.create(control.addonInfo('name'), '')
            self.progressDialog.update(0, control.lang(30515).encode('utf-8'), str(' '))

            trailerMenu = control.lang(30516).encode('utf-8') if tvshowtitle == None else control.lang(30517).encode('utf-8')

            infoMenu = control.lang(30502).encode('utf-8') if tvshowtitle == None else control.lang(30503).encode('utf-8')

            downloads = True if control.setting('downloads') == 'true' and not (control.setting('movie.download.path') == '' or control.setting('tv.download.path') == '') else False

            meta = json.loads(meta)

            try: del meta['year']
            except: pass

            poster = meta['poster'] if 'poster' in meta else '0'
            banner = meta['banner'] if 'banner' in meta else '0'
            thumb = meta['thumb'] if 'thumb' in meta else poster
            fanart = meta['fanart'] if 'fanart' in meta else '0'

            if poster == '0': poster = control.addonPoster()
            if banner == '0' and poster == '0': banner = control.addonBanner()
            elif banner == '0': banner = poster
            if thumb == '0' and fanart == '0': thumb = control.addonFanart()
            elif thumb == '0': thumb = fanart
            if control.setting('fanart') == 'true' and not fanart == '0': pass
            else: fanart = control.addonFanart()

            systitle = urllib.quote_plus('%s (%s)' % (title, year) if tvshowtitle == None or season == None or episode == None else '%s S%02dE%02d' % (tvshowtitle, int(season), int(episode)))
            sysname = urllib.quote_plus('%s (%s)' % (title, year) if tvshowtitle == None or season == None or episode == None else tvshowtitle)
            sysimage, sysaddon = urllib.quote_plus(poster), sys.argv[0]

            for i in range(len(self.sources)):
                try:
                    #if self.progressDialog.iscanceled(): break

                    self.progressDialog.update(int((100 / float(len(self.sources))) * i))

                    label = self.sources[i]['label']

                    syssource = urllib.quote_plus(json.dumps([self.sources[i]]))

                    url = '%s?action=playItem&source=%s' % (sysaddon, syssource)

                    cm = []
                    cm.append((control.lang(30504).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon))

                    if downloads == True:
                        cm.append((control.lang(30505).encode('utf-8'), 'RunPlugin(%s?action=download&name=%s&image=%s&source=%s)' % (sysaddon, systitle, sysimage, syssource)))

                    cm.append((trailerMenu, 'RunPlugin(%s?action=trailer&name=%s)' % (sysaddon, sysname)))
                    cm.append((infoMenu, 'Action(Info)'))
                    cm.append((control.lang(30506).encode('utf-8'), 'RunPlugin(%s?action=refresh)' % sysaddon))
                    cm.append((control.lang(30507).encode('utf-8'), 'RunPlugin(%s?action=openSettings)' % sysaddon))
                    cm.append((control.lang(30508).encode('utf-8'), 'RunPlugin(%s?action=openPlaylist)' % sysaddon))

                    item = control.item(label=label, iconImage='DefaultVideo.png', thumbnailImage=thumb)
                    try: item.setArt({'poster': poster, 'tvshow.poster': poster, 'season.poster': poster, 'banner': banner, 'tvshow.banner': banner, 'season.banner': banner})
                    except: pass
                    item.setInfo(type='Video', infoLabels = meta)
                    if not fanart == None: item.setProperty('Fanart_Image', fanart)
                    item.setProperty('Video', '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]), 'files')
            control.directory(int(sys.argv[1]), cacheToDisc=True)
            try: self.progressDialog.close()
            except: pass
        except:
            control.infoDialog(control.lang(30501).encode('utf-8'))
            try: self.progressDialog.close()
            except: pass
Exemplo n.º 39
0
    def sourcesDialog(self, items, progress=True):
        try:
            sources = [{'label': '00 | [B]%s[/B]' % control.lang(30509).encode('utf-8').upper()}] + items

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

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

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

            items = [items[select-1]]
            items = [i for i in items+next+prev][:20]

            if progress == True:
                self.progressDialog = control.progressDialog
                self.progressDialog.create(control.addonInfo('name'), '')
                self.progressDialog.update(0)

            block = None

            for i in range(len(items)):
                try:
                    if progress == True:
                        if self.progressDialog.iscanceled(): break
                        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])
                    w.start()

                    m = ''

                    for x in range(3600):
                        if progress == True:
                            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
                        k = control.condVisibility('Window.IsActive(yesnoDialog)')
                        if k: m += '1'; m = m[-1]
                        if (w.is_alive() == False or x > 30) and not k: break
                        time.sleep(0.5)

                    for x in range(30):
                        if m == '': break
                        if progress == True:
                            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']

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

                    control.execute('Dialog.Close(virtualkeyboard)')
                    control.execute('Dialog.Close(yesnoDialog)')
                    return self.url
                except:
                    pass

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

        except:
            try: self.progressDialog.close()
            except: pass
Exemplo n.º 40
0
    def getSources(self, title, year, imdb, tvdb, season, episode, tvshowtitle, premiered, presetDict=[], timeout=30, progress=True):
        sourceDict = []
        for package, name, is_pkg in pkgutil.walk_packages(__path__): sourceDict.append((name, is_pkg))
        sourceDict = [i[0] for i in sourceDict if i[1] == False]

        if not presetDict == []: sourceDict = [i for i in presetDict if i in sourceDict]

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

        if content == 'movie':
            sourceDict = [i for i in sourceDict if i.endswith(('_mv', '_mv_tv'))]
        else:
            sourceDict = [i for i in sourceDict if i.endswith(('_tv', '_mv_tv'))]

        try: sourceDict = [(i, control.setting('provider.' + re.sub('_mv_tv$|_mv$|_tv$', '', i))) for i in sourceDict]
        except: sourceDict = [(i, 'true') for i in sourceDict]

        sourceDict = [i[0] for i in sourceDict if not i[1] == 'false']

        threads = []

        control.makeFile(control.dataPath)
        self.sourceFile = control.providercacheFile


        if content == 'movie':
            title = cleantitle.normalize(title)
            for source in sourceDict: threads.append(workers.Thread(self.getMovieSource, title, year, imdb, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source()))
        else:
            tvshowtitle = cleantitle.normalize(tvshowtitle)
            for source in sourceDict: threads.append(workers.Thread(self.getEpisodeSource, title, year, imdb, tvdb, season, episode, tvshowtitle, premiered, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source()))


        try: timeout = int(control.setting('scrapers.timeout.1'))
        except: pass

        [i.start() for i in threads]

        control.idle()

        sourceLabel = [re.sub('_mv_tv$|_mv$|_tv$', '', i) for i in sourceDict]
        sourceLabel = [re.sub('v\d+$', '', i).upper() for i in sourceLabel]

        if progress == True:
            self.progressDialog = control.progressDialog
            self.progressDialog.create(control.addonInfo('name'), '')
            self.progressDialog.update(0)

        string1 = control.lang(30512).encode('utf-8')
        string2 = control.lang(30513).encode('utf-8')
        string3 = control.lang(30514).encode('utf-8')

        for i in range(0, timeout * 2):
            try:
                if xbmc.abortRequested == True: return sys.exit()

                try: info = [sourceLabel[int(re.sub('[^0-9]', '', str(x.getName()))) - 1] for x in threads if x.is_alive() == True]
                except: info = []

                if len(info) > 5: info = len(info)

                if progress == True:
                    self.progressDialog.update(int((100 / float(len(threads))) * len([x for x in threads if x.is_alive() == False])), str('%s: %s %s' % (string1, int(i * 0.5), string2)), str('%s: %s' % (string3, str(info).translate(None, "[]'"))))
                    if self.progressDialog.iscanceled(): break

                is_alive = [x.is_alive() for x in threads]
                if all(x == False for x in is_alive): break
                time.sleep(0.5)
            except:
                pass

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

        self.sourcesFilter()

        return self.sources
Exemplo n.º 41
0
args = urlparse.parse_qs(sys.argv[2][1:])
mode = args.get('mode', None)


if mode is None:
    addon.add_item({'mode': 'live_sport'}, {'title':'Live Sport'}, img=icon_path('live_sport.jpg'), fanart=fanart,is_folder=True)
    addon.add_item({'mode': 'live_tv'}, {'title':'Live TV'}, img=icon_path('live_tv.jpg'), fanart=fanart,is_folder=True)
    addon.add_item({'mode': 'p2p_corner'}, {'title':'P2P Corner'}, img=icon_path('p2p_corner.jpg'), fanart=fanart,is_folder=True)
    addon.add_item({'mode': 'on_demand_sport_categories'}, {'title':'Sport On Demand'}, img=icon_path('sport_on_demand.jpg'), fanart=fanart,is_folder=True)
    #addon.add_item({'mode': 'blogs'}, {'title':'Blogs'}, img=icon_path('blogs.jpg'), fanart=fanart,is_folder=True)
    addon.add_item({'mode': 'tools'}, {'title':'Tools'}, img=icon_path('tools.jpg'), fanart=fanart,is_folder=True)
    addon.add_item({'mode': 'my_castaway'}, {'title':'My Castaway'}, img=icon_path('my_castaway.jpg'), fanart=fanart,is_folder=True)

    addon.end_of_directory()
    from resources.lib.modules import cache, control, changelog
    cache.get(changelog.get, 600000000, control.addonInfo('version'), table='changelog')
    

elif mode[0]=='my_castaway':
    #addon.add_item({'mode': 'favourites'}, {'title':'Favourites'}, img=icon_path('favourites.jpg'), fanart=fanart,is_folder=True)
    #addon.add_item({'mode': 'my_lists'}, {'title':'My Lists'}, img=icon_path('my_lists.jpg'), fanart=fanart,is_folder=True)
    addon.add_item({'mode': 'keyboard_open'}, {'title':'Open URL'}, img=icon_path('my_castaway.jpg'), fanart=fanart,is_folder=True)
    addon.add_item({'mode': 'x'}, {'title':'[COLOR yellow]Follow me @natko1412[/COLOR]'}, img=icon_path('twitter.png'), fanart=fanart)
    addon.end_of_directory()


elif mode[0]=='keyboard_open':
    keyboard = xbmc.Keyboard('', 'Enter URL:', False)
    keyboard.doModal()
    if keyboard.isConfirmed():
        query = keyboard.getText()
Exemplo n.º 42
0
    def getSources(self,
                   title,
                   year,
                   imdb,
                   tvdb,
                   season,
                   episode,
                   tvshowtitle,
                   premiered,
                   presetDict=[],
                   timeout=30,
                   progress=True):
        sourceDict = []
        for package, name, is_pkg in pkgutil.walk_packages(__path__):
            sourceDict.append((name, is_pkg))
        sourceDict = [i[0] for i in sourceDict if i[1] == False]

        if not presetDict == []:
            sourceDict = [i for i in presetDict if i in sourceDict]

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

        if content == 'movie':
            sourceDict = [
                i for i in sourceDict if i.endswith(('_mv', '_mv_tv'))
            ]
        else:
            sourceDict = [
                i for i in sourceDict if i.endswith(('_tv', '_mv_tv'))
            ]

        try:
            sourceDict = [(i,
                           control.setting('provider.' +
                                           re.sub('_mv_tv$|_mv$|_tv$', '', i)))
                          for i in sourceDict]
        except:
            sourceDict = [(i, 'true') for i in sourceDict]

        sourceDict = [i[0] for i in sourceDict if not i[1] == 'false']

        threads = []

        control.makeFile(control.dataPath)
        self.sourceFile = control.providercacheFile

        if content == 'movie':
            title = cleantitle.normalize(title)
            for source in sourceDict:
                threads.append(
                    workers.Thread(
                        self.getMovieSource, title, year, imdb,
                        re.sub('_mv_tv$|_mv$|_tv$', '', source),
                        __import__(source, globals(), locals(), [],
                                   -1).source()))
        else:
            tvshowtitle = cleantitle.normalize(tvshowtitle)
            for source in sourceDict:
                threads.append(
                    workers.Thread(
                        self.getEpisodeSource, title, year, imdb, tvdb, season,
                        episode, tvshowtitle, premiered,
                        re.sub('_mv_tv$|_mv$|_tv$', '', source),
                        __import__(source, globals(), locals(), [],
                                   -1).source()))

        try:
            timeout = int(control.setting('scrapers.timeout.1'))
        except:
            pass

        [i.start() for i in threads]

        control.idle()

        sourceLabel = [re.sub('_mv_tv$|_mv$|_tv$', '', i) for i in sourceDict]
        sourceLabel = [re.sub('v\d+$', '', i).upper() for i in sourceLabel]

        if progress == True:
            self.progressDialog = control.progressDialog
            self.progressDialog.create(control.addonInfo('name'), '')
            self.progressDialog.update(0)

        string1 = control.lang(30512).encode('utf-8')
        string2 = control.lang(30513).encode('utf-8')
        string3 = control.lang(30514).encode('utf-8')

        for i in range(0, timeout * 2):
            try:
                if xbmc.abortRequested == True: return sys.exit()

                try:
                    info = [
                        sourceLabel[int(re.sub('[^0-9]', '', str(x.getName())))
                                    - 1] for x in threads
                        if x.is_alive() == True
                    ]
                except:
                    info = []

                if len(info) > 5: info = len(info)

                if progress == True:
                    self.progressDialog.update(
                        int((100 / float(len(threads))) *
                            len([x
                                 for x in threads if x.is_alive() == False])),
                        str('%s: %s %s' % (string1, int(i * 0.5), string2)),
                        str('%s: %s' %
                            (string3, str(info).translate(None, "[]'"))))
                    if self.progressDialog.iscanceled(): break

                is_alive = [x.is_alive() for x in threads]
                if all(x == False for x in is_alive): break
                time.sleep(0.5)
            except:
                pass

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

        self.sourcesFilter()

        return self.sources
Exemplo n.º 43
0
    def addItem(self, title, year, imdb, tvdb, season, episode, tvshowtitle,
                premiered, meta):
        try:
            if 'super.fav' in control.infoLabel('Container.PluginName'):
                return control.dialog.ok('Exodus',
                                         control.lang(30518).encode('utf-8'),
                                         '', '')

            self.sources = self.getSources(title, year, imdb, tvdb, season,
                                           episode, tvshowtitle, premiered)
            if self.sources == []: raise Exception()

            self.progressDialog = control.progressDialog
            self.progressDialog.create(control.addonInfo('name'), '')
            self.progressDialog.update(0,
                                       control.lang(30515).encode('utf-8'),
                                       str(' '))

            content = 'movies' if tvshowtitle == None else 'episodes'

            trailerMenu = control.lang(30516).encode(
                'utf-8') if tvshowtitle == None else control.lang(
                    30517).encode('utf-8')

            infoMenu = control.lang(30502).encode(
                'utf-8') if tvshowtitle == None else control.lang(
                    30503).encode('utf-8')

            downloads = True if control.setting(
                'downloads') == 'true' and not (
                    control.setting('movie.download.path') == ''
                    or control.setting('tv.download.path') == '') else False

            meta = json.loads(meta)

            try:
                del meta['duration']
            except:
                pass

            poster = meta['poster'] if 'poster' in meta else '0'
            banner = meta['banner'] if 'banner' in meta else '0'
            thumb = meta['thumb'] if 'thumb' in meta else poster
            fanart = meta['fanart'] if 'fanart' in meta else '0'

            if poster == '0': poster = control.addonPoster()
            if banner == '0' and poster == '0': banner = control.addonBanner()
            elif banner == '0': banner = poster
            if thumb == '0' and fanart == '0': thumb = control.addonFanart()
            elif thumb == '0': thumb = fanart
            if control.setting('fanart') == 'true' and not fanart == '0': pass
            else: fanart = control.addonFanart()

            systitle = urllib.quote_plus(
                '%s (%s)' % (title, year) if tvshowtitle == None or season ==
                None or episode == None else '%s S%02dE%02d' %
                (tvshowtitle, int(season), int(episode)))
            sysname = urllib.quote_plus(
                '%s (%s)' % (title, year) if tvshowtitle == None or season ==
                None or episode == None else tvshowtitle)
            sysimage, sysaddon = urllib.quote_plus(poster), sys.argv[0]

            for i in range(len(self.sources)):
                try:
                    #if self.progressDialog.iscanceled(): break

                    self.progressDialog.update(
                        int((100 / float(len(self.sources))) * i))

                    label = self.sources[i]['label']

                    syssource = urllib.quote_plus(json.dumps([self.sources[i]
                                                              ]))

                    url = '%s?action=playItem&source=%s' % (sysaddon,
                                                            syssource)

                    cm = []
                    cm.append((control.lang(30504).encode('utf-8'),
                               'RunPlugin(%s?action=queueItem)' % sysaddon))

                    if downloads == True:
                        cm.append((control.lang(30505).encode(
                            'utf-8'
                        ), 'RunPlugin(%s?action=download&name=%s&image=%s&source=%s)'
                                   %
                                   (sysaddon, systitle, sysimage, syssource)))

                    cm.append(
                        (trailerMenu, 'RunPlugin(%s?action=trailer&name=%s)' %
                         (sysaddon, sysname)))
                    cm.append((infoMenu, 'Action(Info)'))
                    cm.append((control.lang(30506).encode('utf-8'),
                               'RunPlugin(%s?action=refresh)' % sysaddon))
                    cm.append((control.lang(30507).encode('utf-8'),
                               'RunPlugin(%s?action=openSettings)' % sysaddon))
                    cm.append((control.lang(30508).encode('utf-8'),
                               'RunPlugin(%s?action=openPlaylist)' % sysaddon))

                    item = control.item(label=label,
                                        iconImage='DefaultVideo.png',
                                        thumbnailImage=thumb)
                    try:
                        item.setArt({
                            'poster': poster,
                            'tvshow.poster': poster,
                            'season.poster': poster,
                            'banner': banner,
                            'tvshow.banner': banner,
                            'season.banner': banner
                        })
                    except:
                        pass
                    item.setInfo(type='Video', infoLabels=meta)
                    if not fanart == None:
                        item.setProperty('Fanart_Image', fanart)
                    item.setProperty('Video', '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]), content)
            control.directory(int(sys.argv[1]), cacheToDisc=True)
            try:
                self.progressDialog.close()
            except:
                pass
        except:
            control.infoDialog(control.lang(30501).encode('utf-8'))
            try:
                self.progressDialog.close()
            except:
                pass
Exemplo n.º 44
0
# -*- coding: UTF-8 -*-

import os, time, cProfile, StringIO, pstats, json, xbmc

from xbmc import LOGDEBUG, LOGERROR, LOGFATAL, LOGINFO, LOGNONE, LOGNOTICE, LOGSEVERE, LOGWARNING  # @UnusedImport
from datetime import date, datetime, timedelta
from resources.lib.modules import control

name = control.addonInfo('name')
DEBUGPREFIX = '[COLOR red][ STREAM TVSUPERTUGA DEBUG ][/COLOR]'  # Using color coding, for color formatted log viewers like Assassin's Tools
LOGPATH = xbmc.translatePath('special://logpath/')


def log(msg, level=LOGNOTICE):
    debug_enabled = control.setting('addon_debug')
    debug_log = control.setting('debug.location')

    print DEBUGPREFIX + ' Debug Enabled?: ' + str(debug_enabled)
    print DEBUGPREFIX + ' Debug Log?: ' + str(debug_log)

    if not control.setting('addon_debug') == 'true':
        return

    try:
        if isinstance(msg, unicode):
            msg = '%s (ENCODED)' % (msg.encode('utf-8'))

        if not control.setting('debug.location') == '0':
            log_file = os.path.join(LOGPATH, 'Stream TVsupertuga.log')
            if not os.path.exists(log_file):
                f = open(log_file, 'w')
Exemplo n.º 45
0
                   is_folder=True)
    #addon.add_item({'mode': 'blogs'}, {'title':'Blogs'}, img=icon_path('blogs.jpg'), fanart=fanart,is_folder=True)
    addon.add_item({'mode': 'tools'}, {'title': 'Tools'},
                   img=icon_path('tools.jpg'),
                   fanart=fanart,
                   is_folder=True)
    addon.add_item({'mode': 'my_castaway'}, {'title': 'My Castaway'},
                   img=icon_path('my_castaway.jpg'),
                   fanart=fanart,
                   is_folder=True)

    addon.end_of_directory()
    from resources.lib.modules import cache, control, changelog
    cache.get(changelog.get,
              600000000,
              control.addonInfo('version'),
              table='changelog')

elif mode[0] == 'my_castaway':
    #addon.add_item({'mode': 'favourites'}, {'title':'Favourites'}, img=icon_path('favourites.jpg'), fanart=fanart,is_folder=True)
    #addon.add_item({'mode': 'my_lists'}, {'title':'My Lists'}, img=icon_path('my_lists.jpg'), fanart=fanart,is_folder=True)
    addon.add_item({'mode': 'keyboard_open'}, {'title': 'Open URL'},
                   img=icon_path('my_castaway.jpg'),
                   fanart=fanart,
                   is_folder=True)
    addon.add_item({'mode': 'x'},
                   {'title': '[COLOR yellow]Follow me @natko1412[/COLOR]'},
                   img=icon_path('twitter.png'),
                   fanart=fanart)
    addon.end_of_directory()
Exemplo n.º 46
0
def addDirectoryItem(name, url, action, image, image2, fanart, audio, 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]

    u = '%s?name=%s&url=%s&audio=%s&image=%s&fanart=%s&playable=%s&tvshow=%s&content=%s&action=%s' % (sysaddon, urllib.quote_plus(name), urllib.quote_plus(url), urllib.quote_plus(audio), urllib.quote_plus(image), urllib.quote_plus(fanart), urllib.quote_plus(playable), str(tvshow), str(content), str(action))

    cm = []

    if content in ['movies', 'tvshows']:
        data.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, urllib.quote_plus(name))})
        cm.append((control.lang(30707).encode('utf-8'), 'RunPlugin(%s?action=trailer&name=%s)' % (sysaddon, urllib.quote_plus(name))))

    if not 'plot' in data:
        data.update({'plot': control.lang(30706).encode('utf-8')})


    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)
Exemplo n.º 47
0
    def getSources(self, title, year, imdb, tvdb, season, episode, tvshowtitle, premiered, quality='HD', timeout=45):
        u = None

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

        sourceDict = self.sourceDict

        content = 'movie' if tvshowtitle == None else 'episode'
        if content == 'movie':
            sourceDict = [(i[0], i[1], getattr(i[1], 'movie', None)) for i in sourceDict]
        else:
            sourceDict = [(i[0], i[1], getattr(i[1], 'tvshow', None)) for i in sourceDict]
        sourceDict = [(i[0], i[1]) for i in sourceDict if not i[2] == None]

        sourceDict = [(i[0], i[1], i[1].priority) for i in sourceDict]

        if quality == 'SD':
            sourceDict = [i for i in sourceDict if i[2] == 0]

        threads = []

        if content == 'movie':
            title = self.getTitle(title)
            aliases = self.getAliasTitles(imdb, '', content)
            for i in sourceDict: threads.append(workers.Thread(self.getMovieSource, title, title, aliases, year, imdb, i[0], i[1]))
        else:
            tvshowtitle = self.getTitle(tvshowtitle)
            aliases = self.getAliasTitles(imdb, '', content)
            for i in sourceDict: threads.append(workers.Thread(self.getEpisodeSource, title, year, imdb, tvdb, season, episode, tvshowtitle, tvshowtitle, aliases, premiered, i[0], i[1]))


        s = [i[0] + (i[1],) for i in zip(sourceDict, threads)]
        s = [(i[3].getName(), i[0], i[2]) for i in s]

        mainsourceDict = [i[0] for i in s if i[2] == 0]
        sourcelabelDict = dict([(i[0], i[1].upper()) for i in s])

        [i.start() for i in threads]

        string1 = control.lang(32404).encode('utf-8')
        string2 = control.lang(32405).encode('utf-8')
        string3 = control.lang(32406).encode('utf-8')
        string6 = '[B][COLOR cyan]Cypher now decoding streams[/COLOR][/B]'

        for i in range(0, (timeout * 2) + 60):
            try:
                if xbmc.abortRequested == True: return sys.exit()

                try: info = [sourcelabelDict[x.getName()] for x in threads if x.is_alive() == True]
                except: info = []

                timerange = int(i * 0.5)

                try:
                    if progressDialog.iscanceled(): break
                except:
                    pass
                try:
                    string4 = string1 % str(timerange)
                    if len(info) > 5: string5 = string3 % str(len(info))
                    else: string5 = string3 % str(info).translate(None, "[]'")
                    progressDialog.update(int((100 / float(len(threads))) * len([x for x in threads if x.is_alive() == False])), str(string6), str(string4), str(string5))
                except:
                    pass

                is_alive = [x.is_alive() for x in threads]
                if all(x == False for x in is_alive): break

                if timerange >= timeout:
                    is_alive = [x for x in threads if x.is_alive() == True and x.getName() in mainsourceDict]
                    if not is_alive: break

                time.sleep(0.5)
            except:
                pass

        progressDialog.update(100, control.lang(30726).encode('utf-8'), control.lang(30731).encode('utf-8'))

        items = self.sourcesFilter()

        filter = [i for i in items if i['source'].lower() in self.hostcapDict and i['debrid'] == '']
        items = [i for i in items if not i in filter]

        filter = [i for i in items if i['source'].lower() in self.hostblockDict and i['debrid'] == '']
        items = [i for i in items if not i in filter]

        items = [i for i in items if ('autoplay' in i and i['autoplay'] == True) or not 'autoplay' in i]

        for i in range(len(items)):
            try:
                if progressDialog.iscanceled(): break
                if xbmc.abortRequested == True: return sys.exit()
                url = self.sourcesResolve(items[i])
                if u == None: u = url
                if not url == None: break
            except:
                pass

        try: progressDialog.close()
        except: pass

        return u
Exemplo n.º 48
0
    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 re, os, sys, urllib, urllib2, urlparse, time, threading

from resources.lib.modules import control
from resources.lib.modules import cache
import pyxbmct.addonwindow as pyxbmct

downloadPath = control.setting('downloadPath')
property = control.addonInfo('id') + '.downloader'


def downloader():

    thumb = control.addonThumb()
    fanart = control.addonFanart()

    status = control.window.getProperty(property + '.status')

    if not downloadPath == '':
        item = control.item('[COLOR FF00b8ff]Downloads[/COLOR]',
                            iconImage=thumb,
                            thumbnailImage=thumb)
        item.addContextMenuItems([], replaceItems=True)
        item.setProperty('fanart_image', fanart)
Exemplo n.º 49
0
    def keepPlaybackAlive(self):
        pname = '%s.player.overlay' % control.addonInfo('id')
        control.window.clearProperty(pname)


        if self.content == 'movie':
            overlay = playcount.getMovieOverlay(playcount.getMovieIndicators(), self.imdb)

        elif self.content == 'episode':
            overlay = playcount.getEpisodeOverlay(playcount.getTVShowIndicators(), self.imdb, self.tvdb, self.season, self.episode)

        else:
            overlay = '6'


        for i in range(0, 240):
            if self.isPlayingVideo(): break
            xbmc.sleep(1000)


        if overlay == '7':

            while self.isPlayingVideo():
                try:
                    self.totalTime = self.getTotalTime()
                    self.currentTime = self.getTime()
                except:
                    pass
                xbmc.sleep(2000)


        elif self.content == 'movie':

            while self.isPlayingVideo():
                try:
                    self.totalTime = self.getTotalTime()
                    self.currentTime = self.getTime()

                    watcher = (self.currentTime / self.totalTime >= .9)
                    property = control.window.getProperty(pname)

                    if watcher == True and not property == '7':
                        control.window.setProperty(pname, '7')
                        playcount.markMovieDuringPlayback(self.imdb, '7')

                    elif watcher == False and not property == '6':
                        control.window.setProperty(pname, '6')
                        playcount.markMovieDuringPlayback(self.imdb, '6')
                except:
                    pass
                xbmc.sleep(2000)


        elif self.content == 'episode':

            while self.isPlayingVideo():
                try:
                    self.totalTime = self.getTotalTime()
                    self.currentTime = self.getTime()

                    watcher = (self.currentTime / self.totalTime >= .9)
                    property = control.window.getProperty(pname)

                    if watcher == True and not property == '7':
                        control.window.setProperty(pname, '7')
                        playcount.markEpisodeDuringPlayback(self.imdb, self.tvdb, self.season, self.episode, '7')

                    elif watcher == False and not property == '6':
                        control.window.setProperty(pname, '6')
                        playcount.markEpisodeDuringPlayback(self.imdb, self.tvdb, self.season, self.episode, '6')
                except:
                    pass
                xbmc.sleep(2000)


        control.window.clearProperty(pname)
Exemplo n.º 50
0
def manager(name,
            imdb=None,
            tvdb=None,
            season=None,
            episode=None,
            refresh=True):
    lists = []
    try:
        if season: season = int(season)
        if episode: episode = int(episode)
        if tvdb: media_type = 'Show'
        else: media_type = 'Movie'

        items = [(control.lang(33651), 'watch')]
        items += [(control.lang(33652), 'unwatch')]
        items += [(control.lang(33653), 'rate')]
        items += [(control.lang(33654), 'unrate')]
        items += [(control.lang(40075) % media_type, 'hideItem')]
        if control.setting('trakt.scrobble') == 'true' and control.setting(
                'resume.source') == '1':
            items += [(control.lang(40076), 'scrobbleReset')]
        items += [(control.lang(33575), '/sync/collection')]
        items += [(control.lang(33576), '/sync/collection/remove')]
        if season or episode:
            items += [(control.lang(33573), '/sync/watchlist')]
            items += [(control.lang(33574), '/sync/watchlist/remove')]
        items += [(control.lang(33577), '/sync/watchlist')]
        items += [(control.lang(33578), '/sync/watchlist/remove')]
        items += [(control.lang(33579), '/users/me/lists/%s/items')]

        result = getTraktAsJson('/users/me/lists')
        lists = [(i['name'], i['ids']['slug']) for i in result]
        lists = [lists[i // 2] for i in range(len(lists) * 2)]

        for i in range(0, len(lists), 2):
            # lists[i] = ((control.lang(33580) % lists[i][0]).encode('utf-8'), '/users/me/lists/%s/items' % lists[i][1])
            lists[i] = ((control.lang(33580) % lists[i][0]),
                        '/users/me/lists/%s/items' % lists[i][1])
        for i in range(1, len(lists), 2):
            # lists[i] = ((control.lang(33581) % lists[i][0]).encode('utf-8'), '/users/me/lists/%s/items/remove' % lists[i][1])
            lists[i] = ((control.lang(33581) % lists[i][0]),
                        '/users/me/lists/%s/items/remove' % lists[i][1])
        items += lists

        control.hide()
        select = control.selectDialog([i[0] for i in items],
                                      heading=control.addonInfo('name') +
                                      ' - ' + control.lang(32515))

        if select == -1: return
        if select >= 0:
            if items[select][0] == control.lang(33651):
                control.busy()
                watch(name,
                      imdb=imdb,
                      tvdb=tvdb,
                      season=season,
                      episode=episode,
                      refresh=refresh)
                control.hide()
            elif items[select][0] == control.lang(33652):
                control.busy()
                unwatch(name,
                        imdb=imdb,
                        tvdb=tvdb,
                        season=season,
                        episode=episode,
                        refresh=refresh)
                control.hide()
            elif items[select][0] == control.lang(33653):
                control.busy()
                rate(imdb=imdb, tvdb=tvdb, season=season, episode=episode)
                control.hide()
            elif items[select][0] == control.lang(33654):
                control.busy()
                unrate(imdb=imdb, tvdb=tvdb, season=season, episode=episode)
                control.hide()
            elif items[select][0] == control.lang(40075) % media_type:
                control.busy()
                hideItem(name=name,
                         imdb=imdb,
                         tvdb=tvdb,
                         season=season,
                         episode=episode)
                control.hide()
            elif items[select][0] == control.lang(40076):
                control.busy()
                scrobbleReset(imdb=imdb,
                              tvdb=tvdb,
                              season=season,
                              episode=episode)
                control.hide()
            else:
                if not tvdb:
                    post = {"movies": [{"ids": {"imdb": imdb}}]}
                else:
                    if episode:
                        if items[select][0] == control.lang(33573) or items[
                                select][0] == control.lang(33574):
                            post = {"shows": [{"ids": {"tvdb": tvdb}}]}
                        else:
                            post = {
                                "shows": [{
                                    "ids": {
                                        "tvdb": tvdb
                                    },
                                    "seasons": [{
                                        "number":
                                        season,
                                        "episodes": [{
                                            "number": episode
                                        }]
                                    }]
                                }]
                            }
                            name = name + ' - ' + '%sx%02d' % (season, episode)
                    elif season:
                        if items[select][0] == control.lang(33573) or items[
                                select][0] == control.lang(33574):
                            post = {"shows": [{"ids": {"tvdb": tvdb}}]}
                        else:
                            post = {
                                "shows": [{
                                    "ids": {
                                        "tvdb": tvdb
                                    },
                                    "seasons": [{
                                        "number": season
                                    }]
                                }]
                            }
                            name = name + ' - ' + 'Season %s' % season
                    else:
                        post = {"shows": [{"ids": {"tvdb": tvdb}}]}

                if items[select][0] == control.lang(33579):
                    slug = listAdd(successNotification=True)
                    if slug:
                        getTrakt(items[select][1] % slug, post=post)[0]
                else:
                    getTrakt(items[select][1], post=post)[0]

                control.hide()
                message = 33583 if 'remove' in items[select][1] else 33582
                if refresh:
                    control.refresh()
                control.trigger_widget_refresh()
                if control.setting('trakt.general.notifications') == 'true':
                    control.notification(title=name, message=message)
    except:
        log_utils.error()
        control.hide()
Exemplo n.º 51
0
    def keepPlaybackAlive(self):
        pname = '%s.player.overlay' % control.addonInfo('id')
        control.window.clearProperty(pname)

        if self.content == 'movie':
            overlay = playcount.getMovieOverlay(playcount.getMovieIndicators(),
                                                self.imdb)

        elif self.content == 'episode':
            overlay = playcount.getEpisodeOverlay(
                playcount.getTVShowIndicators(), self.imdb, self.tvdb,
                self.season, self.episode)

        else:
            overlay = '6'

        for i in range(0, 240):
            if self.isPlayingVideo(): break
            xbmc.sleep(1000)

        if overlay == '7':

            while self.isPlayingVideo():
                try:
                    self.totalTime = self.getTotalTime()
                    self.currentTime = self.getTime()
                except:
                    pass
                xbmc.sleep(2000)

        elif self.content == 'movie':

            while self.isPlayingVideo():
                try:
                    self.totalTime = self.getTotalTime()
                    self.currentTime = self.getTime()

                    watcher = (self.currentTime / self.totalTime >= .9)
                    property = control.window.getProperty(pname)

                    if watcher == True and not property == '7':
                        control.window.setProperty(pname, '7')
                        playcount.markMovieDuringPlayback(self.imdb, '7')

                    elif watcher == False and not property == '6':
                        control.window.setProperty(pname, '6')
                        playcount.markMovieDuringPlayback(self.imdb, '6')
                except:
                    pass
                xbmc.sleep(2000)

        elif self.content == 'episode':

            while self.isPlayingVideo():
                try:
                    self.totalTime = self.getTotalTime()
                    self.currentTime = self.getTime()

                    watcher = (self.currentTime / self.totalTime >= .9)
                    property = control.window.getProperty(pname)

                    if watcher == True and not property == '7':
                        control.window.setProperty(pname, '7')
                        playcount.markEpisodeDuringPlayback(
                            self.imdb, self.tvdb, self.season, self.episode,
                            '7')

                    elif watcher == False and not property == '6':
                        control.window.setProperty(pname, '6')
                        playcount.markEpisodeDuringPlayback(
                            self.imdb, self.tvdb, self.season, self.episode,
                            '6')
                except:
                    pass
                xbmc.sleep(2000)

        control.window.clearProperty(pname)
Exemplo n.º 52
0
    def addDirectory(self, items, queue=False):
        if items == None or len(items) == 0: return

        sysaddon = sys.argv[0]
        addonPoster = addonBanner = control.addonInfo('icon')
        addonFanart = control.addonInfo('fanart')

        playlist = control.playlist
        if not queue == False: playlist.clear()

        try:
            devmode = True if 'testings.xml' in control.listDir(
                control.dataPath)[1] else False
        except:
            devmode = False

        mode = [i['content'] for i in items if 'content' in i]
        if 'movies' in mode: mode = 'movies'
        elif 'tvshows' in mode: mode = 'tvshows'
        elif 'seasons' in mode: mode = 'seasons'
        elif 'episodes' in mode: mode = 'episodes'
        elif 'videos' in mode: mode = 'videos'
        else: mode = 'addons'

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

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

                if i['action'] == 'plugin' and 'url' in i: url = i['url']

                try:
                    devurl = dict(
                        urlparse.parse_qsl(
                            urlparse.urlparse(url).query))['action']
                except:
                    devurl = None
                if devurl == 'developer' and not devmode == True:
                    raise Exception()

                poster = i['poster'] if 'poster' in i else '0'
                banner = i['banner'] if 'banner' in i else '0'
                fanart = i['fanart'] if 'fanart' in i else '0'
                if poster == '0': poster = addonPoster
                if banner == '0' and poster == '0': banner = addonBanner
                elif banner == '0': banner = poster

                content = i['content'] if 'content' in i else '0'

                folder = i['folder'] if 'folder' in i else True

                meta = dict((k, v) for k, v in i.iteritems() if not v == '0')

                cm = []

                if content in ['movies', 'tvshows']:
                    meta.update({
                        'trailer':
                        '%s?action=trailer&name=%s' %
                        (sysaddon, urllib.quote_plus(name))
                    })
                    cm.append((control.lang(30707).encode('utf-8'),
                               'RunPlugin(%s?action=trailer&name=%s)' %
                               (sysaddon, urllib.quote_plus(name))))

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

                if (folder == False and not '|regex=' in str(i.get('url'))
                    ) or (folder == True
                          and content in ['tvshows', 'seasons']):
                    cm.append((control.lang(30723).encode('utf-8'),
                               'RunPlugin(%s?action=queueItem)' % sysaddon))

                if content == 'movies':
                    try:
                        dfile = '%s (%s)' % (i['title'], i['year'])
                    except:
                        dfile = name
                    try:
                        cm.append((control.lang(30722).encode(
                            'utf-8'
                        ), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)'
                                   % (sysaddon, urllib.quote_plus(dfile),
                                      urllib.quote_plus(i['url']),
                                      urllib.quote_plus(poster))))
                    except:
                        pass
                elif content == 'episodes':
                    try:
                        dfile = '%s S%02dE%02d' % (i['tvshowtitle'],
                                                   int(i['season']),
                                                   int(i['episode']))
                    except:
                        dfile = name
                    try:
                        cm.append((control.lang(30722).encode(
                            'utf-8'
                        ), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)'
                                   % (sysaddon, urllib.quote_plus(dfile),
                                      urllib.quote_plus(i['url']),
                                      urllib.quote_plus(poster))))
                    except:
                        pass
                elif content == 'songs':
                    try:
                        cm.append((control.lang(30722).encode(
                            'utf-8'
                        ), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)'
                                   % (sysaddon, urllib.quote_plus(name),
                                      urllib.quote_plus(i['url']),
                                      urllib.quote_plus(poster))))
                    except:
                        pass

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

                if devmode == True:
                    try:
                        cm.append(('Open in browser',
                                   'RunPlugin(%s?action=browser&url=%s)' %
                                   (sysaddon, urllib.quote_plus(i['url']))))
                    except:
                        pass

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

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

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

                if queue == False:
                    item.setInfo(type='Video', infoLabels=meta)
                    item.addContextMenuItems(cm)
                    control.addItem(handle=int(sys.argv[1]),
                                    url=url,
                                    listitem=item,
                                    isFolder=folder)
                else:
                    item.setInfo(type='Video', infoLabels=meta)
                    playlist.add(url=url, listitem=item)
            except:
                pass

        if not queue == False:
            return control.player.play(playlist)

        try:
            i = items[0]
            if i['next'] == '': raise Exception()
            url = '%s?action=%s&url=%s' % (sysaddon, i['nextaction'],
                                           urllib.quote_plus(i['next']))
            item = control.item(label=control.lang(30500).encode('utf-8'))
            item.setArt({
                'addonPoster': addonPoster,
                'thumb': addonPoster,
                'poster': addonPoster,
                'tvshow.poster': addonPoster,
                'season.poster': addonPoster,
                'banner': addonPoster,
                'tvshow.banner': addonPoster,
                'season.banner': addonPoster
            })
            item.setProperty('addonFanart_Image', addonFanart)
            control.addItem(handle=int(sys.argv[1]),
                            url=url,
                            listitem=item,
                            isFolder=True)
        except:
            pass

        if not mode == None: control.content(int(sys.argv[1]), mode)
        control.directory(int(sys.argv[1]), cacheToDisc=True)
        if mode in ['movies', 'tvshows', 'seasons', 'episodes']:
            views.setView(mode, {'skin.estuary': 55})
Exemplo n.º 53
0
    def getURISource(self, url):
        u = None

        sourceDict = self.sourceDict

        domain = re.sub('^www\.|^www\d+\.', '',
                        urlparse.urlparse(url.strip().lower()).netloc)

        domains = [(i[0], i[1].domains) for i in sourceDict]
        domains = [i[0] for i in domains if any(x in domain for x in i[1])]

        if not domains: return False

        sourceDict = [i for i in sourceDict if i[0] == domains[0]][0]
        source = sourceDict[0]
        call = sourceDict[1]

        progressDialog = control.progressDialog
        progressDialog.create(control.addonInfo('name'),
                              control.lang(30726).encode('utf-8'))
        progressDialog.update(0)

        progressDialog.update(0,
                              control.lang(30726).encode('utf-8'),
                              control.lang(30731).encode('utf-8'))

        self.sources = call.sources(url, self.hostDict, self.hostprDict)
        for i in self.sources:
            i.update({'provider': source})

        progressDialog.update(50,
                              control.lang(30726).encode('utf-8'),
                              control.lang(30731).encode('utf-8'))

        items = self.sourcesFilter()

        filter = [
            i for i in items
            if i['source'].lower() in self.hostcapDict and i['debrid'] == ''
        ]
        items = [i for i in items if not i in filter]

        filter = [
            i for i in items
            if i['source'].lower() in self.hostblockDict and i['debrid'] == ''
        ]
        items = [i for i in items if not i in filter]

        items = [
            i for i in items if ('autoplay' in i and i['autoplay'] == True)
            or not 'autoplay' in i
        ]

        for i in range(len(items)):
            try:
                if progressDialog.iscanceled(): break
                if xbmc.abortRequested == True: return sys.exit()
                url = self.sourcesResolve(items[i])
                if u == None: u = url
                if not url == None: break
            except:
                pass

        try:
            progressDialog.close()
        except:
            pass

        return u
Exemplo n.º 54
0
def get():
    import os, xbmcgui
    from resources.lib.modules import control
    changelogfile = os.path.join(control.addonPath, 'changelog.txt')
    r = open(changelogfile)
    text = r.read()
    id = 10147
    control.execute('ActivateWindow(%d)' % id)
    control.sleep(500)
    win = xbmcgui.Window(id)
    retry = 50
    while (retry > 0):
        try:
            control.sleep(10)
            retry -= 1
            win.getControl(1).setLabel('--[ [COLOR darkorange] v%s [/COLOR]ChangeLog ]--' %(control.addonInfo('version')))
            win.getControl(5).setText(text)
            return
        except:
            pass
Exemplo n.º 55
0
    def getSources(self,
                   title,
                   year,
                   imdb,
                   tvdb,
                   season,
                   episode,
                   tvshowtitle,
                   premiered,
                   quality='HD',
                   timeout=20):
        u = None

        self.prepareSources()

        sourceDict = self.sourceDict

        content = 'movie' if tvshowtitle == None else 'episode'
        if content == 'movie':
            sourceDict = [(i[0], i[1], getattr(i[1], 'movie', None))
                          for i in sourceDict]
        else:
            sourceDict = [(i[0], i[1], getattr(i[1], 'tvshow', None))
                          for i in sourceDict]
        sourceDict = [(i[0], i[1]) for i in sourceDict if not i[2] == None]

        sourceDict = [(i[0], i[1], i[1].priority) for i in sourceDict]

        if quality == 'SD':
            sourceDict = [i for i in sourceDict if i[2] == 0]

        threads = []

        if content == 'movie':
            title = self.getTitle(title)
            for i in sourceDict:
                threads.append(
                    workers.Thread(self.getMovieSource, title, title, year,
                                   imdb, i[0], i[1]))
        else:
            tvshowtitle = self.getTitle(tvshowtitle)
            for i in sourceDict:
                threads.append(
                    workers.Thread(self.getEpisodeSource, title, year, imdb,
                                   tvdb, season, episode, tvshowtitle,
                                   tvshowtitle, premiered, i[0], i[1]))

        s = [i[0] + (i[1], ) for i in zip(sourceDict, threads)]
        s = [(i[3].getName(), i[0], i[2]) for i in s]

        mainsourceDict = [i[0] for i in s if i[2] == 0]

        [i.start() for i in threads]

        progressDialog = control.progressDialog
        progressDialog.create(control.addonInfo('name'),
                              control.lang(30726).encode('utf-8'))
        progressDialog.update(0)

        progressDialog.update(0,
                              control.lang(30726).encode('utf-8'),
                              control.lang(30731).encode('utf-8'))

        for i in range(0, (timeout * 2) + 60):
            try:
                if xbmc.abortRequested == True: return sys.exit()

                timerange = int(i * 0.5)

                try:
                    if progressDialog.iscanceled(): break
                except:
                    pass

                is_alive = [x.is_alive() for x in threads]
                if all(x == False for x in is_alive): break

                if timerange >= timeout:
                    is_alive = [
                        x for x in threads if x.is_alive() == True
                        and x.getName() in mainsourceDict
                    ]
                    if not is_alive: break

                time.sleep(0.5)
            except:
                pass

        progressDialog.update(50,
                              control.lang(30726).encode('utf-8'),
                              control.lang(30731).encode('utf-8'))

        items = self.sourcesFilter()

        filter = [
            i for i in items
            if i['source'].lower() in self.hostcapDict and i['debrid'] == ''
        ]
        items = [i for i in items if not i in filter]

        filter = [
            i for i in items
            if i['source'].lower() in self.hostblockDict and i['debrid'] == ''
        ]
        items = [i for i in items if not i in filter]

        items = [
            i for i in items if ('autoplay' in i and i['autoplay'] == True)
            or not 'autoplay' in i
        ]

        for i in range(len(items)):
            try:
                if progressDialog.iscanceled(): break
                if xbmc.abortRequested == True: return sys.exit()
                url = self.sourcesResolve(items[i])
                if u == None: u = url
                if not url == None: break
            except:
                pass

        try:
            progressDialog.close()
        except:
            pass

        return u
Exemplo n.º 56
0
    def playItem(self, source):
        try:
            f = dict(
                urlparse.parse_qsl(
                    control.infoLabel('Container.FolderPath').replace('?',
                                                                      '')))

            meta = f['meta'] if 'meta' in f else None
            title = f['title'] if 'title' in f else None
            title = f['tvshowtitle'] if 'tvshowtitle' in f else title
            year = f['year'] if 'year' in f else None
            season = f['season'] if 'season' in f else None
            episode = f['episode'] if 'episode' in f else None
            imdb = f['imdb'] if 'imdb' in f else None
            tvdb = f['tvdb'] if 'tvdb' in f else None

            next = []
            prev = []
            total = []

            for i in range(1, 1000):
                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('?', '')))
                    u = json.loads(u['source'])[0]
                    next.append(u)
                except:
                    break
            for i in range(-1000, 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('?', '')))
                    u = json.loads(u['source'])[0]
                    prev.append(u)
                except:
                    break

            items = json.loads(source)
            items = [i for i in items + next + prev][:20]

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

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

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

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

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

                    control.sleep(200)

                    from resources.lib.modules.player import player
                    player().run(title, year, season, episode, imdb, tvdb,
                                 meta, self.url)

                    return self.url
                except:
                    pass

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

            raise Exception()

        except:
            control.infoDialog(control.lang(30501).encode('utf-8'))
            pass
Exemplo n.º 57
0
    def playItem(self, source):
        try:
            f = dict(urlparse.parse_qsl(control.infoLabel('Container.FolderPath').replace('?','')))

            meta = f['meta'] if 'meta' in f else None
            title = f['title'] if 'title' in f else None
            title = f['tvshowtitle'] if 'tvshowtitle' in f else title
            year = f['year'] if 'year' in f else None
            season = f['season'] if 'season' in f else None
            episode = f['episode'] if 'episode' in f else None
            imdb = f['imdb'] if 'imdb' in f else None
            tvdb = f['tvdb'] if 'tvdb' in f else None

            next = [] ; prev = [] ; total = []

            for i in range(1,1000):
                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('?','')))
                    u = json.loads(u['source'])[0]
                    next.append(u)
                except:
                    break
            for i in range(-1000,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('?','')))
                    u = json.loads(u['source'])[0]
                    prev.append(u)
                except:
                    break

            items = json.loads(source)
            items = [i for i in items+next+prev][:20]

            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])
                    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
                        k = control.condVisibility('Window.IsActive(yesnoDialog)')
                        if k: m += '1'; m = m[-1]
                        if (w.is_alive() == False or x > 30) and not k: break
                        time.sleep(0.5)

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


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

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

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

                    control.sleep(200)
                    control.execute('Dialog.Close(virtualkeyboard)')
                    control.execute('Dialog.Close(yesnoDialog)')

                    from resources.lib.modules.player import player
                    player().run(title, year, season, episode, imdb, tvdb, meta, self.url)

                    return self.url
                except:
                    pass

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

            raise Exception()

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

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

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

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

            items = [items[select - 1]]
            items = [i for i in items + next + prev][:20]

            if progress == True:
                self.progressDialog = control.progressDialog
                self.progressDialog.create(control.addonInfo('name'), '')
                self.progressDialog.update(0)

            block = None

            for i in range(len(items)):
                try:
                    if progress == True:
                        if self.progressDialog.iscanceled(): break
                        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])
                    w.start()

                    m = ''

                    for x in range(3600):
                        if progress == True:
                            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(0.5)

                    for x in range(30):
                        if m == '': break
                        if progress == True:
                            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']

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

                    return self.url
                except:
                    pass

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

        except:
            try:
                self.progressDialog.close()
            except:
                pass
Exemplo n.º 59
0
    def addDirectory(self, items, queue=False):
        if items == None or len(items) == 0: return

        sysaddon = sys.argv[0]
        addonPoster = addonBanner = control.addonInfo('icon')
        addonFanart = control.addonInfo('fanart')

        playlist = control.playlist
        if not queue == False: playlist.clear()

        try: devmode = True if 'testings.xml' in control.listDir(control.dataPath)[1] else False
        except: devmode = False

        mode = [i['content'] for i in items if 'content' in i]
        if 'movies' in mode: mode = 'movies'
        elif 'tvshows' in mode: mode = 'tvshows'
        elif 'seasons' in mode: mode = 'seasons'
        elif 'episodes' in mode: mode = 'episodes'
        elif 'addons' in mode: mode = 'addons'
        else: mode = 'videos'

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

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

                if i['action'] == 'plugin' and 'url' in i: url = i['url']

                try: devurl = dict(urlparse.parse_qsl(urlparse.urlparse(url).query))['action']
                except: devurl = None
                if devurl == 'developer' and not devmode == True: raise Exception()

                poster = i['poster'] if 'poster' in i else '0'
                banner = i['banner'] if 'banner' in i else '0'
                fanart = i['fanart'] if 'fanart' in i else '0'
                if poster == '0': poster = addonPoster
                if banner == '0' and poster == '0': banner = addonBanner
                elif banner == '0': banner = poster

                content = i['content'] if 'content' in i else '0'

                folder = i['folder'] if 'folder' in i else True

                meta = dict((k,v) for k, v in i.iteritems() if not v == '0')

                cm = []

                if content in ['movies', 'tvshows']:
                    meta.update({'trailer': '%s?action=trailer&name=%s' % (sysaddon, urllib.quote_plus(name))})
                    cm.append((control.lang(30707).encode('utf-8'), 'RunPlugin(%s?action=trailer&name=%s)' % (sysaddon, urllib.quote_plus(name))))

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

                if (folder == False and not '|regex=' in str(i.get('url'))) or (folder == True and content in ['tvshows', 'seasons']):
                    cm.append((control.lang(30723).encode('utf-8'), 'RunPlugin(%s?action=queueItem)' % sysaddon))

                if content == 'movies':
                    try: dfile = '%s (%s)' % (i['title'], i['year'])
                    except: dfile = name
                    try: cm.append((control.lang(30722).encode('utf-8'), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(dfile), urllib.quote_plus(i['url']), urllib.quote_plus(poster))))
                    except: pass
                elif content == 'episodes':
                    try: dfile = '%s S%02dE%02d' % (i['tvshowtitle'], int(i['season']), int(i['episode']))
                    except: dfile = name
                    try: cm.append((control.lang(30722).encode('utf-8'), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(dfile), urllib.quote_plus(i['url']), urllib.quote_plus(poster))))
                    except: pass
                elif content == 'songs':
                    try: cm.append((control.lang(30722).encode('utf-8'), 'RunPlugin(%s?action=addDownload&name=%s&url=%s&image=%s)' % (sysaddon, urllib.quote_plus(name), urllib.quote_plus(i['url']), urllib.quote_plus(poster))))
                    except: pass

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

                if devmode == True:
                    try: cm.append(('Open in browser', 'RunPlugin(%s?action=browser&url=%s)' % (sysaddon, urllib.quote_plus(i['url']))))
                    except: pass


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

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

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

                if queue == False:
                    item.setInfo(type='Video', infoLabels = meta)
                    item.addContextMenuItems(cm)
                    control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=folder)
                else:
                    item.setInfo(type='Video', infoLabels = meta)
                    playlist.add(url=url, listitem=item)
            except:
                pass

        if not queue == False:
            return control.player.play(playlist)

        try:
            i = items[0]
            if i['next'] == '': raise Exception()
            url = '%s?action=%s&url=%s' % (sysaddon, i['nextaction'], urllib.quote_plus(i['next']))
            item = control.item(label=control.lang(30500).encode('utf-8'))
            item.setArt({'addonPoster': addonPoster, 'thumb': addonPoster, 'poster': addonPoster, 'tvshow.poster': addonPoster, 'season.poster': addonPoster, 'banner': addonPoster, 'tvshow.banner': addonPoster, 'season.banner': addonPoster})
            item.setProperty('addonFanart_Image', addonFanart)
            control.addItem(handle=int(sys.argv[1]), url=url, listitem=item, isFolder=True)
        except:
            pass

        if not mode == None: control.content(int(sys.argv[1]), mode)
        control.directory(int(sys.argv[1]), cacheToDisc=True)
        if mode in ['movies', 'tvshows', 'seasons', 'episodes']:
            views.setView(mode, {'skin.estuary': 55})