1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-13 11:32:20 -05:00

Fix for issue #891 - Trakt was failing when trying to update watchlist.

Trakt watchlist now tvdb and tvrage compatible.
Added 'trakt_id' constant to IndexerAPI configs module.
This commit is contained in:
echel0n 2014-11-24 02:59:39 -08:00
parent e3500fffc1
commit 31a9d96f6c
2 changed files with 47 additions and 40 deletions

View File

@ -37,6 +37,7 @@ indexerConfig[INDEXER_TVRAGE] = {
} }
# TVDB Indexer Settings # TVDB Indexer Settings
indexerConfig[INDEXER_TVDB]['trakt_id'] = 'tvdb_id'
indexerConfig[INDEXER_TVDB]['xem_origin'] = 'tvdb' indexerConfig[INDEXER_TVDB]['xem_origin'] = 'tvdb'
indexerConfig[INDEXER_TVDB]['icon'] = 'thetvdb16.png' indexerConfig[INDEXER_TVDB]['icon'] = 'thetvdb16.png'
indexerConfig[INDEXER_TVDB]['scene_url'] = 'http://midgetspy.github.io/sb_tvdb_scene_exceptions/exceptions.txt' indexerConfig[INDEXER_TVDB]['scene_url'] = 'http://midgetspy.github.io/sb_tvdb_scene_exceptions/exceptions.txt'
@ -44,6 +45,7 @@ indexerConfig[INDEXER_TVDB]['show_url'] = 'http://thetvdb.com/?tab=series&id='
indexerConfig[INDEXER_TVDB]['base_url'] = 'http://thetvdb.com/api/%(apikey)s/series/' % indexerConfig[INDEXER_TVDB]['api_params'] indexerConfig[INDEXER_TVDB]['base_url'] = 'http://thetvdb.com/api/%(apikey)s/series/' % indexerConfig[INDEXER_TVDB]['api_params']
# TVRAGE Indexer Settings # TVRAGE Indexer Settings
indexerConfig[INDEXER_TVRAGE]['trakt_id'] = 'tvrage_id'
indexerConfig[INDEXER_TVRAGE]['xem_origin'] = 'rage' indexerConfig[INDEXER_TVRAGE]['xem_origin'] = 'rage'
indexerConfig[INDEXER_TVRAGE]['icon'] = 'tvrage16.png' indexerConfig[INDEXER_TVRAGE]['icon'] = 'tvrage16.png'
indexerConfig[INDEXER_TVRAGE]['scene_url'] = 'https://raw.githubusercontent.com/echel0n/sb_tvrage_scene_exceptions/master/exceptions.txt' indexerConfig[INDEXER_TVRAGE]['scene_url'] = 'https://raw.githubusercontent.com/echel0n/sb_tvrage_scene_exceptions/master/exceptions.txt'

View File

@ -45,11 +45,11 @@ class TraktNotifier:
ep_obj: The TVEpisode object to add to trakt ep_obj: The TVEpisode object to add to trakt
""" """
if sickbeard.USE_TRAKT: trakt_id = sickbeard.indexerApi(ep_obj.show.indexer).config['trakt_id']
if sickbeard.USE_TRAKT:
# URL parameters # URL parameters
data = { data = {
'tvdb_id': ep_obj.show.indexerid,
'title': ep_obj.show.name, 'title': ep_obj.show.name,
'year': ep_obj.show.startyear, 'year': ep_obj.show.startyear,
'episodes': [{ 'episodes': [{
@ -58,48 +58,53 @@ class TraktNotifier:
}] }]
} }
if data is not None: if trakt_id == 'tvdb_id':
data[trakt_id] = ep_obj.show.indexerid
# update library
TraktCall("show/episode/library/%API%", self._api(), self._username(), self._password(), data) TraktCall("show/episode/library/%API%", self._api(), self._username(), self._password(), data)
# remove from watchlist
if sickbeard.TRAKT_REMOVE_WATCHLIST: if sickbeard.TRAKT_REMOVE_WATCHLIST:
TraktCall("show/episode/unwatchlist/%API%", self._api(), self._username(), self._password(), data) TraktCall("show/episode/unwatchlist/%API%", self._api(), self._username(), self._password(), data)
if sickbeard.TRAKT_REMOVE_SERIESLIST: if sickbeard.TRAKT_REMOVE_SERIESLIST:
data_show = None
# URL parameters, should not need to recheck data (done above)
data = { data = {
'shows': [ 'shows': [
{ {
'tvdb_id': ep_obj.show.indexerid,
'title': ep_obj.show.name, 'title': ep_obj.show.name,
'year': ep_obj.show.startyear 'year': ep_obj.show.startyear
} }
] ]
} }
if trakt_id == 'tvdb_id':
data['shows'][trakt_id] = ep_obj.show.indexerid
TraktCall("show/unwatchlist/%API%", self._api(), self._username(), self._password(), data) TraktCall("show/unwatchlist/%API%", self._api(), self._username(), self._password(), data)
# Remove all episodes from episode watchlist # Remove all episodes from episode watchlist
# Start by getting all episodes in the watchlist # Start by getting all episodes in the watchlist
watchlist = TraktCall("user/watchlist/episodes.json/%API%/" + sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD) watchlist = TraktCall("user/watchlist/episodes.json/%API%/" + sickbeard.TRAKT_USERNAME,
sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD)
# Convert watchlist to only contain current show # Convert watchlist to only contain current show
if watchlist:
for show in watchlist: for show in watchlist:
# Check if tvdb_id exists if show[trakt_id] == ep_obj.show.indexerid:
if 'tvdb_id' in show:
if unicode(data['shows'][0]['tvdb_id']) == show['tvdb_id']:
data_show = { data_show = {
'title': show['title'], 'title': show['title'],
'tvdb_id': show['tvdb_id'], trakt_id: show[trakt_id],
'episodes': [] 'episodes': []
} }
# Add series and episode (number) to the arry # Add series and episode (number) to the array
for episodes in show['episodes']: for episodes in show['episodes']:
ep = {'season': episodes['season'], 'episode': episodes['number']} ep = {'season': episodes['season'], 'episode': episodes['number']}
data_show['episodes'].append(ep) data_show['episodes'].append(ep)
if data_show is not None:
TraktCall("show/episode/unwatchlist/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD, data_show) TraktCall("show/episode/unwatchlist/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME,
sickbeard.TRAKT_PASSWORD, data_show)
def test_notify(self, api, username, password): def test_notify(self, api, username, password):
""" """