def start_(self): cw = self.customWidget self.read() if self.status == 'stop': return True cw.dir = self.dir cw.urls = self.urls self.size = Size() cw.setColor('downloading') self.exec_queue.run(lambda : cw.pbar.setMaximum(MAX_PBAR)) self.exec_queue.run(lambda : cw.pbar.setFormat('%p%')) cw.downloader_pausable = True self.update_tools_buttons() if cw.paused: data = cw.pause_data self._filesize_prev = data['filesize'] cw.paused = False cw.pause_lock = False self.update_tools_buttons() torrent.download(self._info, save_path=self.dir, callback=self.callback) if cw.alive: self.exec_queue.run(lambda : cw.setSpeed('')) if cw.pause_lock and cw.pbar.value() < cw.pbar.maximum(): cw.pause_data = {'type': self.type, 'url': self.url, 'filesize': self._filesize_prev} cw.paused = True cw.pause_lock = False self.update_tools_buttons() return True self.title = self.name if not self.single: self.exec_queue.run(lambda : cw.pbar.setMaximum(len(cw.imgs)))
def start_(self): cw = self.cw cw.pbar.setFormat('%p%') cw.setColor('reading') cw.downloader_pausable = True if cw.paused: data = cw.pause_data cw.paused = False cw.pause_lock = False self.update_tools_buttons() self.read() if self.status == 'stop': self.stop() return True if cw.paused: pass else: cw.dir = self.dir cw.urls[:] = self.urls cw.clearPieces() self.size = Size() self.size_upload = Size() cw.pbar.setMaximum(self._info.total_size()) cw.setColor('downloading') torrent.download(self._info, save_path=self.dir, callback=self.callback, cw=cw) self.update_progress(self._h, False) cw.setSpeed(0.0) cw.setUploadSpeed(0.0) if not cw.alive: return self.update_pause() if cw.paused: return True self.title = self.name if not self.single: cw.pbar.setMaximum(len(cw.imgs)) cw.clearPieces() self._h = None
def run(): logger.info("Retrieving myepisodes list") raw_feed = url.urlopen(config.val("rss")).read() title_list = re.findall("<title>(.*?)</title>", raw_feed) # Counting results, using a flag results = 0 downloaded_flag = 0 # Notification text - this var is updated each time a torrent is successfully found body = "Downloading episodes:\n" for title in title_list: title_cut = re.findall("\[ (.*?) \]", title) dropped_shows = config.dropped_shows() # If title is "", it's not a show. Also filtering according to specified year, and skipping some specific shows if len(title_cut) == 0: logger.info("Skipping empty line") continue elif int(title_cut[3][-4:]) < config.val("limit_date"): logger.info("Skipping show older than limit date (" + title_cut[3][-4:] + ")") continue elif title_cut[0] in dropped_shows: logger.info("Skipping specific show") continue else: results += 1 episode_nbr = "S" + title_cut[1][:2] + "E" + title_cut[1][-2:] episode = title_cut[0] + " " + episode_nbr logger.info("Found episode : " + episode) # Searching episode, updating body notification if download has started logger.info("Searching episode") downloaded = torrent.download(episode) if downloaded: body = body + downloaded + "\n" downloaded_flag = 1 # If nothing new, or could not fetch anything if results == 0 or downloaded_flag == 0: logger.info("Nothing new today") else: # Pushing notification logger.info("Pushing notification") config.notification(body) # Writing logs for web interface write_logs(body) return results