Skip to content

Commit

Permalink
Changed: API keys are not mandatory for indexers. See #427
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and [email protected] committed Nov 26, 2016
1 parent d74e034 commit 8241bca
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 11 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Added: Show stats for a certain time span. See [#431](https://github.com/theothe

Added: Option to truncate database and log file. Requested by a user running the synology package where database and log files are not available easily.

Changed: API keys are not mandatory for indexers. Apparently there are som which don't require one or even throw an error when one is provided. Whatever. See [#427](https://github.com/theotherp/nzbhydra/issues/427)

Changed: Some indexers do support more search types or IDs than they say in their caps. So search capabilities of an indexer (searching by IMDB ID, TVDB ID, etc.) are now always determined by "brute force" instead of relying on the data provided in the caps. That means that the caps check will take a lot more time (up to 6 queries) but be more precise. See [#433](https://github.com/theotherp/nzbhydra/issues/433).

Fixed: Calls to /details/ would not use dereferer.
Expand Down
20 changes: 15 additions & 5 deletions nzbhydra/searchmodules/newznab.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ def test_connection(host, apikey):
logger.info("Testing connection for host %s" % host)
f = furl(host)
f.path.add("api")
f.query.add({"apikey": apikey, "t": "tvsearch"})
f.query.add({"t": "tvsearch"})
if apikey:
f.query.add({"apikey": apikey})
try:
headers = {
'User-Agent': config.settings.searching.userAgent
Expand Down Expand Up @@ -289,7 +291,9 @@ def check_caps(host, apikey, userAgent=None, timeout=None, skipIdsAndTypes=False
def _build_base_url(host, apikey, action, category, limit=None, offset=0):
f = furl(host)
f.path.add("api")
f.query.add({"apikey": apikey, "extended": 1, "t": action, "offset": offset})
f.query.add({"extended": 1, "t": action, "offset": offset})
if apikey:
f.query.add({"apikey": apikey})
if limit is not None:
f.query.add({"limit": limit})

Expand Down Expand Up @@ -461,7 +465,9 @@ def get_details_link(self, guid):
def get_entry_by_id(self, guid, title):
url = furl(self.settings.host)
url.path.add("api")
url.add({"apikey": self.settings.apikey, "t": "details", "o": "xml", "id": guid})
url.add({"t": "details", "o": "xml", "id": guid})
if self.settings.apikey:
url.add({"apikey": self.settings.apikey, "t": "details", "o": "xml", "id": guid})

response, papiaccess, _ = self.get_url_with_papi_access(url, "nfo")
if response is None:
Expand Down Expand Up @@ -619,7 +625,9 @@ def get_nfo(self, guid):
else:
logger.debug("Using t=getnfo for non-nzedb based indexer")
t = "getnfo"
url.add({"apikey": self.settings.apikey, "t": t, "o": "xml", "id": guid, "raw": "1"})
url.add({"t": t, "o": "xml", "id": guid, "raw": "1"})
if self.settings.apikey:
url.add({"apikey": self.settings.apikey})

response, papiaccess, _ = self.get_url_with_papi_access(url, "nfo")
if response is None:
Expand All @@ -644,7 +652,9 @@ def get_nfo(self, guid):
def get_nzb_link(self, guid, title):
f = furl(self.settings.host)
f.path.add("api")
f.add({"t": "get", "apikey": self.settings.apikey, "id": guid})
f.add({"t": "get", "id": guid})
if self.settings.apikey:
f.add({"apikey": self.settings.apikey})
return f.tostr()


Expand Down
6 changes: 3 additions & 3 deletions nzbhydra/webaccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ def getCleanProxyUrl(url):

def get(url, **kwargs):
global proxies
myproxies = proxies if proxies is not None and furl(url).host not in ["127.0.0.1", "localhost"] and "192.168" not in url else None
myproxies = proxies if proxies is not None and furl(url).host not in ["127.0.0.1", "localhost"] and "192.168" not in str(url) else None
return requests.get(url, proxies=myproxies, verify=False, **kwargs)


def post(url, **kwargs):
global proxies
myproxies = proxies if proxies is not None and furl(url).host not in ["127.0.0.1", "localhost"] and "192.168" not in url else None
return requests.post(url, proxies=myproxies if furl(url).host not in ["127.0.0.1", "localhost"] and "192.168" not in url else None, verify=False, **kwargs)
myproxies = proxies if proxies is not None and furl(url).host not in ["127.0.0.1", "localhost"] and "192.168" not in str(url) else None
return requests.post(url, proxies=myproxies, verify=False, **kwargs)
1 change: 0 additions & 1 deletion static/js/nzbhydra.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/js/nzbhydra.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion ui-src/js/config-fields-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,6 @@ function getIndexerBoxFields(model, parentModel, isInitial, injector) {
type: 'horizontalInput',
templateOptions: {
type: 'text',
required: true,
label: 'API Key'
},
watcher: {
Expand Down

0 comments on commit 8241bca

Please sign in to comment.