def clear(options): """Deletes waiting movies from queue""" items = queue_get(downloaded=False, queue_name=options.queue_name) console("Removing the following movies from movie queue:") console("-" * 79) for item in items: console(item.title) queue_del(title=item.title, queue_name=options.queue_name) if not items: console("No results") console("-" * 79)
def clear(): """Deletes waiting movies from queue""" items = queue_get(downloaded=False) console('Removing the following movies from movie queue:') console('-' * 79) for item in items: console(item.title) queue_del(title=item.title) if not items: console('No results') console('-' * 79)
def clear(self, session): """Delete movie queue""" items = queue_get(session=session, downloaded=False) console("Removing the following movies from movie queue:") console("-" * 79) for item in items: console(item.title) queue_del(item.imdb_id) if not items: console("No results") console("-" * 79)
def clear(self, session): """Delete movie queue""" items = queue_get(session=session, downloaded=False) console('Removing the following movies from movie queue:') console('-' * 79) for item in items: console(item.title) queue_del(item.imdb_id) if not items: console('No results') console('-' * 79)
def delete(self, type, id, session=None): """ Delete movies from movie queue """ kwargs = self.validate_type(type, id, session) try: mq.queue_del(**kwargs) except mq.QueueError as e: reply = {'status': 'error', 'message': e.message} return reply, 404 reply = jsonify( {'status': 'success', 'message': 'successfully deleted {0} movie {1}'.format(type, id)}) return reply
def on_process_start(self, feed): """Handle --movie-queue management""" if not getattr(feed.manager.options, "movie_queue", False): return feed.manager.disable_feeds() options = feed.manager.options.movie_queue if options["action"] == "list": self.queue_list(feed.session) return if options["action"] == "downloaded": self.queue_list(feed.session, downloaded=True) return if options["action"] == "clear": self.clear(feed.session) return if options["action"] == "del": try: title = queue_del(options["what"]) except QueueError, e: console(e.message) else: console("Removed %s from queue" % title) return
def on_process_start(self, feed): """Handle --movie-queue management""" if not getattr(feed.manager.options, 'movie_queue', False): return feed.manager.disable_feeds() options = feed.manager.options.movie_queue if options['action'] == 'list': self.queue_list(feed.session) return if options['action'] == 'downloaded': self.queue_list(feed.session, downloaded=True) return if options['action'] == 'clear': self.clear(feed.session) return if options['action'] == 'del': try: title = queue_del(options['what']) except QueueError, e: console(e.message) else: console('Removed %s from queue' % title) return
def on_process_start(self, task): """Handle --movie-queue management""" if not getattr(task.manager.options, 'movie_queue', False): return task.manager.disable_tasks() options = task.manager.options.movie_queue if options['action'] == 'list': self.queue_list(task.session) return # If the action was to do more than just list the series, make sure all entries are processed again next run. task.manager.config_changed() if options['action'] == 'downloaded': self.queue_list(task.session, downloaded=True) return if options['action'] == 'clear': self.clear(task.session) return if options['action'] == 'del': try: title = queue_del(options['what']) except QueueError, e: console(e.message) else: console('Removed %s from queue' % title) return
def del_from_queue(): imdb_id = request.values.get('imdb_id') try: title = queue_del(imdb_id=imdb_id) except QueueError as e: flash(e.message, 'error') else: flash('%s removed from queue.' % title, 'delete') return redirect(url_for('.index'))
def do_cli(manager, options): """Handle movie-queue subcommand""" if options.queue_action == 'list': queue_list(options) return # If the action affects make sure all entries are processed again next run. manager.config_changed() if options.queue_action == 'clear': clear() return if options.queue_action == 'del': try: what = parse_what(options.movie_name, lookup=False) title = queue_del(**what) except QueueError as e: console('ERROR: %s' % e.message) else: console('Removed %s from queue' % title) return if options.queue_action == 'forget': try: what = parse_what(options.movie_name, lookup=False) title = queue_forget(**what) except QueueError as e: console('ERROR: %s' % e.message) else: console( 'Forgot that %s was downloaded. Movie will be downloaded again.' % title) return if options.queue_action == 'add': try: quality = qualities.Requirements(options.quality) except ValueError as e: console('`%s` is an invalid quality requirement string: %s' % (options.quality, e.message)) return # Adding to queue requires a lookup for missing information what = {} try: what = parse_what(options.movie_name) except QueueError as e: console('ERROR: %s' % e.message) if not what.get('title') or not (what.get('imdb_id') or what.get('tmdb_id')): console('could not determine movie') # TODO: Rethink errors return try: queue_add(quality=quality, **what) except QueueError as e: console(e.message) if e.errno == 1: # This is an invalid quality error, display some more info # TODO: Fix this error? # console('Recognized qualities are %s' % ', '.join([qual.name for qual in qualities.all()])) console( 'ANY is the default and can also be used explicitly to specify that quality should be ignored.' ) except OperationalError: console('OperationalError') return
def on_process_start(self, task): """Handle --movie-queue management""" if not getattr(task.manager.options, 'movie_queue', False): return task.manager.disable_tasks() options = task.manager.options.movie_queue if options['action'] == 'list': self.queue_list(task.session) return # If the action affects make sure all entries are processed again next run. task.manager.config_changed() if options['action'] == 'downloaded': self.queue_list(task.session, downloaded=True) return if options['action'] == 'clear': self.clear(task.session) return if options['action'] == 'del': try: what = parse_what(options['what']) title = queue_del(title=what.get('title'), imdb_id=what.get('imdb_id'), tmdb_id=what.get('tmdb_id')) except QueueError as e: console('ERROR: %s' % e.message) else: console('Removed %s from queue' % title) return if options['action'] == 'forget': try: what = parse_what(options['what']) title = queue_forget(title=what.get('title'), imdb_id=what.get('imdb_id'), tmdb_id=what.get('tmdb_id')) except QueueError as e: console('ERROR: %s' % e.message) else: console( 'Forgot that %s was downloaded. Movie will be downloaded again.' % title) return if options['action'] == 'add': # Adding to queue requires a lookup for missing information what = {} try: what = parse_what(options['what']) except QueueError as e: console('ERROR: %s' % e.message) if not what.get('title') or not (what.get('imdb_id') or what.get('tmdb_id')): console('could not determine movie') # TODO: Rethink errors return try: added = queue_add(title=what['title'], imdb_id=what['imdb_id'], tmdb_id=what['tmdb_id'], quality=options['quality'], force=options['force']) except QueueError as e: console(e.message) if e.errno == 1: # This is an invalid quality error, display some more info # TODO: Fix this error? #console('Recognized qualities are %s' % ', '.join([qual.name for qual in qualities.all()])) console( 'ANY is the default and can also be used explicitly to specify that quality should be ignored.' ) except OperationalError: log.critical('OperationalError')
def on_process_start(self, task): """Handle --movie-queue management""" if not getattr(task.manager.options, 'movie_queue', False): return task.manager.disable_tasks() options = task.manager.options.movie_queue if options['action'] == 'list': self.queue_list(task.session) return # If the action was to do more than just list the series, make sure all entries are processed again next run. task.manager.config_changed() if options['action'] == 'downloaded': self.queue_list(task.session, downloaded=True) return if options['action'] == 'clear': self.clear(task.session) return if options['action'] == 'del': try: title = queue_del(options['what']) except QueueError as e: console(e.message) else: console('Removed %s from queue' % title) return if options['action'] == 'forget': try: title = queue_forget(options['what']) except QueueError as e: console(e.message) else: console('Marked %s as undownloaded' % title) return # Adding to queue requires a lookup for missing information try: what = parse_what(options['what']) options.update(what) except QueueError as e: console(e.message) if not options.get('title') or not (options.get('imdb_id') or options.get('tmdb_id')): console('could not determine movie') # TODO: Rethink errors return try: if options['action'] == 'add': try: added = queue_add(title=options['title'], imdb_id=options['imdb_id'], tmdb_id=options['tmdb_id'], quality=options['quality'], force=options['force']) except QueueError as e: console(e.message) if e.errno == 1: # This is an invalid quality error, display some more info # TODO: Fix this error? #console('Recognized qualities are %s' % ', '.join([qual.name for qual in qualities.all()])) console('ANY is the default and can also be used explicitly to specify that quality should be ignored.') else: console('Added %s to queue with quality %s' % (added['title'], added['quality'])) except OperationalError: log.critical('OperationalError')
def on_process_start(self, task): """Handle --movie-queue management""" if not getattr(task.manager.options, "movie_queue", False): return task.manager.disable_tasks() options = task.manager.options.movie_queue if options["action"] == "list": self.queue_list(task.session) return # If the action affects make sure all entries are processed again next run. task.manager.config_changed() if options["action"] == "downloaded": self.queue_list(task.session, downloaded=True) return if options["action"] == "clear": self.clear(task.session) return if options["action"] == "del": try: what = parse_what(options["what"]) title = queue_del(title=what.get("title"), imdb_id=what.get("imdb_id"), tmdb_id=what.get("tmdb_id")) except QueueError as e: console("ERROR: %s" % e.message) else: console("Removed %s from queue" % title) return if options["action"] == "forget": try: what = parse_what(options["what"]) title = queue_forget(title=what.get("title"), imdb_id=what.get("imdb_id"), tmdb_id=what.get("tmdb_id")) except QueueError as e: console("ERROR: %s" % e.message) else: console("Forgot that %s was downloaded. Movie will be downloaded again." % title) return if options["action"] == "add": # Adding to queue requires a lookup for missing information what = {} try: what = parse_what(options["what"]) except QueueError as e: console("ERROR: %s" % e.message) if not what.get("title") or not (what.get("imdb_id") or what.get("tmdb_id")): console("could not determine movie") # TODO: Rethink errors return try: added = queue_add( title=what["title"], imdb_id=what["imdb_id"], tmdb_id=what["tmdb_id"], quality=options["quality"], force=options["force"], ) except QueueError as e: console(e.message) if e.errno == 1: # This is an invalid quality error, display some more info # TODO: Fix this error? # console('Recognized qualities are %s' % ', '.join([qual.name for qual in qualities.all()])) console( "ANY is the default and can also be used explicitly to specify that quality should be ignored." ) except OperationalError: log.critical("OperationalError")
def do_cli(manager, options): """Handle movie-queue subcommand""" if options.queue_action == "list": queue_list(options) return # If the action affects make sure all entries are processed again next run. manager.config_changed() if options.queue_action == "clear": clear(options) return if options.queue_action == "del": try: what = parse_what(options.movie_name, lookup=False) title = queue_del(queue_name=options.queue_name, **what) except QueueError as e: console("ERROR: %s" % e.message) else: console("Removed %s from queue" % title) return if options.queue_action == "forget": try: what = parse_what(options.movie_name, lookup=False) title = queue_forget(queue_name=options.queue_name, **what) except QueueError as e: console("ERROR: %s" % e.message) else: console("Forgot that %s was downloaded. Movie will be downloaded again." % title.get("title")) return if options.queue_action == "add": try: quality = qualities.Requirements(options.quality) except ValueError as e: console("`%s` is an invalid quality requirement string: %s" % (options.quality, e.message)) return # Adding to queue requires a lookup for missing information what = {} try: what = parse_what(options.movie_name) except QueueError as e: console("ERROR: %s" % e.message) if not what.get("title") or not (what.get("imdb_id") or what.get("tmdb_id")): console("could not determine movie") # TODO: Rethink errors return try: queue_add(quality=quality, queue_name=options.queue_name, **what) except QueueError as e: console(e.message) if e.errno == 1: # This is an invalid quality error, display some more info # TODO: Fix this error? # console('Recognized qualities are %s' % ', '.join([qual.name for qual in qualities.all()])) console("ANY is the default and can also be used explicitly to specify that quality should be ignored.") except OperationalError: console("OperationalError") return
def del_from_queue(): imdb_id = request.values.get('imdb_id') try: title = queue_del(imdb_id) except QueueError, e: flash(e.message, 'error')
def do_cli(manager, options): """Handle movie-queue subcommand""" console('WARNING!: movie_queue plugin is deprecated. Please switch to using movie_list\n') if options.queue_action == 'list': queue_list(options) return # If the action affects make sure all entries are processed again next run. manager.config_changed() if options.queue_action == 'clear': clear(options) return if options.queue_action == 'del': try: what = parse_what(options.movie_name, lookup=False) title = queue_del(queue_name=options.queue_name, **what) except QueueError as e: console('ERROR: %s' % e.message) else: console('Removed %s from queue' % title) return if options.queue_action == 'forget': try: what = parse_what(options.movie_name, lookup=False) title = queue_forget(queue_name=options.queue_name, **what) except QueueError as e: console('ERROR: %s' % e.message) else: console('Forgot that %s was downloaded. Movie will be downloaded again.' % title.get('title')) return if options.queue_action == 'add': try: quality = qualities.Requirements(options.quality) except ValueError as e: console('`%s` is an invalid quality requirement string: %s' % (options.quality, e.message)) return # Adding to queue requires a lookup for missing information what = {} try: what = parse_what(options.movie_name) except QueueError as e: console('ERROR: %s' % e.message) if not what.get('title') or not (what.get('imdb_id') or what.get('tmdb_id')): console('could not determine movie') # TODO: Rethink errors return try: queue_add(quality=quality, queue_name=options.queue_name, **what) except QueueError as e: console(e.message) if e.errno == 1: # This is an invalid quality error, display some more info # TODO: Fix this error? # console('Recognized qualities are %s' % ', '.join([qual.name for qual in qualities.all()])) console('ANY is the default and can also be used explicitly to specify that quality should be ignored.') except OperationalError: console('OperationalError') return