def run(self): """Run daily search thread.""" generic_queue.QueueItem.run(self) self.started = True try: log.info('Beginning daily search for new episodes') found_results = search_for_needed_episodes(self.scheduler_start_time, force=self.force) if not found_results: log.info('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): log.info( 'Downloading {name} with {seeders} seeders and {leechers} leechers' ' and size {size} from {provider}', { 'name': result.name, 'seeders': result.seeders, 'leechers': result.leechers, 'size': pretty_file_size(result.size), 'provider': result.provider.name, } ) else: log.info( 'Downloading {name} with size: {size} from {provider}', { 'name': result.name, 'size': pretty_file_size(result.size), 'provider': result.provider.name, } ) # Set the search_type for the result. result.search_type = SearchType.DAILY_SEARCH # Create the queue item snatch_queue_item = SnatchQueueItem(result.series, result.episodes, result) # Add the queue item to the queue app.manual_snatch_scheduler.action.add_item(snatch_queue_item) self.success = False while snatch_queue_item.success is False: if snatch_queue_item.started and snatch_queue_item.success: self.success = True time.sleep(1) # give the CPU a break time.sleep(common.cpu_presets[app.CPU_PRESET]) except Exception as error: self.success = False log.exception('DailySearchQueueItem Exception, error: {error}', {'error': error}) if self.success is None: self.success = False self.finish()
def run(self): """Run daily search thread.""" generic_queue.QueueItem.run(self) self.started = True try: log.info('Beginning daily search for new episodes') found_results = search_for_needed_episodes(self.scheduler_start_time, force=self.force) if not found_results: log.info('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): log.info( 'Downloading {name} with {seeders} seeders and {leechers} leechers' ' and size {size} from {provider}', { 'name': result.name, 'seeders': result.seeders, 'leechers': result.leechers, 'size': pretty_file_size(result.size), 'provider': result.provider.name, } ) else: log.info( 'Downloading {name} with size: {size} from {provider}', { 'name': result.name, 'size': pretty_file_size(result.size), 'provider': result.provider.name, } ) # Set the search_type for the result. result.search_type = SearchType.DAILY_SEARCH # Create the queue item snatch_queue_item = SnatchQueueItem(result.series, result.episodes, result) # Add the queue item to the queue app.manual_snatch_scheduler.action.add_item(snatch_queue_item) self.success = False while snatch_queue_item.success is False: if snatch_queue_item.started and snatch_queue_item.success: self.success = True time.sleep(1) # give the CPU a break time.sleep(common.cpu_presets[app.CPU_PRESET]) except Exception as error: self.success = False log.exception('DailySearchQueueItem Exception, error: {error}', {'error': error}) if self.success is None: self.success = False self.finish()
def run(self): """Run daily search thread.""" generic_queue.QueueItem.run(self) self.started = True try: log.info('Beginning daily search for new episodes') found_results = search_for_needed_episodes(force=self.force) if not found_results: log.info('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): log.info( 'Downloading {name} with {seeders} seeders and {leechers} leechers' ' and size {size} from {provider}', { 'name': result.name, 'seeders': result.seeders, 'leechers': result.leechers, 'size': pretty_file_size(result.size), 'provider': result.provider.name, }) else: log.info( 'Downloading {name} with size: {size} from {provider}', { 'name': result.name, 'size': pretty_file_size(result.size), 'provider': result.provider.name, }) self.success = snatch_episode(result) # give the CPU a break time.sleep(common.cpu_presets[app.CPU_PRESET]) except Exception as error: self.success = False log.exception('DailySearchQueueItem Exception, error: {error}', {'error': error}) if self.success is None: self.success = False self.finish()