Esempio n. 1
0
 def get_torrent(self, quality=None):
     """Picks a suitable torrent and returns it."""
     if not quality:
         quality = config["quality"]
     # bish, bash, bosh
     #if len(self.torrents) == 1 and self.torrents[0].quality <= quality:
     #    return self.torrents[0]
     # One torrent higher than the quality we want. this is unlikely, but
     # unwanted.
     #elif len(self.torrents) == 1:
     #    raise EpisodeNoWorkingTorrentsError
     
     # Use the highest quality available in the feed. This is to avoid
     # delays trying to find a higher quality torrent if there's really
     # no chance of finding one.
     # The only disadvantage to this method is when a higher quality 
     # episode does actually pop up, we will probably miss the first one.
     wanted_quality = min(quality, self.show.best_quality)
     shortlist = []
     # First try : download the episodes for which we have the wanted
     # quality
     for torrent in self.torrents:
         if torrent.quality == wanted_quality:
             try:
                 torrent.download_retry()
                 shortlist.append(torrent)
             except TorrentError, e:
                 logging.warn("Torrent download failed: %s" % e)
Esempio n. 2
0
 def _save_episode(self, episode):
         try:
             filename = episode.save(config["quality"])
             logging.info("%s saved to %s" % (episode, filename))
             return True
         except EpisodeQualityDelayError:
             logging.debug("Delaying download of this episode to wait for "
                          "a higher quality to be released.")
         except EpisodeNoWorkingTorrentsError:
             #if key == keys[-1]:
                 # TODO: only warn about this once otherwise cron jobs
                 #       will get oh-so-annoying. store in state file
                 #       so we're only bugged once or twice
             #    logging.info("No working torrents found for %s. The "
             #                 "download will be attempted again next "
             #                 "time PyTVShows is run." 
             #                % new_episodes[key])
             #else:
                 # TODO: store failed torrents in the state file for
                 #       retrying
             logging.warn("No working torrents found for %s." % episode)
         return False