Esempio n. 1
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
Esempio n. 2
0
def clear(table=None):
    try:
        control.idle()

        if table == None: table = ['rel_list', 'rel_lib']
        elif not type(table) == list: table = [table]

        yes = control.yesnoDialog(control.lang(30401).encode('utf-8'), '', '')
        if not yes: return

        dbcon = database.connect(control.cacheFile)
        dbcur = dbcon.cursor()

        for t in table:
            try:
                dbcur.execute("DROP TABLE IF EXISTS %s" % t)
                dbcur.execute("VACUUM")
                dbcon.commit()
            except:
                pass

        control.infoDialog(control.lang(30402).encode('utf-8'))
    except:
        pass
Esempio n. 3
0
        from resources.lib.indexers import episodes
        rlist = episodes.seasons().get(tvshowtitle, year, imdb, tvdb, create_directory=False)
        r = sys.argv[0]+"?action=random&rtype=episode"
    elif rtype == 'show':
        from resources.lib.indexers import tvshows
        rlist = tvshows.tvshows().get(url, create_directory=False)
        r = sys.argv[0]+"?action=random&rtype=season"
    from resources.lib.modules import control
    from random import randint
    import json
    try:
        rand = randint(1,len(rlist))-1
        for p in ['title','year','imdb','tvdb','season','episode','tvshowtitle','premiered','select']:
            if rtype == "show" and p == "tvshowtitle":
                try: r += '&'+p+'='+urllib.quote_plus(rlist[rand]['title'])
                except: pass
            else:
                try: r += '&'+p+'='+urllib.quote_plus(rlist[rand][p])
                except: pass
        try: r += '&meta='+urllib.quote_plus(json.dumps(rlist[rand]))
        except: r += '&meta='+urllib.quote_plus("{}")
        if rtype == "movie":
            try: control.infoDialog(rlist[rand]['title'], control.lang(32536).encode('utf-8'), time=30000)
            except: pass
        elif rtype == "episode":
            try: control.infoDialog(rlist[rand]['tvshowtitle']+" - Season "+rlist[rand]['season']+" - "+rlist[rand]['title'], control.lang(32536).encode('utf-8'), time=30000)
            except: pass
        control.execute('RunPlugin(%s)' % r)
    except:
        control.infoDialog(control.lang(32537).encode('utf-8'), time=8000)
Esempio n. 4
0
                     rlist[rand]['title'])
             except:
                 pass
         else:
             try:
                 r += '&' + p + '=' + urllib.quote_plus(rlist[rand][p])
             except:
                 pass
     try:
         r += '&meta=' + urllib.quote_plus(json.dumps(rlist[rand]))
     except:
         r += '&meta=' + urllib.quote_plus("{}")
     if rtype == "movie":
         try:
             control.infoDialog(rlist[rand]['title'],
                                control.lang(32536).encode('utf-8'),
                                time=30000)
         except:
             pass
     elif rtype == "episode":
         try:
             control.infoDialog(rlist[rand]['tvshowtitle'] + " - Season " +
                                rlist[rand]['season'] + " - " +
                                rlist[rand]['title'],
                                control.lang(32536).encode('utf-8'),
                                time=30000)
         except:
             pass
     control.execute('RunPlugin(%s)' % r)
 except:
     control.infoDialog(control.lang(32537).encode('utf-8'), time=8000)
Esempio n. 5
0
    def getSources(self,
                   title,
                   year,
                   imdb,
                   tvdb,
                   season,
                   episode,
                   tvshowtitle,
                   premiered,
                   quality='HD',
                   timeout=10):
        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