How to use the flexget.plugin function in FlexGet

To help you get started, we’ve selected a few FlexGet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Flexget / Flexget / tests / external_plugins / external_plugin.py View on Github external
def register_plugin():
    plugin.register(ExternalPlugin, 'external_plugin', api_ver=2)
github Flexget / Flexget / flexget / plugins / services / pogcal_acquired.py View on Github external
    @plugin.priority(plugin.PRIORITY_LAST)
    def on_task_output(self, task, config):
        if not task.accepted and not task.options.test:
            return
        try:
            result = session.post(
                'http://www.pogdesign.co.uk/cat/login',
                data={
                    'username': config['username'],
                    'password': config['password'],
                    'sub_login': 'Account Login',
                },
            )
        except requests.RequestException as e:
            log.error('Error logging in to pog calendar: %s' % e)
            return
        if 'logout' not in result.text:
github Flexget / Flexget / flexget / components / notify / notify.py View on Github external
def send_notification(self, *args, **kwargs):
        send_notification = plugin.get('notification_framework', 'notify').send_notification
        try:
            send_notification(*args, **kwargs)
        except plugin.PluginError as e:
            log.error(e)
        except plugin.PluginWarning as e:
            log.warning(e)
        except Exception as e:
            log.exception(e)
github Flexget / Flexget / flexget / plugins / urlrewrite_isohunt.py View on Github external
entries = set()
        search_strings = [normalize_unicode(s) for s in entry.get('search_strings', [entry['title']])]
        for search_string in search_strings:
            url = 'http://isohunt.com/js/rss/%s?iht=%s&noSL' % (
                urllib.quote(search_string.encode('utf-8')), optionlist.index(config))

            log.debug('requesting: %s' % url)
            rss = feedparser.parse(url)

            status = rss.get('status', False)
            if status != 200:
                raise plugin.PluginWarning('Search result not 200 (OK), received %s' % status)

            ex = rss.get('bozo_exception', False)
            if ex:
                raise plugin.PluginWarning('Got bozo_exception (bad feed)')

            for item in rss.entries:
                entry = Entry()
                entry['title'] = item.title
                entry['url'] = item.link

                m = re.search(r'Size: ([\d]+).*Seeds: (\d+).*Leechers: (\d+)', item.description, re.IGNORECASE)
                if not m:
                    log.debug('regexp did not find seeds / peer data')
                    continue
                else:
                    log.debug('regexp found size(%s), Seeds(%s) and Leeches(%s)' % (m.group(1), m.group(2), m.group(3)))

                    entry['content_size'] = int(m.group(1))
                    entry['torrent_seeds'] = int(m.group(2))
                    entry['torrent_leeches'] = int(m.group(3))
github Flexget / Flexget / flexget / plugins / clients / deluge.py View on Github external
    @plugin.priority(135)
    def on_task_output(self, task, config):
        """Add torrents to deluge at exit."""
        config = self.prepare_config(config)
        # don't add when learning
        if task.options.learn:
            return
        if not config['enabled'] or not (task.accepted or task.options.test):
            return

        self.connect(task, config)
        # Clean up temp file if download plugin is not configured for this task
        if 'download' not in task.config:
            for entry in task.accepted + task.failed:
                if os.path.exists(entry.get('file', '')):
                    os.remove(entry['file'])
                    del (entry['file'])
github Flexget / Flexget / flexget / plugins / operate / disable.py View on Github external
def all_builtins():
    """Helper function to return an iterator over all builtin plugins."""
    return (p for p in plugin.plugins.values() if p.builtin)
github Flexget / Flexget / flexget / plugins / sites / site_1337x.py View on Github external
    @plugin.internet(log)
    def search(self, task, entry, config):
        """
            Search for entries on 1337x
        """

        if not isinstance(config, dict):
            config = {}

        order_by = ''
        sort_order = ''
        if isinstance(config.get('order_by'), str):
            if config['order_by'] != 'leechers':
                order_by = '/{0}/desc'.format(config['order_by'])
                sort_order = 'sort-'

        entries = set()
github Flexget / Flexget / flexget / plugins / modify / path_by_space.py View on Github external
    @plugin.priority(250)  # run before other plugins
    def on_task_metainfo(self, task, config):
        selector = selector_map[config['select']]

        # Convert within to bytes (int) or percent (float)
        within = config.get('within')
        if isinstance(within, str) and '%' in within:
            within = parse_percent(within)
        else:
            within = parse_size(within)

        path = selector(config['paths'], within=within)

        if path:
            log.debug('Path %s selected due to (%s)' % (path, config['select']))

            for entry in task.all_entries:
github Flexget / Flexget / flexget / plugins / filter / list_reject.py View on Github external
def on_task_filter(self, task, config):
        for item in config:
            for plugin_name, plugin_config in item.items():
                try:
                    thelist = plugin.get_plugin_by_name(plugin_name).instance.get_list(plugin_config)
                except AttributeError:
                    raise PluginError('Plugin %s does not support list interface' % plugin_name)
                for entry in task.entries:
                    if entry in thelist:
                        entry.reject()
github Flexget / Flexget / flexget / components / estimate_release / estimators / est_movies_bluray.py View on Github external
    @plugin.priority(2)
    def estimate(self, entry):
        if 'movie_name' not in entry:
            return

        movie_name = entry['movie_name']
        movie_year = entry.get('movie_year')

        if movie_year is not None and movie_year > datetime.datetime.now().year:
            logger.debug('Skipping Blu-ray.com lookup since movie year is {}', movie_year)
            return

        logger.debug('Searching Blu-ray.com for release date of {} ({})', movie_name, movie_year)

        release_date = None
        try:
            with Session() as session: