Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_unknown_plugin(self):
with pytest.raises(plugin.DependencyError):
plugin.get_plugin_by_name('nonexisting_plugin')
import logging
from flexget import plugin
from flexget.entry import Entry
from flexget.event import event
from flexget.utils.cached_input import cached
try:
# NOTE: Importing other plugins is discouraged!
from flexget.plugins.internal import api_rottentomatoes as plugin_api_rottentomatoes
except ImportError:
raise plugin.DependencyError(issued_by=__name__, missing='api_rottentomatoes')
log = logging.getLogger('rottentomatoes_list')
class RottenTomatoesList:
"""
Emits an entry for each movie in a Rotten Tomatoes list.
Configuration:
dvds:
- top_rentals
- upcoming
movies:
- box_office
from loguru import logger
from flexget import plugin
from flexget.event import event
try:
# NOTE: Importing other plugins is discouraged!
from flexget.components.parsing.parsers import parser_common as plugin_parser_common
except ImportError:
raise plugin.DependencyError(issued_by=__name__, missing='parser_common')
logger = logger.bind(name='metainfo_movie')
class MetainfoMovie:
"""
Check if entry appears to be a movie, and populate movie info if so.
"""
schema = {'type': 'boolean'}
def on_task_metainfo(self, task, config):
# Don't run if we are disabled
if config is False:
return
for entry in task.entries:
from functools import partial
from loguru import logger
from flexget import plugin
from flexget.event import event
from flexget.manager import Session
from flexget.utils.log import log_once
try:
# NOTE: Importing other plugins is discouraged!
from flexget.components.imdb.utils import extract_id
except ImportError:
raise plugin.DependencyError(issued_by=__name__, missing='imdb')
logger = logger.bind(name='tmdb_lookup')
class PluginTmdbLookup:
"""Retrieves tmdb information for entries.
Example:
tmdb_lookup: yes
"""
field_map = {
'tmdb_name': 'name',
'tmdb_id': 'id',
'imdb_id': 'imdb_id',
def on_task_start(self, task, config):
"""Raise a DependencyError if our dependencies aren't available"""
try:
from deluge.ui.client import client # noqa
except ImportError as e:
log.debug('Error importing deluge: %s' % e)
raise plugin.DependencyError('deluge', 'deluge',
'Deluge >=1.2 module and it\'s dependencies required. ImportError: %s' % e,
log)
try:
from twisted.internet import reactor # noqa
except:
raise plugin.DependencyError('deluge', 'twisted.internet', 'Twisted.internet package required', log)
from sqlalchemy import func
from sqlalchemy.sql.elements import and_
from flexget import plugin
from flexget.db_schema import with_session
from flexget.event import event
from flexget.manager import Session
from flexget.utils.tools import split_title_year
from . import db
try:
# NOTE: Importing other plugins is discouraged!
from flexget.components.parsing.parsers import parser_common as plugin_parser_common
except ImportError:
raise plugin.DependencyError(issued_by=__name__, missing='parser_common')
log = logging.getLogger('movie_list')
class MovieListBase:
"""
Class that contains helper methods for movie list as well as plugins that use it,
such as API and CLI.
"""
@property
def supported_ids(self):
# Return a list of supported series identifier as registered via their plugins
return [
p.instance.movie_identifier for p in plugin.get_plugins(interface='movie_metainfo')
]
def on_task_output(self, task, config):
"""Task handler for rar_extract"""
if isinstance(config, bool) and not config:
return
# Fail if rarfile is missing
if not rarfile:
raise plugin.DependencyError(issued_by='rar_extract',
missing='rarfile',
message='rarfile plugin requires the rarfile Python\
module.')
config = self.prepare_config(config)
# Set the path of the unrar tool if it's not specified in PATH
unrar_tool = config['unrar_tool']
if unrar_tool:
rarfile.UNRAR_TOOL = unrar_tool
log.debug('Set RarFile.unrar_tool to: %s' % unrar_tool)
for entry in task.accepted:
self.handle_entry(entry, config)
import logging
from functools import partial
from flexget import plugin
from flexget.event import event
from flexget.utils.database import with_session
try:
# NOTE: Importing other plugins is discouraged!
from flexget.components.thetvdb import api_tvdb as plugin_api_tvdb
except ImportError:
raise plugin.DependencyError(issued_by=__name__, missing='api_tvdb')
log = logging.getLogger('thetvdb_lookup')
class PluginThetvdbLookup:
"""Retrieves TheTVDB information for entries. Uses series_name,
series_season, series_episode from series plugin.
Example:
thetvdb_lookup: yes
Primarily used for passing thetvdb information to other plugins.
Among these is the IMDB url for the series.
This information is provided (via entry):
from __future__ import unicode_literals, division, absolute_import
import argparse
from datetime import datetime, timedelta
from sqlalchemy import func
from flexget import options, plugin
from flexget.event import event
from flexget.logger import console
from flexget.manager import Session
try:
from flexget.plugins.filter.series import (Series, Episode, Release, SeriesTask, forget_series,
forget_series_episode, set_series_begin, normalize_series_name,
new_eps_after, get_latest_release)
except ImportError:
raise plugin.DependencyError(issued_by='cli_series', missing='series',
message='Series commandline interface not loaded')
def do_cli(manager, options):
if options.series_action == 'list':
display_summary(options)
elif options.series_action == 'show':
display_details(options.series_name)
elif options.series_action == 'forget':
forget(manager, options)
elif options.series_action == 'begin':
begin(manager, options)
def display_summary(options):
"""
from argparse import ArgumentParser
from sqlalchemy.exc import OperationalError
from flexget import options
from flexget.event import event
from flexget.logger import console
from flexget.plugin import DependencyError
from flexget.utils import qualities
try:
from flexget.plugins.filter.movie_queue import (QueueError, queue_add, queue_del, queue_get, queue_forget,
queue_clear, parse_what)
except ImportError:
raise DependencyError(issued_by='cli_movie_queue', missing='movie_queue')
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