1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-08-13 16:53:54 -04: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
indexerConfig[INDEXER_TVDB]['trakt_id'] = 'tvdb_id'
indexerConfig[INDEXER_TVDB]['xem_origin'] = 'tvdb'
indexerConfig[INDEXER_TVDB]['icon'] = 'thetvdb16.png'
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']
# TVRAGE Indexer Settings
indexerConfig[INDEXER_TVRAGE]['trakt_id'] = 'tvrage_id'
indexerConfig[INDEXER_TVRAGE]['xem_origin'] = 'rage'
indexerConfig[INDEXER_TVRAGE]['icon'] = 'tvrage16.png'
indexerConfig[INDEXER_TVRAGE]['scene_url'] = 'https://raw.githubusercontent.com/echel0n/sb_tvrage_scene_exceptions/master/exceptions.txt'

View File

@ -34,7 +34,7 @@ class TraktNotifier:
def notify_subtitle_download(self, ep_name, lang):
pass
def notify_git_update(self, new_version):
pass
@ -45,11 +45,11 @@ class TraktNotifier:
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
data = {
'tvdb_id': ep_obj.show.indexerid,
'title': ep_obj.show.name,
'year': ep_obj.show.startyear,
'episodes': [{
@ -58,48 +58,53 @@ class TraktNotifier:
}]
}
if data is not None:
TraktCall("show/episode/library/%API%", self._api(), self._username(), self._password(), data)
if sickbeard.TRAKT_REMOVE_WATCHLIST:
TraktCall("show/episode/unwatchlist/%API%", self._api(), self._username(), self._password(), data)
if trakt_id == 'tvdb_id':
data[trakt_id] = ep_obj.show.indexerid
if sickbeard.TRAKT_REMOVE_SERIESLIST:
data_show = None
# update library
TraktCall("show/episode/library/%API%", self._api(), self._username(), self._password(), data)
# URL parameters, should not need to recheck data (done above)
data = {
'shows': [
{
'tvdb_id': ep_obj.show.indexerid,
'title': ep_obj.show.name,
'year': ep_obj.show.startyear
}
]
}
TraktCall("show/unwatchlist/%API%", self._api(), self._username(), self._password(), data)
# remove from watchlist
if sickbeard.TRAKT_REMOVE_WATCHLIST:
TraktCall("show/episode/unwatchlist/%API%", self._api(), self._username(), self._password(), data)
# Remove all episodes from episode 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)
if sickbeard.TRAKT_REMOVE_SERIESLIST:
data = {
'shows': [
{
'title': ep_obj.show.name,
'year': ep_obj.show.startyear
}
]
}
# Convert watchlist to only contain current show
if trakt_id == 'tvdb_id':
data['shows'][trakt_id] = ep_obj.show.indexerid
TraktCall("show/unwatchlist/%API%", self._api(), self._username(), self._password(), data)
# Remove all episodes from episode 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)
# Convert watchlist to only contain current show
if watchlist:
for show in watchlist:
# Check if tvdb_id exists
if 'tvdb_id' in show:
if unicode(data['shows'][0]['tvdb_id']) == show['tvdb_id']:
data_show = {
'title': show['title'],
'tvdb_id': show['tvdb_id'],
'episodes': []
}
# Add series and episode (number) to the arry
for episodes in show['episodes']:
ep = {'season': episodes['season'], 'episode': episodes['number']}
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)
if show[trakt_id] == ep_obj.show.indexerid:
data_show = {
'title': show['title'],
trakt_id: show[trakt_id],
'episodes': []
}
# Add series and episode (number) to the array
for episodes in show['episodes']:
ep = {'season': episodes['season'], 'episode': episodes['number']}
data_show['episodes'].append(ep)
TraktCall("show/episode/unwatchlist/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME,
sickbeard.TRAKT_PASSWORD, data_show)
def test_notify(self, api, username, password):
"""