mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-01 08:53:37 +00:00
b3be940d44
Add setting to Trakt notification to update collection with downloaded episode info. Add Most Watched, Collected during the last month on Trakt. Change Add from Trakt/"Shows:" with Anticipated, Popular views. Change improve robustness of Trakt communications. Change Trakt notifier logo. Change pep8 and cleanup.
57 lines
1.8 KiB
Python
57 lines
1.8 KiB
Python
import ast
|
|
import base64
|
|
import re
|
|
import sickbeard
|
|
from helpers import tryInt
|
|
|
|
|
|
def read_config_string(data):
|
|
|
|
return data and dict((tryInt(x[0]), x[1]) for x in ast.literal_eval(data)) or {}
|
|
|
|
|
|
def build_config(**kwargs):
|
|
"""
|
|
kwargs is filtered for settings that enable updates to Trakt
|
|
|
|
:param kwargs: kwargs to be filtered for settings that enable updates to Trakt
|
|
:return: dict of parsed config kwargs where k is Trakt account id, v is a parent location
|
|
"""
|
|
|
|
config = {}
|
|
|
|
root_dirs = []
|
|
if sickbeard.ROOT_DIRS:
|
|
root_pieces = sickbeard.ROOT_DIRS.split('|')
|
|
root_dirs = root_pieces[1:]
|
|
|
|
for item in [re.findall('update_trakt_(\d+)_(.*)', k) for k, v in kwargs.items() if k.startswith('update_trakt_')]:
|
|
for account_id, location in item:
|
|
account_id = tryInt(account_id, None)
|
|
if None is account_id:
|
|
continue
|
|
for cur_dir in root_dirs:
|
|
account_id = tryInt(account_id, None)
|
|
if account_id and base64.urlsafe_b64encode(cur_dir) == location:
|
|
if isinstance(config.get(account_id), list):
|
|
config[account_id] += [cur_dir]
|
|
else:
|
|
config[account_id] = [cur_dir]
|
|
|
|
return config
|
|
|
|
|
|
def build_config_string(config):
|
|
"""
|
|
:param config: dicts of Trakt account id, parent location
|
|
:return: string csv of parsed config kwargs for config file
|
|
"""
|
|
return unicode(config.items())
|
|
|
|
|
|
def trakt_collection_remove_account(account_id):
|
|
if account_id in sickbeard.TRAKT_UPDATE_COLLECTION:
|
|
sickbeard.TRAKT_UPDATE_COLLECTION.pop(account_id)
|
|
sickbeard.save_config()
|
|
return True
|
|
return False
|