Ejemplo n.º 1
0
    def _downloadPropers(self, properList):
        """
        Download proper (snatch it)

        :param properList:
        """

        for curProper in properList:

            historyLimit = datetime.today() - timedelta(days=30)

            # make sure the episode has been downloaded before
            historyResults = main_db.MainDB().select(
                    "SELECT resource FROM history " +
                    "WHERE showid = ? AND season = ? AND episode = ? AND quality = ? AND date >= ? " +
                    "AND action IN (" + ",".join([str(x) for x in Quality.SNATCHED + Quality.DOWNLOADED]) + ")",
                    [curProper.indexerid, curProper.season, curProper.episode, curProper.quality,
                     historyLimit.strftime(History.date_format)])

            # if we didn't download this episode in the first place we don't know what quality to use for the proper so we can't do it
            if len(historyResults) == 0:
                sickrage.srLogger.info(
                        "Unable to find an original history entry for proper " + curProper.name + " so I'm not downloading it.")
                continue

            else:

                # make sure that none of the existing history downloads are the same proper we're trying to download
                clean_proper_name = self._genericName(remove_non_release_groups(curProper.name))
                isSame = False
                for curResult in historyResults:
                    # if the result exists in history already we need to skip it
                    if self._genericName(
                            remove_non_release_groups(curResult[b"resource"])) == clean_proper_name:
                        isSame = True
                        break
                if isSame:
                    sickrage.srLogger.debug("This proper is already in history, skipping it")
                    continue

                # get the episode object
                epObj = curProper.show.getEpisode(curProper.season, curProper.episode)

                # make the result object
                result = curProper.provider.getResult([epObj])
                result.show = curProper.show
                result.url = curProper.url
                result.name = curProper.name
                result.quality = curProper.quality
                result.release_group = curProper.release_group
                result.version = curProper.version
                result.content = curProper.content

                # snatch it
                snatchEpisode(result, SNATCHED_PROPER)
                gen.sleep(cpu_presets[sickrage.srConfig.CPU_PRESET])
Ejemplo n.º 2
0
 def _test(self):
     for test_string in test_strings:
         self.assertEqual(remove_non_release_groups(test_string), test_result)
Ejemplo n.º 3
0
    def _downloadPropers(self, properList):
        """
        Download proper (snatch it)

        :param properList:
        """

        for curProper in properList:

            historyLimit = datetime.today() - timedelta(days=30)

            # make sure the episode has been downloaded before
            historyResults = main_db.MainDB().select(
                "SELECT resource FROM history " +
                "WHERE showid = ? AND season = ? AND episode = ? AND quality = ? AND date >= ? "
                + "AND action IN (" + ",".join(
                    [str(x)
                     for x in Quality.SNATCHED + Quality.DOWNLOADED]) + ")", [
                         curProper.indexerid, curProper.season,
                         curProper.episode, curProper.quality,
                         historyLimit.strftime(History.date_format)
                     ])

            # if we didn't download this episode in the first place we don't know what quality to use for the proper so we can't do it
            if len(historyResults) == 0:
                sickrage.srLogger.info(
                    "Unable to find an original history entry for proper " +
                    curProper.name + " so I'm not downloading it.")
                continue

            else:

                # make sure that none of the existing history downloads are the same proper we're trying to download
                clean_proper_name = self._genericName(
                    remove_non_release_groups(curProper.name))
                isSame = False
                for curResult in historyResults:
                    # if the result exists in history already we need to skip it
                    if self._genericName(
                            remove_non_release_groups(
                                curResult[b"resource"])) == clean_proper_name:
                        isSame = True
                        break
                if isSame:
                    sickrage.srLogger.debug(
                        "This proper is already in history, skipping it")
                    continue

                # get the episode object
                epObj = curProper.show.getEpisode(curProper.season,
                                                  curProper.episode)

                # make the result object
                result = curProper.provider.getResult([epObj])
                result.show = curProper.show
                result.url = curProper.url
                result.name = curProper.name
                result.quality = curProper.quality
                result.release_group = curProper.release_group
                result.version = curProper.version
                result.content = curProper.content

                # snatch it
                snatchEpisode(result, SNATCHED_PROPER)
                time.sleep(cpu_presets[sickrage.srConfig.CPU_PRESET])