def _get_categories(self, sub_type, data): """ Retrieve a list of possible categories with category ids. Using the default url/api?cat http://yournewznaburl.com/api?t=caps&apikey=yourapikey """ if not data.get('name'): return self._bad_request('No provider name provided') if not data.get('url'): return self._bad_request('No provider url provided') if not data.get('apikey'): return self._bad_request('No provider api key provided') if sub_type == 'newznab': provider = NewznabProvider(data.get('name'), data.get('url'), data.get('apikey')) elif sub_type == 'torznab': provider = TorznabProvider(data.get('name'), data.get('url'), data.get('apikey')) capabilities = provider.get_capabilities() return self._created(data={'result': capabilities._asdict()})
def getZnabCategories(kind, name, url, api_key): """ Retrieve a list of possible categories with category ids. Using the default url/api?cat http://yournewznaburl.com/api?t=caps&apikey=yourapikey """ error = '' if not name: error += '\nNo Provider Name specified' if not url: error += '\nNo Provider Url specified' if not api_key: error += '\nNo Provider Api key specified' if error != '': return json.dumps({'success': False, 'message': error}) if kind == 'newznab': temp_provider = NewznabProvider(name, url, api_key) elif kind == 'torznab': temp_provider = TorznabProvider(name, url, api_key) capabilities = temp_provider.get_capabilities() return json.dumps(capabilities._asdict())
def getZnabCategories(kind, name, url, api_key): """ Retrieve a list of possible categories with category ids. Using the default url/api?cat http://yournewznaburl.com/api?t=caps&apikey=yourapikey """ error = '' if not name: error += '\nNo Provider Name specified' if not url: error += '\nNo Provider Url specified' if not api_key: error += '\nNo Provider Api key specified' if error != '': return json.dumps({'success': False, 'message': error}) if kind == 'newznab': temp_provider = NewznabProvider(name, url, api_key) elif kind == 'torznab': temp_provider = TorznabProvider(name, url, api_key) capabilities = temp_provider.get_capabilities() return json.dumps(capabilities._asdict())