mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-11 05:33:37 +00:00
d3a7f0ff5e
Add newznab smart logic to avoid missing releases when there are a great many recent releases. Change improve performance by using newznab server advertised capabilities. Change config/providers newznab to display only non-default categories. Change use scene season for wanted segment in backlog if show is scene numbering. Change combine Manage Searches / Backlog Search / Limited and Full to Force. Change consolidate limited and full backlog. Change config / Search / Backlog search frequency to instead spread backlog searches over a number of days. Change migrate minimum used value for search frequency into new minimum 7 for search spread. Change restrict nzb providers to 1 backlog batch run per day. Add to Config/Search/Unaired episodes/Allow episodes that are released early. Add to Config/Search/Unaired episodes/Use specific api requests to search for early episode releases. Add use related ids for newznab searches to increase search efficiency. Add periodic update of related show ids. Change terminology Edit Show/"Post processing" tab name to "Other". Add advanced feature "Related show IDs" to Edit Show/Other used for finding episodes and TV info. Add search info source image links to those that have zero id under Edit Show/Other/"Related show IDs". Add "set master" button to Edit Show/Other/"Related show IDs" for info source that can be changed. Change terminology displayShow "Indexers" to "Links" to cover internal and web links. Change add related show info sources on displayShow page. Change don't display "temporarily" defunct TVRage image link on displayShow pages unless it is master info source. Change if a defunct info source is the master of a show then present a link on displayShow to edit related show IDs. Change simplify the next backlog search run time display in the page footer. Change try ssl when fetching data thetvdb, imdb, trakt, scene exception. Change improve reliability to Trakt notifier by using show related id support. Change improve config/providers newznab categories layout. Change show loaded log message at start up and include info source. Change if episode has no airdate then set status to unaired (was skipped). Technical Change move scene_exceptions table from cache.db to sickbeard.db. Add related ids to show obj. Add use of mapped indexer ids for newznab. Add indexer to sql in wanted_eps. Add aired in (scene) season for wanted episodes. Add need_anime, need_sports, need_sd, need_hd, need_uhd to wanted episodes and added as parameter to update_providers. Add fix for lib lockfile/mkdirlockfile. Add set master TV info source logic. Change harden ui input validation. Add per action dialog confirmation. Change to reload page under more events. Change implement "Mark all added episodes Wanted to search for releases" when setting new info source.
128 lines
5.1 KiB
Python
128 lines
5.1 KiB
Python
# Author: Dieter Blomme <dieterblomme@gmail.com>
|
|
# URL: http://code.google.com/p/sickbeard/
|
|
#
|
|
# This file is part of SickGear.
|
|
#
|
|
# SickGear is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# SickGear is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
import sickbeard
|
|
from sickbeard import logger
|
|
from lib.libtrakt import TraktAPI, exceptions
|
|
import os
|
|
|
|
|
|
class TraktNotifier:
|
|
def __init__(self):
|
|
pass
|
|
|
|
"""
|
|
A "notifier" for trakt.tv which keeps track of what has and hasn't been added to your library.
|
|
"""
|
|
|
|
def notify_snatch(self, ep_name):
|
|
pass
|
|
|
|
def notify_download(self, ep_name):
|
|
pass
|
|
|
|
def notify_subtitle_download(self, ep_name, lang):
|
|
pass
|
|
|
|
def notify_git_update(self, new_version):
|
|
pass
|
|
|
|
@staticmethod
|
|
def update_collection(ep_obj):
|
|
"""
|
|
Sends a request to trakt indicating that the given episode is part of our collection.
|
|
|
|
:param ep_obj: The TVEpisode object to add to trakt
|
|
"""
|
|
|
|
if sickbeard.USE_TRAKT and sickbeard.TRAKT_ACCOUNTS:
|
|
|
|
# URL parameters
|
|
data = {
|
|
'shows': [
|
|
{
|
|
'title': ep_obj.show.name,
|
|
'year': ep_obj.show.startyear,
|
|
'ids': {},
|
|
}
|
|
]
|
|
}
|
|
|
|
from sickbeard.indexers.indexer_config import INDEXER_TVDB, INDEXER_TVRAGE, INDEXER_IMDB, INDEXER_TMDB, \
|
|
INDEXER_TRAKT
|
|
|
|
supported_indexer = {INDEXER_TRAKT: 'trakt', INDEXER_TVDB: 'tvdb', INDEXER_TVRAGE: 'tvrage',
|
|
INDEXER_IMDB: 'imdb', INDEXER_TMDB: 'tmdb'}
|
|
indexer_priorities = [INDEXER_TRAKT, INDEXER_TVDB, INDEXER_TVRAGE, INDEXER_IMDB, INDEXER_TMDB]
|
|
|
|
indexer = indexerid = None
|
|
if ep_obj.show.indexer in supported_indexer:
|
|
indexer, indexerid = supported_indexer[ep_obj.show.indexer], ep_obj.show.indexerid
|
|
else:
|
|
for i in indexer_priorities:
|
|
if ep_obj.show.ids.get(i, {'id': 0}).get('id', 0) > 0:
|
|
indexer, indexerid = supported_indexer[i], ep_obj.show.ids[i]['id']
|
|
break
|
|
|
|
if indexer is None or indexerid is None:
|
|
logger.log('Missing trakt supported id, could not add to collection.', logger.WARNING)
|
|
return
|
|
|
|
data['shows'][0]['ids'][indexer] = indexerid
|
|
|
|
# Add Season and Episode + Related Episodes
|
|
data['shows'][0]['seasons'] = [{'number': ep_obj.season, 'episodes': []}]
|
|
|
|
for relEp_Obj in [ep_obj] + ep_obj.relatedEps:
|
|
data['shows'][0]['seasons'][0]['episodes'].append({'number': relEp_Obj.episode})
|
|
|
|
for tid, locations in sickbeard.TRAKT_UPDATE_COLLECTION.items():
|
|
if tid not in sickbeard.TRAKT_ACCOUNTS.keys():
|
|
continue
|
|
for loc in locations:
|
|
if not ep_obj.location.startswith('%s%s' % (loc.rstrip(os.path.sep), os.path.sep)):
|
|
continue
|
|
|
|
warn, msg = False, ''
|
|
try:
|
|
resp = TraktAPI().trakt_request('sync/collection', data, send_oauth=tid)
|
|
if 'added' in resp and 'episodes' in resp['added'] and 0 < sickbeard.helpers.tryInt(resp['added']['episodes']):
|
|
msg = 'Added episode to'
|
|
elif 'updated' in resp and 'episodes' in resp['updated'] and 0 < sickbeard.helpers.tryInt(resp['updated']['episodes']):
|
|
msg = 'Updated episode in'
|
|
elif 'existing' in resp and 'episodes' in resp['existing'] and 0 < sickbeard.helpers.tryInt(resp['existing']['episodes']):
|
|
msg = 'Episode is already in'
|
|
elif 'not_found' in resp and 'episodes' in resp['not_found'] and 0 < sickbeard.helpers.tryInt(resp['not_found']['episodes']):
|
|
msg = 'Episode not found on Trakt, not adding to'
|
|
else:
|
|
warn, msg = True, 'Could not add episode to'
|
|
except (exceptions.TraktAuthException, exceptions.TraktException):
|
|
warn, msg = True, 'Error adding episode to'
|
|
msg = 'Trakt: %s your %s collection' % (msg, sickbeard.TRAKT_ACCOUNTS[tid].name)
|
|
if not warn:
|
|
logger.log(msg)
|
|
else:
|
|
logger.log(msg, logger.WARNING)
|
|
|
|
|
|
@staticmethod
|
|
def _use_me():
|
|
return sickbeard.USE_TRAKT
|
|
|
|
|
|
notifier = TraktNotifier
|