How to use FlexGet - 10 common examples

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 / tests / test_secrets.py View on Github external
def test_secret_from_db(self, execute_task, manager):
        with Session() as session:
            s = Secrets(secrets={'test_secret_db': True})
            session.add(s)

        fire_event('manager.before_config_validate', manager.config, manager)

        task = execute_task('test_secret_from_db')
        assert len(task.accepted) == 1
github Flexget / Flexget / tests / test_emit_series.py View on Github external
def inject_series(self, execute_task, release_name):
        execute_task('inject_series', options={'inject': [Entry(title=release_name, url='')], 'disable_tracking': True})
github Flexget / Flexget / tests / test_series_list_api.py View on Github external
assert json.loads(rsp.get_data(as_text=True)).get('title') == 'test_series_2'

        new_data = {'quality': '720p',
                    'qualities': ['720p', '1080p'],
                    'timeframe': '2 days',
                    'upgrade': True,
                    'target': '1080p',
                    'propers': True,
                    'specials': True,
                    'tracking': False,
                    'exact': True,
                    'begin': 's01e01',
                    'from_group': ['group1', 'group2'],
                    'parse_only': True}

        rsp = api_client.json_put('/series_list/1/', data=json.dumps(new_data))
        assert rsp.status_code == 200, 'Response code is %s' % rsp.status_code

        rsp = api_client.get('/series_list/1/series/')
        assert rsp.status_code == 200, 'Response code is %s' % rsp.status_code
        response = json.loads(rsp.get_data(as_text=True))
        assert len(response.get('series')) == 2

        for series in response.get('series'):
            for attribute in new_data:
                assert series[attribute] == new_data[attribute]
github Flexget / Flexget / tests / test_secrets.py View on Github external
def test_secrets_put(self, api_client):
        rsp = api_client.get('/secrets/')
        assert rsp.status_code == 200, 'Response code is %s' % rsp.status_code
        assert json.loads(rsp.get_data(as_text=True)) == {}

        rsp = api_client.json_put('/secrets/', data=json.dumps(self.secrets_dict))
        assert rsp.status_code == 201, 'Response code is %s' % rsp.status_code
        assert json.loads(rsp.get_data(as_text=True)) == self.secrets_dict

        rsp = api_client.get('/secrets/')
        assert rsp.status_code == 200, 'Response code is %s' % rsp.status_code
        assert json.loads(rsp.get_data(as_text=True)) == self.secrets_dict
github Flexget / Flexget / tests / test_utils.py View on Github external
def test_json_encode_dt(self):
        date_str = '2016-03-11T17:12:17Z'
        dt = datetime.strptime(date_str, '%Y-%m-%dT%H:%M:%SZ')
        encoded_dt = json.dumps(dt, encode_datetime=True)
        assert encoded_dt == '"%s"' % date_str
github Flexget / Flexget / tests / test_pluginapi.py View on Github external
def test_unknown_plugin(self):
        with pytest.raises(plugin.DependencyError):
            plugin.get_plugin_by_name('nonexisting_plugin')
github Flexget / Flexget / tests / test_urlrewriting.py View on Github external
def get_urlrewriter(self, name):
        info = get_plugin_by_name(name)
        return info.instance
github Flexget / Flexget / flexget / plugins / metainfo / imdb_lookup.py View on Github external
# search and store to cache
        if 'title' in entry:
            log.verbose('Parsing imdb for `%s`' % entry['title'])
        else:
            log.verbose('Parsing imdb for `%s`' % entry['imdb_id'])
        try:
            movie = self._parse_new_movie(entry['imdb_url'], session)
        except UnicodeDecodeError:
            log.error('Unable to determine encoding for %s. Installing chardet library may help.' %
                      entry['imdb_url'])
            # store cache so this will not be tried again
            movie = Movie()
            movie.url = entry['imdb_url']
            session.add(movie)
            session.commit()
            raise plugin.PluginError('UnicodeDecodeError')
        except ValueError as e:
            # TODO: might be a little too broad catch, what was this for anyway? ;P
            if manager.options.debug:
                log.exception(e)
            raise plugin.PluginError('Invalid parameter: %s' % entry['imdb_url'], log)

        for att in ['title', 'score', 'votes', 'meta_score', 'year', 'genres', 'languages', 'actors', 'directors', 'writers',
                    'mpaa_rating']:
            log.trace('movie.%s: %s' % (att, getattr(movie, att)))

        # Update the entry fields
        entry.update_using_map(self.field_map, movie)
github Flexget / Flexget / flexget / plugins / filter / imdb_queue.py View on Github external
def queue_add(self, title=None, imdb_id=None, quality='ANY', force=True):
        """Add an item to the queue with the specified quality"""

        if not title or not imdb_id:
            # We don't have all the info we need to add movie, do a lookup for more info
            result = self.parse_what(imdb_id or title)
            title = result['title']
            imdb_id = result['imdb_id']
        quality = self.validate_quality(quality)

        session = Session()

        # check if the item is already queued
        item = session.query(ImdbQueue).filter(ImdbQueue.imdb_id == imdb_id).first()
        if not item:
            item = ImdbQueue(imdb_id, quality, force)
            item.title = title
            session.add(item)
            session.commit()
            return {'title': title, 'imdb_id': imdb_id, 'quality': quality, 'force': force}
        else:
            raise QueueError('ERROR: %s is already in the queue' % title)