Ejemplo n.º 1
0
    def execute(self):
        generic_queue.QueueItem.execute(self)

        for season in self.segment:
            sickbeard.searchBacklog.BacklogSearcher.currentSearchInfo = {
            'title': self.show.name + " Season " + str(season)}

            wantedEps = self.segment[season]

            try:
                logger.log("Beginning backlog search for [" + self.show.name + "]")
                searchResult = search.searchProviders(self.show, season, wantedEps, False)

                # reset thread back to original name
                threading.currentThread().name = self.thread_name

                if searchResult:
                    for result in searchResult:
                        # just use the first result for now
                        logger.log(u"Downloading " + result.name + " from " + result.provider.name)
                        search.snatchEpisode(result)

                        # give the CPU a break
                        time.sleep(common.cpu_presets[sickbeard.CPU_PRESET])

                else:
                    logger.log(u"No needed episodes found during backlog search for [" + self.show.name + "]")

            except Exception:
                logger.log(traceback.format_exc(), logger.DEBUG)

        self.finish()
Ejemplo n.º 2
0
    def searchForTodaysEpisodes(self):

        self.amActive = True

        self._changeMissingEpisodes()

        # make sure our lists are up to date
        sickbeard.updateAiringList()
        sickbeard.updateComingList()

        with self.lock:
            
            logger.log("Beginning search for new episodes on RSS")

            foundResults = search.searchForNeededEpisodes()
            
            if not len(foundResults):
                logger.log("No needed episodes found on the RSS feeds")
            else:
                for curResult in foundResults:
                    search.snatchEpisode(curResult)
                    time.sleep(2)
                

        # update our lists to reflect any changes we just made
        sickbeard.updateAiringList()
        sickbeard.updateComingList()

        self.amActive = False
Ejemplo n.º 3
0
    def run(self):

        generic_queue.QueueItem.run(self)

        try:

            logger.log("Beginning daily search for [" + self.show.name + "]")
            foundResults = search.searchForNeededEpisodes(self.show, self.segment)

            if not len(foundResults):
                logger.log(u"No needed episodes found during daily search for [" + self.show.name + "]")
            else:
                for result in foundResults:
                    # just use the first result for now
                    logger.log(u"Downloading " + result.name + " from " + result.provider.name)
                    search.snatchEpisode(result)

                    # give the CPU a break
                    time.sleep(common.cpu_presets[sickbeard.CPU_PRESET])

            generic_queue.QueueItem.finish(self)
        except Exception:
            logger.log(traceback.format_exc(), logger.DEBUG)

        self.finish()
Ejemplo n.º 4
0
    def execute(self):
        generic_queue.QueueItem.execute(self)

        for season, episodes in self.segment.items():
            for epObj in episodes:
                logger.log(u"Marking episode as bad: [" + epObj.prettyName() + "]")
                failed_history.markFailed(epObj)

                (release, provider) = failed_history.findRelease(epObj)
                if release:
                    failed_history.logFailed(release)
                    history.logFailed(epObj, release, provider)

                failed_history.revertEpisode(epObj)
                logger.log("Beginning failed download search for [" + epObj.prettyName() + "]")

                try:
                    searchResult = search.searchProviders(self.show, season, [epObj], True)

                    # reset thread back to original name
                    threading.currentThread().name = self.thread_name

                    if searchResult:
                        for result in searchResult:
                            # just use the first result for now
                            logger.log(u"Downloading " + result.name + " from " + result.provider.name)
                            search.snatchEpisode(result)

                            # give the CPU a break
                            time.sleep(common.cpu_presets[sickbeard.CPU_PRESET])

                    else:
                        logger.log(u"No valid episode found to retry for [" + epObj.prettyName() + "]")
                except Exception, e:
                    logger.log(traceback.format_exc(), logger.DEBUG)
Ejemplo n.º 5
0
    def execute(self):

        generic_queue.QueueItem.execute(self)

        # check if we want to search for season packs instead of just season/episode
        seasonSearch = False
        seasonEps = self.show.getAllEpisodes(self.segment)
        if len(seasonEps) == len(self.wantedEpisodes):
            seasonSearch = True

        # convert indexer numbering to scene numbering for searches
        for i, epObj in enumerate(self.wantedEpisodes):
            (self.wantedEpisodes[i].scene_season,
             self.wantedEpisodes[i].scene_episode) = sickbeard.scene_numbering.get_scene_numbering(self.show.indexerid,
                                                                                                   self.show.indexer,
                                                                                                   epObj.season,
                                                                                                   epObj.episode)
            logger.log(
                "Beginning backlog search for " + self.wantedEpisodes[i].prettyName() + ' as ' + self.wantedEpisodes[
                    i].prettySceneName())

        # search for our wanted items and return the results
        results = search.searchProviders(self.show, self.segment, self.wantedEpisodes, seasonSearch=seasonSearch)

        # download whatever we find
        for curResult in results:
            search.snatchEpisode(curResult)
            time.sleep(5)

        self.finish()
Ejemplo n.º 6
0
    def run(self):
        generic_queue.QueueItem.run(self)

        try:
            logger.log(u"Marking episode as bad: [" + self.segment.prettyName() + "]")
            failed_history.markFailed(self.segment)

            (release, provider) = failed_history.findRelease(self.segment)
            if release:
                failed_history.logFailed(release)
                history.logFailed(self.segment, release, provider)

            failed_history.revertEpisode(self.segment)
            logger.log("Beginning failed download search for [" + self.segment.prettyName() + "]")

            searchResult = search.searchProviders(self.show, [self.segment], True)

            if searchResult:
                for result in searchResult:
                    # just use the first result for now
                    logger.log(u"Downloading " + result.name + " from " + result.provider.name)
                    search.snatchEpisode(result)

                    # give the CPU a break
                    time.sleep(common.cpu_presets[sickbeard.CPU_PRESET])
            else:
                logger.log(u"No valid episode found to retry for [" + self.segment.prettyName() + "]")
        except Exception:
            logger.log(traceback.format_exc(), logger.DEBUG)

        if self.success is None:
            self.success = False

        self.finish()
Ejemplo n.º 7
0
    def execute(self):
        generic_queue.QueueItem.execute(self)

        if self.ep_obj:

            failed_history.revertEpisodes(self.show, self.ep_obj.season, [self.ep_obj.episode])
            failed_history.logFailed(self.ep_obj.release_name)

            foundEpisode = search.findEpisode(self.ep_obj, manualSearch=True)
            result = False

            if not foundEpisode:
                ui.notifications.message('No downloads were found', "Couldn't find a download for <i>%s</i>" % self.ep_obj.prettyName())
                logger.log(u"Unable to find a download for " + self.ep_obj.prettyName())
            else:
                # just use the first result for now
                logger.log(u"Downloading episode from " + foundEpisode.url)
                result = search.snatchEpisode(foundEpisode)
                providerModule = foundEpisode.provider
                if not result:
                    ui.notifications.error('Error while attempting to snatch ' + foundEpisode.name+', check your logs')
                elif providerModule == None:
                    ui.notifications.error('Provider is configured incorrectly, unable to download')
    
            self.success = result

        else:    
    
            results = []
            myDB = db.DBConnection()
    
            if not self.show.air_by_date:
                sqlResults = myDB.select("SELECT episode, release_name FROM tv_episodes WHERE showid = ? AND season = ? AND status IN (" + ",".join([str(x) for x in common.Quality.FAILED]) + ")", [self.show.tvdbid, self.segment])
            else:
                segment_year, segment_month = map(int, self.segment.split('-'))
                min_date = datetime.date(segment_year, segment_month, 1)
    
                # it's easier to just hard code this than to worry about rolling the year over or making a month length map
                if segment_month == 12:
                    max_date = datetime.date(segment_year, 12, 31)
                else:
                    max_date = datetime.date(segment_year, segment_month + 1, 1) - datetime.timedelta(days=1)
    
                sqlResults = myDB.select("SELECT episode, release_name FROM tv_episodes WHERE showid = ? AND airdate >= ? AND airdate <= ? AND status IN (" + ",".join([str(x) for x in common.Quality.FAILED]) + ")",
                                            [self.show.tvdbid, min_date.toordinal(), max_date.toordinal()])
            
            for result in sqlResults:
                failed_history.revertEpisodes(self.show, self.segment, [result["episode"]])
                failed_history.logFailed(result["release_name"])

                results = search.findSeason(self.show, self.segment)

            # download whatever we find
            for curResult in results:
                search.snatchEpisode(curResult)
                time.sleep(5)

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

        :param properList:
        """

        for curProper in properList:

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

            # make sure the episode has been downloaded before
            myDB = db.DBConnection()
            historyResults = myDB.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:
                logger.log(
                    u"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(helpers.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(helpers.remove_non_release_groups(curResult["resource"])) == clean_proper_name:
                        isSame = True
                        break
                if isSame:
                    logger.log(u"This proper is already in history, skipping it", logger.DEBUG)
                    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[sickbeard.CPU_PRESET])
Ejemplo n.º 9
0
 def _searchBacklogForEp(self, curEp):
 
     foundResult = search.findEpisode(curEp)
     
     if not foundResult:
         logger.log("Unable to find NZB for " + curEp.prettyName(True))
     
     else:
         # just use the first result for now
         search.snatchEpisode(foundResult)
Ejemplo n.º 10
0
    def execute(self):

        generic_queue.QueueItem.execute(self)

        results = search.findSeason(self.show, self.segment)

        # download whatever we find
        for curResult in results:
            search.snatchEpisode(curResult, download_dir=self.show._location)
            time.sleep(5)

        self.finish()
Ejemplo n.º 11
0
    def execute(self):

        generic_queue.QueueItem.execute(self)

        results = search.findSeason(self.show, self.segment)

        # download whatever we find
        for curResult in results:
            search.snatchEpisode(curResult)
            time.sleep(5)

        self.finish()
Ejemplo n.º 12
0
def _downloadPropers(properList):

    for curProper in properList:

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

        # make sure the episode has been downloaded before
        myDB = db.DBConnection()
        historyResults = myDB.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]) + ')',
            [curProper.indexerid, curProper.season, curProper.episode, curProper.quality,
             historyLimit.strftime(history.dateFormat)])

        # 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:
            logger.log(
                u'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 = _genericName(helpers.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 _genericName(helpers.remove_non_release_groups(curResult['resource'])) == clean_proper_name:
                    isSame = True
                    break
            if isSame:
                logger.log(u'This proper is already in history, skipping it', logger.DEBUG)
                continue

            # get the episode object
            showObj = helpers.findCertainShow(sickbeard.showList, curProper.indexerid)
            if showObj == None:
                logger.log(u'Unable to find the show with indexerid ' + str(
                    curProper.indexerid) + ' so unable to download the proper', logger.ERROR)
                continue
            epObj = showObj.getEpisode(curProper.season, curProper.episode)

            # make the result object
            result = curProper.provider.get_result([epObj], curProper.url)
            if None is result:
                continue
            result.name = curProper.name
            result.quality = curProper.quality
            result.version = curProper.version

            # snatch it
            search.snatchEpisode(result, SNATCHED_PROPER)
Ejemplo n.º 13
0
    def execute(self):

        generic_queue.QueueItem.execute(self)

        results = search.searchProviders(self.show, self.segment, self.wantedEpisodes)

        # download whatever we find
        for curResult in results:
            search.snatchEpisode(curResult)
            time.sleep(5)

        self.finish()
Ejemplo n.º 14
0
    def execute(self):
        
        generic_queue.QueueItem.execute(self)

        results = search.findSeason(self.show, self.segment, self.scene)

        # download whatever we find
        if results:
            for curResult in results:
                search.snatchEpisode(curResult)
                time.sleep(5)

        self.finish()
Ejemplo n.º 15
0
    def searchBacklog(self):
        
        if self.amActive == True:
            logger.log("Backlog is still running, not starting it again", logger.DEBUG)
            return
        
        self.amActive = True
        
        self._get_lastBacklog()
        
        curDate = datetime.date.today().toordinal()
        
        if curDate - self._lastBacklog >= self.cycleTime:
            
            logger.log("Searching the database for a list of backlogged episodes to download")
            
            myDB = db.DBConnection()
            sqlResults = myDB.select("SELECT * FROM tv_episodes WHERE status IN (" + str(BACKLOG) + ", " + str(DISCBACKLOG) + ")")
            
            if sqlResults == None or len(sqlResults) == 0:
                logger.log("No episodes were found in the backlog")
                self._set_lastBacklog(curDate)
                self.amActive = False
                return
            
            for sqlEp in sqlResults:
                
                try:
                    show = helpers.findCertainShow(sickbeard.showList, int(sqlEp["showid"]))
                except exceptions.MultipleShowObjectsException:
                    logger.log("ERROR: expected to find a single show matching " + sqlEp["showid"], logger.ERROR) 
                    continue

                curEp = show.getEpisode(sqlEp["season"], sqlEp["episode"])
                
                logger.log("Found backlog episode: " + curEp.prettyName(True), logger.DEBUG)
            
                foundNZBs = search.findEpisode(curEp)
                
                if len(foundNZBs) == 0:
                    logger.log("Unable to find NZB for " + curEp.prettyName(True))
                
                else:
                    # just use the first result for now
                    search.snatchEpisode(foundNZBs[0])

                time.sleep(10)
                    
            self._set_lastBacklog(curDate)
            
        self.amActive = False
Ejemplo n.º 16
0
    def _downloadPropers(self, properList):

        for curProper in properList:

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

            # make sure the episode has been downloaded before
            myDB = db.DBConnection()
            historyResults = myDB.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]) + ")",
                [curProper.indexerid, curProper.season, curProper.episode, curProper.quality,
                 historyLimit.strftime(history.dateFormat)])

            # 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:
                logger.log(
                    u"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
                isSame = False
                for curResult in historyResults:
                    # if the result exists in history already we need to skip it
                    if self._genericName(curResult["resource"]) == self._genericName(curProper.name):
                        isSame = True
                        break
                if isSame:
                    logger.log(u"This proper is already in history, skipping it", logger.DEBUG)
                    continue

                # get the episode object
                showObj = helpers.findCertainShow(sickbeard.showList, curProper.indexerid)
                if showObj == None:
                    logger.log(u"Unable to find the show with indexerid " + str(
                        curProper                                      .indexerid) + " so unable to download the proper", logger.ERROR)
                    continue
                epObj = showObj.getEpisode(curProper.season, curProper.episode)

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

                # snatch it
                search.snatchEpisode(result, SNATCHED_PROPER)
Ejemplo n.º 17
0
    def execute(self):

        generic_queue.QueueItem.execute(self)

        results = search.findSeason(self.show, self.segment)

        # download whatever we find
        for curResult in results:
            if curResult:
                search.snatchEpisode(curResult)
                time.sleep(5)

        logger.log(u"Finished searching for episodes from " + self.show.name + " season " + str(self.segment))
        self.finish()
Ejemplo n.º 18
0
    def _downloadPropers(self, properList):

        for curProper in properList:

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

            # make sure the episode has been downloaded before
            myDB = db.DBConnection()
            historyResults = myDB.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]) + ")",
                [curProper.indexerid, curProper.season, curProper.episode, curProper.quality,
                 historyLimit.strftime(history.dateFormat)])

            # 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:
                logger.log(
                    u"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
                isSame = False
                for curResult in historyResults:
                    # if the result exists in history already we need to skip it
                    if self._genericName(curResult["resource"]) == self._genericName(curProper.name):
                        isSame = True
                        break
                if isSame:
                    logger.log(u"This proper is already in history, skipping it", logger.DEBUG)
                    continue

                # get the episode object
                showObj = helpers.findCertainShow(sickbeard.showList, curProper.indexerid)
                if showObj == None:
                    logger.log(u"Unable to find the show with indexerid " + str(
                        curProper                                      .indexerid) + " so unable to download the proper", logger.ERROR)
                    continue
                epObj = showObj.getEpisode(curProper.season, curProper.episode)

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

                # snatch it
                search.snatchEpisode(result, SNATCHED_PROPER)
Ejemplo n.º 19
0
    def run(self):
        self.amActive = True
        self._changeUnairedEpisodes()

        logger.log(u"Searching for todays new releases ...")
        foundResults = self.searchForNeededEpisodes()

        if not len(foundResults):
            logger.log(u"No needed episodes found on the RSS feeds")
        else:
            for curResult in foundResults:
                snatchEpisode(curResult)

        self.amActive = False
Ejemplo n.º 20
0
    def run(self):
        super(FailedQueueItem, self).run()
        self.started = True

        try:
            for epObj in self.segment:

                logger.log("Marking episode as bad: [" + epObj.prettyName() +
                           "]")

                failed_history.markFailed(epObj)

                (release, provider) = failed_history.findRelease(epObj)
                if release:
                    failed_history.logFailed(release)
                    history.logFailed(epObj, release, provider)

                failed_history.revertEpisode(epObj)
                logger.log("Beginning failed download search for: [" +
                           epObj.prettyName() + "]")

            # If it is wanted, self.downCurQuality doesnt matter
            # if it isnt wanted, we need to make sure to not overwrite the existing ep that we reverted to!
            searchResult = search.searchProviders(self.show, self.segment,
                                                  True, False)

            if searchResult:
                for result in searchResult:
                    # just use the first result for now
                    logger.log("Downloading " + result.name + " from " +
                               result.provider.name)
                    search.snatchEpisode(result)

                    # give the CPU a break
                    time.sleep(common.cpu_presets[sickbeard.CPU_PRESET])
            else:
                pass
                # logger.log(u"No valid episode found to retry for: [" + self.segment.prettyName() + "]")
        except Exception:
            logger.log(traceback.format_exc(), logger.DEBUG)

        # ## Keep a list with the 100 last executed searches
        fifo(MANUAL_SEARCH_HISTORY, self, MANUAL_SEARCH_HISTORY_SIZE)

        if self.success is None:
            self.success = False

        super(FailedQueueItem, self).finish()
        self.finish()
Ejemplo n.º 21
0
    def execute(self):

        generic_queue.QueueItem.execute(self)

        results = search.findSeason(self.show, self.segment)

        # download whatever we find
        for curResult in results:
            if curResult:
                search.snatchEpisode(curResult)
                time.sleep(5)

        logger.log(u"Finished searching for episodes from " + self.show.name +
                   " season " + str(self.segment))
        self.finish()
Ejemplo n.º 22
0
    def run(self):
        super(DailySearchQueueItem, self).run()

        try:
            logger.log("Beginning daily search for new episodes")
            found_results = search.searchForNeededEpisodes()

            if not found_results:
                logger.log("No needed episodes found")
            else:
                for result in found_results:
                    # just use the first result for now
                    logger.log("Downloading " + result.name + " from " + result.provider.name)
                    self.success = search.snatchEpisode(result)

                    # give the CPU a break
                    time.sleep(common.cpu_presets[sickbeard.CPU_PRESET])
        except Exception:
            logger.log(traceback.format_exc(), logger.DEBUG)

        if self.success is None:
            self.success = False

        super(DailySearchQueueItem, self).finish()
        self.finish()
Ejemplo n.º 23
0
    def execute(self):
        generic_queue.QueueItem.execute(self)
        results = []

        for season, episode in self.segment.iteritems():

            (release, provider) = failed_history.findRelease(self.show, season, episode)
            if release:
                logger.log(u"Marking release as bad: " + release)
                failed_history.markFailed(self.show, season, episode)
                failed_history.logFailed(release)

            failed_history.revertEpisode(self.show, season, episode)
            epObj = self.show.getEpisode(season, episode)

            result = search.findEpisode(epObj)
            if result:
                results.append(result)

        # download whatever we find
        for curResult in results:
            self.success = search.snatchEpisode(curResult)
            time.sleep(5)

        self.finish()
Ejemplo n.º 24
0
    def execute(self):
        generic_queue.QueueItem.execute(self)

        episodes = []

        for i, epObj in enumerate(episodes):
            # convert indexer numbering to scene numbering for searches
            (episodes[i].scene_season, self.episodes[i].scene_episode) = sickbeard.scene_numbering.get_scene_numbering(
                self.show.indexerid, self.show.indexer, epObj.season, epObj.episode)

            logger.log(
                "Beginning failed download search for " + epObj.prettyName() + ' as ' + epObj.prettySceneName())

            (release, provider) = failed_history.findRelease(self.show, epObj.season, epObj.episode)
            if release:
                logger.log(u"Marking release as bad: " + release)
                failed_history.markFailed(self.show, epObj.season, epObj.episode)
                failed_history.logFailed(release)
                history.logFailed(self.show.indexerid, epObj.season, epObj.episode, epObj.status, release, provider)

                failed_history.revertEpisode(self.show, epObj.season, epObj.episode)
                episodes.append(epObj)

        # get search results
        results = search.searchProviders(self.show, episodes[0].season, episodes)

        # download whatever we find
        for curResult in results:
            self.success = search.snatchEpisode(curResult)
            time.sleep(5)

        self.finish()
Ejemplo n.º 25
0
    def execute(self):
        generic_queue.QueueItem.execute(self)

        logger.log("Beginning manual search for " + self.ep_obj.prettyName())

        foundResults = search.searchProviders(self.ep_obj.show, self.ep_obj.season, [self.ep_obj], manualSearch=True)
        result = False

        if not foundResults:
            ui.notifications.message('No downloads were found',
                                     "Couldn't find a download for <i>%s</i>" % self.ep_obj.prettyName())
            logger.log(u"Unable to find a download for " + self.ep_obj.prettyName())

            self.success = result
        else:
            for foundResult in foundResults:
                # just use the first result for now
                logger.log(u"Downloading " + foundResult.name + " from " + foundResult.provider.name)

                result = search.snatchEpisode(foundResult)

                providerModule = foundResult.provider
                if not result:
                    ui.notifications.error('Error while attempting to snatch ' + foundResult.name + ', check your logs')
                elif providerModule == None:
                    ui.notifications.error('Provider is configured incorrectly, unable to download')

                self.success = result
Ejemplo n.º 26
0
 def snatch_item(self, item):
     for result in item.results:
         # just use the first result for now
         logger.log(u"Downloading " + result.name + " from " + result.provider.name)
         status =  search.snatchEpisode(result)
         item.success = status
         generic_queue.QueueItem.finish(item)
Ejemplo n.º 27
0
    def execute(self):
        generic_queue.QueueItem.execute(self)

        episodes = []

        for epObj in episodes:
            (release, provider) = failed_history.findRelease(self.show, epObj.season, epObj.episode)
            if release:
                logger.log(u"Marking release as bad: " + release)
                failed_history.markFailed(self.show, epObj.season, epObj.episode)
                failed_history.logFailed(release)
                history.logFailed(self.show.indexerid, epObj.season, epObj.episode, epObj.status, release, provider)

                failed_history.revertEpisode(self.show, epObj.season, epObj.episode)
                episodes.append(epObj)

        # get search results
        results = search.searchProviders(self.show, episodes[0].season, episodes)

        # download whatever we find
        for curResult in results:
            self.success = search.snatchEpisode(curResult)
            time.sleep(5)

        self.finish()
Ejemplo n.º 28
0
    def run(self):
        """
        Run daily search thread
        """
        generic_queue.QueueItem.run(self)
        self.started = True

        try:
            logger.log(u"Beginning daily search for new episodes")
            found_results = search.searchForNeededEpisodes()

            if not found_results:
                logger.log(u"No needed episodes found")
            else:
                for result in found_results:
                    # just use the first result for now
                    if result.seeders not in (-1, None) and result.leechers not in (-1, None):
                        logger.log(u"Downloading {0} with {1} seeders and {2} leechers from {3}".format(result.name,
                                   result.seeders, result.leechers, result.provider.name))
                    else:
                        logger.log(u"Downloading {0} from {1}".format(result.name, result.provider.name))
                    self.success = search.snatchEpisode(result)

                    # give the CPU a break
                    time.sleep(common.cpu_presets[sickbeard.CPU_PRESET])

        except Exception:
            self.success = False
            logger.log(traceback.format_exc(), logger.DEBUG)

        if self.success is None:
            self.success = False

        self.finish()
Ejemplo n.º 29
0
    def execute(self):
        generic_queue.QueueItem.execute(self)

        logger.log(u"Beginning manual search for " + self.ep_obj.prettyName())

        foundEpisode = search.findEpisode(self.ep_obj, manualSearch=True)
        result = False

        if not foundEpisode:
            ui.notifications.message(
                'No downloads were found',
                "Couldn't find a download for <i>%s</i>" %
                self.ep_obj.prettyName())
            logger.log(u"Unable to find a download for " +
                       self.ep_obj.prettyName())

        else:

            # just use the first result for now
            logger.log(u"Downloading episode from " + foundEpisode.url)
            result = search.snatchEpisode(foundEpisode)
            providerModule = foundEpisode.provider
            if not result:
                ui.notifications.error('Error while attempting to snatch ' +
                                       foundEpisode.name + ', check your logs')
            elif providerModule == None:
                ui.notifications.error(
                    'Provider is configured incorrectly, unable to download')

        self.success = result
Ejemplo n.º 30
0
    def run(self):
        generic_queue.QueueItem.run(self)

        try:
            logger.log(u"Beginning manual search for: [" + self.segment.prettyName() + "]")
            self.started = True

            searchResult = search.searchProviders(self.show, [self.segment], True, self.downCurQuality)

            if searchResult:
                # just use the first result for now
                logger.log(u"Downloading " + searchResult[0].name + " from " + searchResult[0].provider.name)
                self.success = search.snatchEpisode(searchResult[0])

                # give the CPU a break
                time.sleep(common.cpu_presets[sickbeard.CPU_PRESET])

            else:
                ui.notifications.message('No downloads were found',
                                         "Couldn't find a download for <i>%s</i>" % self.segment.prettyName())

                logger.log(u"Unable to find a download for: [" + self.segment.prettyName() + "]")

        except Exception:
            logger.log(traceback.format_exc(), logger.DEBUG)

        ### Keep a list with the 100 last executed searches
        fifo(MANUAL_SEARCH_HISTORY, self, MANUAL_SEARCH_HISTORY_SIZE)

        if self.success is None:
            self.success = False

        self.finish()
Ejemplo n.º 31
0
    def run(self):
        generic_queue.QueueItem.run(self)

        try:
            logging.info("Beginning daily search for new episodes")
            foundResults = search.searchForNeededEpisodes()

            if not len(foundResults):
                logging.info("No needed episodes found")
            else:
                for result in foundResults:
                    # just use the first result for now
                    logging.info("Downloading " + result.name + " from " + result.provider.name)
                    self.success = search.snatchEpisode(result)

                    # give the CPU a break
                    time.sleep(common.cpu_presets[sickbeard.CPU_PRESET])

            generic_queue.QueueItem.finish(self)
        except Exception:
            logging.debug(traceback.format_exc())

        if self.success is None:
            self.success = False

        self.finish()
Ejemplo n.º 32
0
    def execute(self):
        generic_queue.QueueItem.execute(self)

        logger.log("Searching for download for " + self.ep_obj.prettyName(True))

        (bestEpisode, otherEpisodes) = search.findEpisode(self.ep_obj, manualSearch=True)
        result = False

        if not bestEpisode:
            ui.notifications.message('No downloads were found', "Couldn't find a download for <i>%s</i>" % self.ep_obj.prettyName(True))
            logger.log(u"Unable to find a download for "+self.ep_obj.prettyName(True))

        else:
            # First attempt to download the best result
            logger.log(u"Downloading best result from " + bestEpisode.url)
            result = search.snatchEpisode(bestEpisode)
            providerModule = bestEpisode.provider

            if not result and otherEpisodes:
                # Attempt to download one of the other results
                (result, snatchedEpisode) = self._tryDownloadAny(otherEpisodes)
                providerModule = snatchedEpisode.provider

            if not result:
                ui.notifications.error('Error while attempting to download result for ' + self.ep_obj.prettyName(True) + ', check your logs')
            elif providerModule == None:
                ui.notifications.error('Provider is configured incorrectly, unable to download')

        self.success = result
Ejemplo n.º 33
0
    def run(self):
        generic_queue.QueueItem.run(self)

        try:
            logger.log(u"Beginning daily search for new episodes")
            foundResults = search.searchForNeededEpisodes()

            if not len(foundResults):
                logger.log(u"No needed episodes found")
            else:
                for result in foundResults:
                    # just use the first result for now
                    logger.log(u"Downloading " + result.name + " from " +
                               result.provider.name)
                    self.success = search.snatchEpisode(result)

                    # give the CPU a break
                    time.sleep(common.cpu_presets[sickbeard.CPU_PRESET])

            generic_queue.QueueItem.finish(self)
        except Exception:
            logger.log(traceback.format_exc(), logger.DEBUG)

        if self.success is None:
            self.success = False

        self.finish()
Ejemplo n.º 34
0
    def run(self):
        generic_queue.QueueItem.run(self)

        try:
            logger.log("Beginning manual search for: [" + self.segment.prettyName() + "]")
            self.started = True
            
            searchResult = search.searchProviders(self.show, [self.segment], True, self.downCurQuality)

            if searchResult:
                # just use the first result for now
                logger.log(u"Downloading " + searchResult[0].name + " from " + searchResult[0].provider.name)
                self.success = search.snatchEpisode(searchResult[0])

                # give the CPU a break
                time.sleep(common.cpu_presets[sickbeard.CPU_PRESET])

            else:
                ui.notifications.message('No downloads were found',
                                         "Couldn't find a download for <i>%s</i>" % self.segment.prettyName())

                logger.log(u"Unable to find a download for: [" + self.segment.prettyName() + "]")

        except Exception:
            logger.log(traceback.format_exc(), logger.DEBUG)
        
        ### Keep a list with the 100 last executed searches
        fifo(MANUAL_SEARCH_HISTORY, self, MANUAL_SEARCH_HISTORY_SIZE)
        
        if self.success is None:
            self.success = False

        self.finish()
Ejemplo n.º 35
0
    def run(self):
        generic_queue.QueueItem.run(self)

        try:
            logger.log("Beginning manual search for [" +
                       self.segment.prettyName() + "]")
            searchResult = search.searchProviders(self.show,
                                                  self.segment.season,
                                                  [self.segment], True)

            if searchResult:
                # just use the first result for now
                logger.log(u"Downloading " + searchResult[0].name + " from " +
                           searchResult[0].provider.name)
                self.success = search.snatchEpisode(searchResult[0])

                # give the CPU a break
                time.sleep(common.cpu_presets[sickbeard.CPU_PRESET])

            else:
                ui.notifications.message(
                    'No downloads were found',
                    "Couldn't find a download for <i>%s</i>" %
                    self.segment.prettyName())

                logger.log(u"Unable to find a download for " +
                           self.segment.prettyName())

        except Exception:
            logger.log(traceback.format_exc(), logger.DEBUG)

        if self.success is None:
            self.success = False

        self.finish()
Ejemplo n.º 36
0
    def execute(self):
        generic_queue.QueueItem.execute(self)

        try:
            logger.log("Beginning manual search for [" + self.segment.prettyName() + "]")
            searchResult = search.searchProviders(self.show, self.segment.season, [self.segment], True)

            # reset thread back to original name
            threading.currentThread().name = self.thread_name

            if searchResult:
                # just use the first result for now
                logger.log(u"Downloading " + searchResult[0].name + " from " + searchResult[0].provider.name)
                self.success = search.snatchEpisode(searchResult[0])

                # give the CPU a break
                time.sleep(common.cpu_presets[sickbeard.CPU_PRESET])

            else:
                ui.notifications.message('No downloads were found',
                                         "Couldn't find a download for <i>%s</i>" % self.segment.prettyName())

                logger.log(u"Unable to find a download for " + self.segment.prettyName())

        except Exception:
            logger.log(traceback.format_exc(), logger.DEBUG)
Ejemplo n.º 37
0
    def execute(self):
        generic_queue.QueueItem.execute(self)

        foundResults = []
        didSearch = False

        providers = [x for x in sickbeard.providers.sortedProviderList() if x.isActive()]

        try:
            with futures.ThreadPoolExecutor(sickbeard.NUM_OF_THREADS) as executor:
                foundResults = list(executor.map(self.process,providers))
            didSearch = True
        except:
            pass

        if not didSearch:
            logger.log(
                u"No NZB/Torrent providers found or enabled in the sickbeard config. Please check your settings.",
                logger.ERROR)

        if len(foundResults):
            for curResult in [item for sublist in foundResults for item in sublist]:
                time.sleep(0.01)

                result = search.snatchEpisode(curResult)

                # duplicate snatch detected due to multithreading
                if result == 2:
                    continue

        else:
            logger.log(u"Backlog search found nothing to snatch ...")

        self.finish()
Ejemplo n.º 38
0
    def execute(self):
        generic_queue.QueueItem.execute(self)

        for season, episode in self.segment.iteritems():
            epObj = self.show.getEpisode(season, episode)

            (release, provider) = failed_history.findRelease(self.show, season, episode)
            if release:
                logger.log(u"Marking release as bad: " + release)
                failed_history.markFailed(self.show, season, episode)
                failed_history.logFailed(release)
                history.logFailed(self.show.indexerid, season, episode, epObj.status, release, provider)

            failed_history.revertEpisode(self.show, season, episode)

        for season, episode in self.segment.iteritems():
            epObj = self.show.getEpisode(season, episode)

            if self.show.air_by_date:
                results = search.findSeason(self.show, str(epObj.airdate)[:7])
            else:
                results = search.findSeason(self.show, season)

            # download whatever we find
            for curResult in results:
                self.success = search.snatchEpisode(curResult)
                time.sleep(5)

        self.finish()
Ejemplo n.º 39
0
    def run(self):
        generic_queue.QueueItem.run(self)
        self.started = True

        try:
            for epObj in self.segment:

                logger.log(u'Marking episode as bad: [' + epObj.prettyName() +
                           ']')

                failed_history.markFailed(epObj)

                (release, provider) = failed_history.findRelease(epObj)
                if release:
                    failed_history.logFailed(release)
                    history.logFailed(epObj, release, provider)

                failed_history.revertEpisode(epObj)
                logger.log('Beginning failed download search for: [' +
                           epObj.prettyName() + ']')

            searchResult = search.searchProviders(self.show, self.segment,
                                                  True)

            if searchResult:
                for result in searchResult:
                    # just use the first result for now
                    logger.log(u'Downloading ' + result.name + ' from ' +
                               result.provider.name)
                    search.snatchEpisode(result)

                    # give the CPU a break
                    time.sleep(common.cpu_presets[sickbeard.CPU_PRESET])
            else:
                pass
                #logger.log(u"No valid episode found to retry for: [" + self.segment.prettyName() + "]")
        except Exception:
            logger.log(traceback.format_exc(), logger.DEBUG)

        finally:
            ### Keep a list with the 100 last executed searches
            fifo(MANUAL_SEARCH_HISTORY, self, MANUAL_SEARCH_HISTORY_SIZE)

            if self.success is None:
                self.success = False

            self.finish()
    def execute(self):
        generic_queue.QueueItem.execute(self)

        self._changeMissingEpisodes()

        logger.log(u"Beginning search for new episodes on RSS")

        foundResults = search.searchForNeededEpisodes()

        if not len(foundResults):
            logger.log(u"No needed episodes found on the RSS feeds")
        else:
            for curResult in foundResults:
                search.snatchEpisode(curResult)
                time.sleep(2)

        generic_queue.QueueItem.finish(self)
Ejemplo n.º 41
0
    def _downloadPropers(self, properList):
        """
        Download proper (snatch it)

        :param properList:
        """

        for curProper in properList:

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

            # make sure the episode has been downloaded before
            main_db_con = db.DBConnection()
            historyResults = main_db_con.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)])

            # make sure that none of the existing history downloads are the same proper we're trying to download
            clean_proper_name = self._genericName(helpers.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(helpers.remove_non_release_groups(curResult["resource"])) == clean_proper_name:
                    isSame = True
                    break
            if isSame:
                logger.log(u"This proper is already in history, skipping it", logger.DEBUG)
                continue
            # get the episode object
            epObj = curProper.show.getEpisode(curProper.season, curProper.episode)
            # make the result object
            result = curProper.provider.get_result([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[sickbeard.CPU_PRESET])
Ejemplo n.º 42
0
    def run(self):
        generic_queue.QueueItem.run(self)

        try:
            for season, episodes in self.segment.items():
                for epObj in episodes:
                    logger.log(u"Marking episode as bad: [" +
                               epObj.prettyName() + "]")
                    failed_history.markFailed(epObj)

                    (release, provider) = failed_history.findRelease(epObj)
                    if release:
                        failed_history.logFailed(release)
                        history.logFailed(epObj, release, provider)

                    failed_history.revertEpisode(epObj)
                    logger.log("Beginning failed download search for [" +
                               epObj.prettyName() + "]")

                    searchResult = search.searchProviders(
                        self.show, season, [epObj], True)

                    if searchResult:
                        for result in searchResult:
                            # just use the first result for now
                            logger.log(u"Downloading " + result.name +
                                       " from " + result.provider.name)
                            search.snatchEpisode(result)

                            # give the CPU a break
                            time.sleep(
                                common.cpu_presets[sickbeard.CPU_PRESET])
                    else:
                        logger.log(u"No valid episode found to retry for [" +
                                   epObj.prettyName() + "]")
        except Exception:
            logger.log(traceback.format_exc(), logger.DEBUG)

        if self.success is None:
            self.success = False

        self.finish()
Ejemplo n.º 43
0
    def execute(self):

        generic_queue.QueueItem.execute(self)

        results = search.findSeason(self.show, self.segment)

        # download whatever we find
        for curResult in results:
            if curResult:
                oldSbTORRENT_PATH = sickbeard.TORRENT_PATH
                sickbeard.TORRENT_PATH = "/tmp/mnt/sdb3/TvShow/" + self.show.name + "/S%(seasonnumber)02d" % {
                    'seasonnumber': self.segment
                }
                search.snatchEpisode(curResult)
                sickbeard.TORRENT_PATH = oldSbTORRENT_PATH
                time.sleep(5)

        logger.log(u"Finished searching for episodes from " + self.show.name +
                   " season " + str(self.segment))
        self.finish()
Ejemplo n.º 44
0
    def execute(self):
        generic_queue.QueueItem.execute(self)

        logger.log("Beginning daily search for [" + self.show.name + "]")
        foundResults = search.searchForNeededEpisodes(self.show, self.segment)

        # reset thread back to original name
        threading.currentThread().name = self.thread_name

        if not len(foundResults):
            logger.log(u"No needed episodes found during daily search for [" + self.show.name + "]")
        else:
            for result in foundResults:
                # just use the first result for now
                logger.log(u"Downloading " + result.name + " from " + result.provider.name)
                search.snatchEpisode(result)

                # give the CPU a break
                time.sleep(common.cpu_presets[sickbeard.CPU_PRESET])

        generic_queue.QueueItem.finish(self)
Ejemplo n.º 45
0
    def run(self):
        generic_queue.QueueItem.run(self)

        try:
            logger.log("Beginning backlog search for: [" + self.show.name + "]")
            searchResult = search.searchProviders(self.show, self.segment, False)

            if searchResult:
                for result in searchResult:
                    # just use the first result for now
                    logger.log(u"Downloading " + result.name + " from " + result.provider.name)
                    search.snatchEpisode(result)

                    # give the CPU a break
                    time.sleep(common.cpu_presets[sickbeard.CPU_PRESET])
            else:
                logger.log(u"No needed episodes found during backlog search for: [" + self.show.name + "]")
        except Exception:
            logger.log(traceback.format_exc(), logger.DEBUG)

        self.finish()
Ejemplo n.º 46
0
    def run(self):
        generic_queue.QueueItem.run(self)

        try:
            self._change_missing_episodes()

            self.update_providers()

            show_list = sickbeard.showList
            fromDate = datetime.date.fromordinal(1)
            for curShow in show_list:
                if curShow.paused:
                    continue

                self.episodes.extend(wantedEpisodes(curShow, fromDate))

            if not self.episodes:
                logger.log(u'No search of cache for episodes required')
                self.success = True
            else:
                num_shows = len(set([ep.show.name for ep in self.episodes]))
                logger.log(u'Found %d needed episode%s spanning %d show%s' %
                           (len(self.episodes),
                            helpers.maybe_plural(len(self.episodes)),
                            num_shows, helpers.maybe_plural(num_shows)))

                try:
                    logger.log(u'Beginning recent search for episodes')
                    found_results = search.searchForNeededEpisodes(
                        self.episodes)

                    if not len(found_results):
                        logger.log(u'No needed episodes found')
                    else:
                        for result in found_results:
                            # just use the first result for now
                            logger.log(u'Downloading %s from %s' %
                                       (result.name, result.provider.name))
                            self.success = search.snatchEpisode(result)

                            # give the CPU a break
                            time.sleep(
                                common.cpu_presets[sickbeard.CPU_PRESET])

                except Exception:
                    logger.log(traceback.format_exc(), logger.DEBUG)

                if self.success is None:
                    self.success = False

        finally:
            self.finish()
Ejemplo n.º 47
0
    def execute(self):
        generic_queue.QueueItem.execute(self)

        self._changeMissingEpisodes()

        logger.log(u"Beginning search for new episodes on RSS")

        foundResults = search.searchForNeededEpisodes()

        if not len(foundResults):
            logger.log(u"No needed episodes found on the RSS feeds")
        else:
            for curResult in foundResults:
                oldSbTORRENT_PATH = sickbeard.TORRENT_PATH
                sickbeard.TORRENT_PATH = "/tmp/mnt/sdb3/TvShow/" + self.show.name + "/S%(seasonnumber)02d" % {
                    'seasonnumber': self.segment
                }
                search.snatchEpisode(curResult)
                sickbeard.TORRENT_PATH = oldSbTORRENT_PATH
                time.sleep(2)

        generic_queue.QueueItem.finish(self)
Ejemplo n.º 48
0
    def execute(self):
        generic_queue.QueueItem.execute(self)

        if self.ep_obj:
            try:
                ep_release_name = failed_history.findRelease(
                    self.show.tvdbid, self.ep_obj.season, self.ep_obj.episode)
                failed_history.revertEpisodes(self.show, self.ep_obj.season,
                                              [self.ep_obj.episode])
                failed_history.logFailed(ep_release_name)
            except:
                pass

            foundEpisode = search.findEpisode(self.ep_obj, manualSearch=True)
            result = False

            if not foundEpisode:
                ui.notifications.message(
                    'No downloads were found',
                    "Couldn't find a download for <i>%s</i>" %
                    self.ep_obj.prettyName())
                logger.log(u"Unable to find a download for " +
                           self.ep_obj.prettyName())
            else:
                # just use the first result for now
                logger.log(u"Downloading episode from " + foundEpisode.url)
                result = search.snatchEpisode(foundEpisode)
                providerModule = foundEpisode.provider
                if not result:
                    ui.notifications.error(
                        'Error while attempting to snatch ' +
                        foundEpisode.name + ', check your logs')
                elif providerModule == None:
                    ui.notifications.error(
                        'Provider is configured incorrectly, unable to download'
                    )

            self.success = result

        else:

            results = []
            myDB = db.DBConnection()

            if not self.show.air_by_date:
                sqlResults = myDB.select(
                    "SELECT episode FROM tv_episodes WHERE showid = ? AND season = ? AND status IN ("
                    + ",".join([str(x) for x in common.Quality.FAILED]) + ")",
                    [self.show.tvdbid, self.segment])
            else:
                segment_year, segment_month = map(int, self.segment.split('-'))
                min_date = datetime.date(segment_year, segment_month, 1)

                # it's easier to just hard code this than to worry about rolling the year over or making a month length map
                if segment_month == 12:
                    max_date = datetime.date(segment_year, 12, 31)
                else:
                    max_date = datetime.date(segment_year, segment_month + 1,
                                             1) - datetime.timedelta(days=1)

                sqlResults = myDB.select(
                    "SELECT episode FROM tv_episodes WHERE showid = ? AND airdate >= ? AND airdate <= ? AND status IN ("
                    + ",".join([str(x) for x in common.Quality.FAILED]) + ")",
                    [
                        self.show.tvdbid,
                        min_date.toordinal(),
                        max_date.toordinal()
                    ])

            for result in sqlResults:
                failed_history.revertEpisodes(self.show, self.segment,
                                              [result["episode"]])
                failed_history.logFailed(ep_release_name)

                results = search.findSeason(self.show, self.segment)

            # download whatever we find
            for curResult in results:
                search.snatchEpisode(curResult)
                time.sleep(5)

        self.finish()
Ejemplo n.º 49
0
    def run(self, force=None, show=None):
        if sickbeard.showList == None:
            return
        logger.log(u"Beginning the search for french episodes older than " +
                   str(sickbeard.FRENCH_DELAY) + " days")
        foundResults = {}
        finalResults = []
        #show = self
        frenchlist = []
        #get list of english episodes that we want to search in french
        myDB = db.DBConnection()
        today = datetime.date.today().toordinal()
        if show:
            frenchsql = myDB.select(
                "SELECT showid, season, episode from tv_episodes where audio_langs='eng' and tv_episodes.showid =? and (? - tv_episodes.airdate) > ? order by showid, airdate asc",
                [show, today, sickbeard.FRENCH_DELAY])
            logger.log(
                "SELECT showid, season, episode from tv_episodes where audio_langs='eng' and tv_episodes.showid ="
                + str(show) + "and (" + str(today) +
                " - tv_episodes.airdate) > " + str(sickbeard.FRENCH_DELAY) +
                "order by showid, airdate asc")
            count = myDB.select(
                "SELECT count(*) from tv_episodes where audio_langs='eng' and tv_episodes.showid =? and (? - tv_episodes.airdate) > ?",
                [show, today, sickbeard.FRENCH_DELAY])
        else:
            frenchsql = myDB.select(
                "SELECT showid, season, episode from tv_episodes, tv_shows where audio_langs='eng' and tv_episodes.showid = tv_shows.indexer_id and tv_shows.frenchsearch = 1 and (? - tv_episodes.airdate) > ? order by showid, airdate asc",
                [today, sickbeard.FRENCH_DELAY])
            count = myDB.select(
                "SELECT count(*) from tv_episodes, tv_shows where audio_langs='eng' and tv_episodes.showid = tv_shows.indexer_id and tv_shows.frenchsearch = 1 and (? - tv_episodes.airdate) > ?",
                [today, sickbeard.FRENCH_DELAY])
        #make the episodes objects

        #logger.log("SELECT showid, season, episode from tv_episodes where audio_langs='eng' and tv_episodes.showid =" + str(show) +"and (" +str(today)+" - tv_episodes.airdate) > "+ str(sickbeard.FRENCH_DELAY) +"order by showid, airdate asc")
        logger.log(
            "SELECT showid, season, episode from tv_episodes, tv_shows where audio_langs='eng' and tv_episodes.showid = tv_shows.indexer_id and tv_shows.frenchsearch = 1 and ("
            + str(today) + " - tv_episodes.airdate) > " +
            str(sickbeard.FRENCH_DELAY) + " order by showid, airdate asc")
        logger.log(u"Searching for " + str(count[0][0]) +
                   " episodes in french")

        #logger.log(frenchsql)

        #logger.log(sickbeard.showList.)

        for episode in frenchsql:

            showObj = Show.find(sickbeard.showList, int(episode[0]))
            if showObj == None:
                logger.log("Show not in show list")

            #showObj = helpers.findCertainShow(sickbeard.showList, episode[0])
            epObj = showObj.getEpisode(episode[1], episode[2])

            #epObj = showObj.getEpisode(int(epInfo[0]), int(epInfo[1]))
            frenchlist.append(epObj)

        #for each episode in frenchlist fire a search in french
        delay = []
        temp = None
        rest = count[0][0]
        for frepisode in frenchlist:
            rest = rest - 1
            if frepisode.show.indexerid in delay:
                logger.log(
                    u"Previous episode for show " + str(frepisode.show.name) +
                    " not found in french so skipping this search",
                    logger.DEBUG)
                continue
            result = []
            for curProvider in providers.sortedProviderList():

                foundResults[curProvider.name] = {}

                if not curProvider.is_active():
                    continue

                logger.log(u"Searching for french episode on " +
                           curProvider.name + " for " + frepisode.show.name +
                           " season " + str(frepisode.season) + " episode " +
                           str(frepisode.episode))
                #try:
                #    logger.log(frepisode)
                #    temp = GenericProvider()
                #    curfrench = temp.findFrench(self, episode=frepisode, manualSearch=True)
                #curfrench =  GenericProvider.findFrench(episode=frepi  sode,manualSearch=True)
                #curProvider.findFrench(frepisode, manualSearch=True)
                #except:
                #    logger.log(u"Exception", logger.DEBUG)
                #    pass

                #for curProvider in providers:
                #    if curProvider.anime_only and not show.is_anime:
                #        logger.log(u"" + str(show.name) + " is not an anime, skipping", logger.DEBUG)
                #        continue

                curfrench = curProvider.find_search_results(
                    frepisode.show, frenchlist, 'sponly', True, True, 'french')

                #curfrench = curProvider.findFrench(frepisode, True)

                #temp = GenericProvider('temp')
                #curfrench = temp.findFrench( episode=frepisode, manualSearch=True)

                if len(curfrench):
                    #make a list of all the results for this provider
                    for curEp in curfrench:
                        if curEp in foundResults:
                            foundResults[
                                curProvider.name][curEp] += curfrench[curEp]
                        else:
                            foundResults[
                                curProvider.name][curEp] = curfrench[curEp]

                if not foundResults[curProvider.name]:
                    continue

                bestSeasonResult = None
                #if SEASON_RESULT in foundResults[curProvider.name]:
                #    bestSeasonResult = search.pickBestResult(foundResults[curProvider.name][SEASON_RESULT], show)
                #_______________________________________________________
                test = 0
                if foundResults[curProvider.name]:
                    for cur_episode in foundResults[curProvider.name]:
                        for x in foundResults[curProvider.name][cur_episode]:
                            tmp = x
                            if not show_name_helpers.filterBadReleases(
                                    x.name):  #x.name):
                                logger.log(
                                    u"French " + x.name +
                                    " isn't a valid scene release that we want, ignoring it",
                                    logger.DEBUG)
                                test += 1
                                continue
                            if sickbeard.IGNORE_WORDS == "":
                                ignore_words = "ztreyfgut"
                            else:
                                ignore_words = str(sickbeard.IGNORE_WORDS)
                            for fil in resultFilters + ignore_words.split(','):
                                if fil == showLanguages.get(u"fre"):
                                    continue
                                if re.search('(^|[\W_])' + fil + '($|[\W_])',
                                             x.url, re.I) or re.search(
                                                 '(^|[\W_])' + fil +
                                                 '($|[\W_])', x.name, re.I):
                                    logger.log(
                                        u"Invalid scene release: " + x.url +
                                        " contains " + fil + ", ignoring it",
                                        logger.DEBUG)
                                    test += 1

                    if test == 0:
                        result.append(x)

            best = None
            try:
                epi = {}
                epi[1] = frepisode
                best = search.pickBestResult(result, showObj)
            except:
                pass
            if best:
                best.name = best.name + ' snatchedfr'
                logger.log(u"Found french episode for " + frepisode.show.name +
                           " season " + str(frepisode.season) + " episode " +
                           str(frepisode.episode))
                try:
                    search.snatchEpisode(best, SNATCHED_FRENCH)
                except:
                    logger.log(u"Exception", logger.DEBUG)
                    pass
            else:
                delay.append(frepisode.show.indexerid)
                logger.log(u"No french episode found for " +
                           frepisode.show.name + " season " +
                           str(frepisode.season) + " episode " +
                           str(frepisode.episode))
            logger.log(str(rest) + u" episodes left")
Ejemplo n.º 50
0
    def __init__(self, force=None, show=None):

        #TODOif not sickbeard.DOWNLOAD_FRENCH:
        #    return
        if sickbeard.showList == None:
            return
        logger.log(u"Beginning the search for french episodes older than " +
                   str(sickbeard.FRENCH_DELAY) + " days")

        frenchlist = []
        #get list of english episodes that we want to search in french
        myDB = db.DBConnection()
        today = datetime.date.today().toordinal()
        if show:
            frenchsql = myDB.select(
                "SELECT showid, season, episode from tv_episodes where audio_langs='en' and tv_episodes.showid =? and (? - tv_episodes.airdate) > ? order by showid, airdate asc",
                [show, today, sickbeard.FRENCH_DELAY])
            count = myDB.select(
                "SELECT count(*) from tv_episodes where audio_langs='en' and tv_episodes.showid =? and (? - tv_episodes.airdate) > ?",
                [show, today, sickbeard.FRENCH_DELAY])
        else:
            frenchsql = myDB.select(
                "SELECT showid, season, episode from tv_episodes, tv_shows where audio_langs='en' and tv_episodes.showid = tv_shows.tvdb_id and tv_shows.frenchsearch = 1 and (? - tv_episodes.airdate) > ? order by showid, airdate asc",
                [today, sickbeard.FRENCH_DELAY])
            count = myDB.select(
                "SELECT count(*) from tv_episodes, tv_shows where audio_langs='en' and tv_episodes.showid = tv_shows.tvdb_id and tv_shows.frenchsearch = 1 and (? - tv_episodes.airdate) > ?",
                [today, sickbeard.FRENCH_DELAY])
        #make the episodes objects
        logger.log(u"Searching for " + str(count[0][0]) +
                   " episodes in french")
        for episode in frenchsql:
            showObj = helpers.findCertainShow(sickbeard.showList, episode[0])
            epObj = showObj.getEpisode(episode[1], episode[2])
            frenchlist.append(epObj)

        #for each episode in frenchlist fire a search in french
        delay = []
        for frepisode in frenchlist:
            if frepisode.show.tvdbid in delay:
                logger.log(
                    u"Previous episode for show " +
                    str(frepisode.show.tvdbid) +
                    " not found in french so skipping this search",
                    logger.DEBUG)
                continue
            result = []
            for curProvider in providers.sortedProviderList():

                if not curProvider.isActive():
                    continue

                logger.log(u"Searching for french episodes on " +
                           curProvider.name + " for " + frepisode.show.name +
                           " season " + str(frepisode.season) + " episode " +
                           str(frepisode.episode))
                try:
                    curfrench = curProvider.findFrench(frepisode,
                                                       manualSearch=True)
                except:
                    logger.log(u"Exception", logger.DEBUG)
                    pass
                for x in curfrench:
                    result.append(x)
            best = None
            try:
                epi = {}
                epi[1] = frepisode
                best = search.pickBestResult(result, episode=epi)
            except:
                pass
            if best:
                best.name = best.name + ' snatchedfr'
                logger.log(u"Found french episode for " + frepisode.show.name +
                           " season " + str(frepisode.season) + " episode " +
                           str(frepisode.episode))
                try:
                    search.snatchEpisode(best, SNATCHED_FRENCH)
                except:
                    logger.log(u"Exception", logger.DEBUG)
                    pass
            else:
                delay.append(frepisode.show.tvdbid)
                logger.log(u"No french episodes found for " +
                           frepisode.show.name + " season " +
                           str(frepisode.season) + " episode " +
                           str(frepisode.episode))
Ejemplo n.º 51
0
def _downloadPropers(properList):

    for curProper in properList:

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

        # make sure the episode has been downloaded before
        myDB = db.DBConnection()
        historyResults = myDB.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]) + ')',
            [
                curProper.indexerid, curProper.season, curProper.episode,
                curProper.quality,
                historyLimit.strftime(history.dateFormat)
            ])

        # 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:
            logger.log(
                u'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 = _genericName(
                helpers.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 _genericName(
                        helpers.remove_non_release_groups(
                            curResult['resource'])) == clean_proper_name:
                    isSame = True
                    break
            if isSame:
                logger.log(u'This proper is already in history, skipping it',
                           logger.DEBUG)
                continue

            # get the episode object
            showObj = helpers.findCertainShow(sickbeard.showList,
                                              curProper.indexerid)
            if showObj == None:
                logger.log(
                    u'Unable to find the show with indexerid ' +
                    str(curProper.indexerid) +
                    ' so unable to download the proper', logger.ERROR)
                continue
            epObj = showObj.getEpisode(curProper.season, curProper.episode)

            # make the result object
            result = curProper.provider.get_result([epObj], curProper.url)
            if None is result:
                continue
            result.name = curProper.name
            result.quality = curProper.quality
            result.version = curProper.version

            # snatch it
            search.snatchEpisode(result, SNATCHED_PROPER)
Ejemplo n.º 52
0
    def _downloadPropers(self, properList):

        for curProper in properList:

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

            # make sure the episode has been downloaded before
            myDB = db.DBConnection()
            historyResults = myDB.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.dateFormat)
                     ])

            # 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:
                logger.log(
                    u"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(
                    helpers.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(
                            helpers.remove_non_release_groups(
                                curResult["resource"])) == clean_proper_name:
                        isSame = True
                        break
                if isSame:
                    logger.log(
                        u"This proper is already in history, skipping it",
                        logger.DEBUG)
                    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
                search.snatchEpisode(result, SNATCHED_PROPER)
                time.sleep(cpu_presets[sickbeard.CPU_PRESET])
Ejemplo n.º 53
0
    def __init__(self, force=None, show=None):

        #TODOif not sickbeard.DOWNLOAD_FRENCH:
        #    return
        if sickbeard.showList==None:
            return
        logger.log(u"Beginning the search for french episodes older than "+ str(sickbeard.FRENCH_DELAY) +" days")
       
        frenchlist=[]
        #get list of english episodes that we want to search in french
        myDB = db.DBConnection()
        today = datetime.date.today().toordinal()
        if show:
            frenchsql=myDB.select("SELECT showid, season, episode from tv_episodes where audio_langs='en' and tv_episodes.showid =? and (? - tv_episodes.airdate) > ? order by showid, airdate asc",[show,today,sickbeard.FRENCH_DELAY]) 
            count=myDB.select("SELECT count(*) from tv_episodes where audio_langs='en' and tv_episodes.showid =? and (? - tv_episodes.airdate) > ?",[show,today,sickbeard.FRENCH_DELAY]) 
        else:
            frenchsql=myDB.select("SELECT showid, season, episode from tv_episodes, tv_shows where audio_langs='en' and tv_episodes.showid = tv_shows.tvdb_id and tv_shows.frenchsearch = 1 and (? - tv_episodes.airdate) > ? order by showid, airdate asc",[today,sickbeard.FRENCH_DELAY])
            count=myDB.select("SELECT count(*) from tv_episodes, tv_shows where audio_langs='en' and tv_episodes.showid = tv_shows.tvdb_id and tv_shows.frenchsearch = 1 and (? - tv_episodes.airdate) > ?",[today,sickbeard.FRENCH_DELAY])
        #make the episodes objects
        logger.log(u"Searching for "+str(count[0][0]) +" episodes in french")
        for episode in frenchsql:
            showObj = helpers.findCertainShow(sickbeard.showList, episode[0])
            epObj = showObj.getEpisode(episode[1], episode[2])
            frenchlist.append(epObj)
        
        #for each episode in frenchlist fire a search in french
        delay=[]
        for frepisode in frenchlist:
            if frepisode.show.tvdbid in delay:
                logger.log(u"Previous episode for show "+str(frepisode.show.tvdbid)+" not found in french so skipping this search", logger.DEBUG)
                continue
            result=[]
            for curProvider in providers.sortedProviderList():

                if not curProvider.isActive():
                    continue

                logger.log(u"Searching for french episodes on "+curProvider.name +" for " +frepisode.show.name +" season "+str(frepisode.season)+" episode "+str(frepisode.episode))
                try:
                    curfrench = curProvider.findFrench(frepisode, manualSearch=True)
                except:
                    logger.log(u"Exception", logger.DEBUG)
                    pass
                test=0
                if curfrench:
                    for x in curfrench:
                        if not show_name_helpers.filterBadReleases(x.name):
                            logger.log(u"French "+x.name+" isn't a valid scene release that we want, ignoring it", logger.DEBUG)
                            test+=1
                            continue
                        if sickbeard.IGNORE_WORDS == "":
                            ignore_words="ztreyfgut"
                        else:
                            ignore_words=str(sickbeard.IGNORE_WORDS)
                        for fil in resultFilters + ignore_words.split(','):
                            if fil == showLanguages.get(u"fr"):
                                continue
                            if re.search('(^|[\W_])'+fil+'($|[\W_])', x.url, re.I):
                                logger.log(u"Invalid scene release: "+x.url+" contains "+fil+", ignoring it", logger.DEBUG)
                                test+=1
                    if test==0:
                        result.append(x)
            best=None
            try:
                epi={}
                epi[1]=frepisode
                best = search.pickBestResult(result, episode = epi)
            except:
                pass
            if best:
                best.name=best.name + ' snatchedfr'
                logger.log(u"Found french episode for " +frepisode.show.name +" season "+str(frepisode.season)+" episode "+str(frepisode.episode))
                try:
                    search.snatchEpisode(best, SNATCHED_FRENCH)
                except:
                    logger.log(u"Exception", logger.DEBUG)
                    pass
            else:
                delay.append(frepisode.show.tvdbid)
                logger.log(u"No french episodes found for " +frepisode.show.name +" season "+str(frepisode.season)+" episode "+str(frepisode.episode))