def find_torrent(self): '''Get the torrent for this episode (whether from the episode itself, its season or search). Updates self.torrent accordingly.''' log.info("Trying to find the torrent for episode %s", self) # Check if we already have a torrent attached to this episode try: if self.torrent is not None: log.info("Torrent already found %s", self.torrent) return self.torrent except Torrent.DoesNotExist: pass # No torrent yet, need to search for one from wall.plugins import TorrentSearcher, get_active_plugin torrent_searcher = get_active_plugin(TorrentSearcher) try: self.torrent = torrent_searcher.search_episode_torrent(self) except: log.exception("Error while searching for torrent for episode %s", self) self.torrent = Torrent(status='Error') self.torrent.save() self.save() if self.torrent.status == 'Error': log.warn('Could not find torrent for episode %s', self) else: log.info("Torrent search for episode %s returned %s", self, self.torrent) return self.torrent
def find_torrent(self): '''Search for bulk torrents for this series' seasons.''' log.info("Trying to find season torrents for series %s", self) from wall.plugins import TorrentSearcher, get_active_plugin torrent_searcher = get_active_plugin(TorrentSearcher) try: # Retrieve a dict of torrents, one item for each season season_torrent_dict = torrent_searcher.search_season_torrent_dict(self) except: log.exception("Error while searching for season torrents for series %s", self) log.info("Season torrent search for series %s returned %s", self, season_torrent_dict) for season_number, season_torrent in season_torrent_dict.items(): season = self.season_set.get(number=season_number) season.set_torrent(season_torrent)