示例#1
0
    def getSources(self, name, title, year, imdb, tvdb, season, episode, show, show_alt, date, genre):
        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 show == None: content = 'movie'
        else: content = 'episode'


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


        global global_sources
        global_sources = []

        threads = []

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

        sourceDict = [i[0] for i in sourceDict if i[1] == 'true']

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


        try: timeout = int(control.setting('sources_timeout_beta'))
        except: timeout = 10


        [i.start() for i in threads]
        #[i.join() for i in threads] ; self.sources = global_sources ; return self.sources


        for i in range(0, timeout * 2):
            is_alive = [x.is_alive() for x in threads]
            if all(x == False for x in is_alive): break
            time.sleep(0.5)

        for i in range(0, 5 * 2):
            is_alive = len([i for i in threads if i.is_alive() == True])
            if is_alive < 10: break
            time.sleep(0.5)


        self.sources = global_sources

        return self.sources
示例#2
0
    def clearSources(self):
        try:
            yes = control.yesnoDialog('Are you sure?', '', '')
            if not yes: return

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

            control.infoDialog('Process Complete')
        except:
            pass
示例#3
0
    def clearSources(self):
        try:
            yes = control.yesnoDialog("Are you sure?", "", "")
            if not yes:
                return

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

            control.infoDialog("Process Complete")
        except:
            pass
示例#4
0
    def getSources(self, name, title, year, imdb, tvdb, season, episode, show, show_alt, date, genre):
        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 show == None:
            content = "movie"
        else:
            content = "episode"

        if content == "movie":
            sourceDict = [i for i in sourceDict if i.endswith(("_mv", "_mv_tv"))]
            try:
                sourceDict = [(i, control.setting(re.sub("_mv_tv$|_mv$|_tv$", "", i))) for i in sourceDict]
            except:
                sourceDict = [(i, "true") for i in sourceDict]
        else:
            sourceDict = [i for i in sourceDict if i.endswith(("_tv", "_mv_tv"))]
            try:
                sourceDict = [(i, control.setting(re.sub("_mv_tv$|_mv$|_tv$", "", i) + "_tv")) for i in sourceDict]
            except:
                sourceDict = [(i, "true") for i in sourceDict]

        global global_sources
        global_sources = []

        threads = []

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

        sourceDict = [i[0] for i in sourceDict if i[1] == "true"]

        if content == "movie":
            title = cleantitle.normalize(title)
            for source in sourceDict:
                threads.append(
                    Thread(
                        self.getMovieSource,
                        title,
                        year,
                        imdb,
                        re.sub("_mv_tv$|_mv$|_tv$", "", source),
                        __import__(source, globals(), locals(), [], -1).source(),
                    )
                )
        else:
            show, show_alt = cleantitle.normalize(show), cleantitle.normalize(show_alt)
            season, episode = ep_redirect.get(title, year, imdb, tvdb, season, episode, show, date, genre)
            for source in sourceDict:
                threads.append(
                    Thread(
                        self.getEpisodeSource,
                        title,
                        year,
                        imdb,
                        tvdb,
                        date,
                        season,
                        episode,
                        show,
                        show_alt,
                        re.sub("_mv_tv$|_mv$|_tv$", "", source),
                        __import__(source, globals(), locals(), [], -1).source(),
                    )
                )

        try:
            timeout = int(control.setting("sources_timeout_beta"))
        except:
            timeout = 10

        [i.start() for i in threads]
        # [i.join() for i in threads] ; self.sources = global_sources ; return self.sources

        for i in range(0, timeout * 2):
            is_alive = [x.is_alive() for x in threads]
            if all(x == False for x in is_alive):
                break
            time.sleep(0.5)

        for i in range(0, 5 * 2):
            is_alive = len([i for i in threads if i.is_alive() == True])
            if is_alive < 10:
                break
            time.sleep(0.5)

        self.sources = global_sources

        return self.sources