cohena/pygazelle — pull request #9 by MrStaticVoid (2014-10-24 20:07:06+00:00)
Title: Fix 'search_torrents' failure under recent version of Gazelle

Some time ago, the 'browse' API call under Gazelle was changed to not
include detailed torrent group and torrent information unless it was
coming from the web search form. This broke pygazelle's
'search_torrents' function, as it tried to fill out torrent objects with
JSON data that simply wasn't there:

>>> gazelle.search_torrents(artistname="65daysofstatic")
{'torrentId': 31697196, 'groupId': 164662}
Traceback (most recent call last):
File "", line 1, in
File "/app/headphones/lib/pygazelle/api.py", line 401, in search_torrents
torrent.set_torrent_search_data(torrent_dict)
File "/app/headphones/lib/pygazelle/torrent.py", line 139, in set_torrent_search_data
self.remastered = search_torrent_json_response['remastered']
KeyError: 'remastered'

This change adds the undocumented 'search_submit' and 'groupresults'
parameters to the 'browse' API call to force Gazelle to return full
torrent data in the results, as it used to. The two parameters can be
seen in the Gazelle source code somewhere around line 58 of 'browse.php'
at the current time:

https://github.com/WhatCD/Gazelle/blob/master/sections/ajax/browse.php#L58

The other option instead of this change is to make individual calls to
'torrentgroup' or 'torrent' for each result returned by 'browse', but
you quickly hit up against the rate limit that way, causing the
'search_torrents' function to take minutes to return in some cases.