mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-04 15:12:23 -05:00
Fixed traktAPI to properly do GET and POST request methods based on API call
This commit is contained in:
parent
cac4af0ed7
commit
1b45caaf7f
@ -13,17 +13,15 @@ class TraktAPI():
|
||||
self.timeout = timeout
|
||||
|
||||
def validateAccount(self):
|
||||
return self.traktRequest("account/test/%APIKEY%")
|
||||
return self.traktRequest("account/test/%APIKEY%", method='POST')
|
||||
|
||||
def traktRequest(self, url, data=None):
|
||||
def traktRequest(self, url, data=None, method='GET'):
|
||||
base_url = self.protocol + 'api.trakt.tv/%s' % url.replace('%APIKEY%', self.apikey).replace('%USER%',
|
||||
self.username)
|
||||
|
||||
# request the URL from trakt and parse the result as json
|
||||
try:
|
||||
resp = requests.get(base_url,
|
||||
auth=HTTPBasicAuth(self.username, self.password),
|
||||
data=data if data else [])
|
||||
resp = requests.request(method, base_url, auth=HTTPBasicAuth(self.username, self.password), data=data if data else [])
|
||||
|
||||
# check for http errors and raise if any are present
|
||||
resp.raise_for_status()
|
||||
|
@ -65,11 +65,11 @@ class TraktNotifier:
|
||||
data[trakt_id] = ep_obj.show.indexerid
|
||||
|
||||
# update library
|
||||
trakt_api.traktRequest("show/episode/library/%APIKEY%", data)
|
||||
trakt_api.traktRequest("show/episode/library/%APIKEY%", data, method='POST')
|
||||
|
||||
# remove from watchlist
|
||||
if sickbeard.TRAKT_REMOVE_WATCHLIST:
|
||||
trakt_api.traktRequest("show/episode/unwatchlist/%APIKEY%", data)
|
||||
trakt_api.traktRequest("show/episode/unwatchlist/%APIKEY%", data, method='POST')
|
||||
|
||||
if sickbeard.TRAKT_REMOVE_SERIESLIST:
|
||||
data = {
|
||||
@ -84,7 +84,7 @@ class TraktNotifier:
|
||||
if trakt_id == 'tvdb_id':
|
||||
data['shows'][0][trakt_id] = ep_obj.show.indexerid
|
||||
|
||||
trakt_api.traktRequest("show/unwatchlist/%APIKEY%", data)
|
||||
trakt_api.traktRequest("show/unwatchlist/%APIKEY%", data, method='POST')
|
||||
|
||||
# Remove all episodes from episode watchlist
|
||||
# Start by getting all episodes in the watchlist
|
||||
@ -105,7 +105,7 @@ class TraktNotifier:
|
||||
ep = {'season': episodes['season'], 'episode': episodes['number']}
|
||||
data_show['episodes'].append(ep)
|
||||
|
||||
trakt_api.traktRequest("show/episode/unwatchlist/%APIKEY%", data_show)
|
||||
trakt_api.traktRequest("show/episode/unwatchlist/%APIKEY%", data_show, method='POST')
|
||||
except (traktException, traktAuthException, traktServerBusy) as e:
|
||||
logger.log(u"Could not connect to Trakt service: %s" % ex(e), logger.WARNING)
|
||||
|
||||
|
@ -90,7 +90,7 @@ class TraktChecker():
|
||||
|
||||
logger.log(u"Removing " + show_obj.name + " from trakt.tv library", logger.DEBUG)
|
||||
try:
|
||||
self.trakt_api.traktRequest("show/unlibrary/%APIKEY%", data)
|
||||
self.trakt_api.traktRequest("show/unlibrary/%APIKEY%", data, method='POST')
|
||||
except (traktException, traktAuthException, traktServerBusy) as e:
|
||||
logger.log(u"Could not connect to Trakt service: %s" % ex(e), logger.WARNING)
|
||||
pass
|
||||
@ -114,7 +114,7 @@ class TraktChecker():
|
||||
logger.log(u"Adding " + show_obj.name + " to trakt.tv library", logger.DEBUG)
|
||||
|
||||
try:
|
||||
self.trakt_api.traktRequest("show/library/%APIKEY%", data)
|
||||
self.trakt_api.traktRequest("show/library/%APIKEY%", data, method='POST')
|
||||
except (traktException, traktAuthException, traktServerBusy) as e:
|
||||
logger.log(u"Could not connect to Trakt service: %s" % ex(e), logger.WARNING)
|
||||
return
|
||||
|
@ -2204,7 +2204,7 @@ class HomeAddShows(Home):
|
||||
trakt_api = TraktAPI(sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD)
|
||||
|
||||
try:
|
||||
recommendedlist = trakt_api.traktRequest("recommendations/shows.json/%APIKEY%")
|
||||
recommendedlist = trakt_api.traktRequest("recommendations/shows.json/%APIKEY%", method='POST')
|
||||
|
||||
if recommendedlist:
|
||||
indexers = ['tvdb_id', 'tvrage_id']
|
||||
|
Loading…
Reference in New Issue
Block a user