2014-03-10 05:18:05 +00:00
|
|
|
# Author: Nic Wolfe <nic@wolfeden.ca>
|
|
|
|
# URL: http://code.google.com/p/sickbeard/
|
|
|
|
#
|
2014-11-12 16:43:14 +00:00
|
|
|
# This file is part of SickGear.
|
2014-03-10 05:18:05 +00:00
|
|
|
#
|
2014-11-12 16:43:14 +00:00
|
|
|
# SickGear is free software: you can redistribute it and/or modify
|
2014-03-10 05:18:05 +00:00
|
|
|
# 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.
|
|
|
|
#
|
2014-11-12 16:43:14 +00:00
|
|
|
# SickGear is distributed in the hope that it will be useful,
|
2014-03-10 05:18:05 +00:00
|
|
|
# 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
|
2014-11-12 16:43:14 +00:00
|
|
|
# along with SickGear. If not, see <http://www.gnu.org/licenses/>.
|
2018-04-11 14:13:20 +00:00
|
|
|
from collections import OrderedDict
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2015-02-24 07:01:12 +00:00
|
|
|
from sickbeard.common import Quality
|
2017-02-17 03:16:51 +00:00
|
|
|
from unidecode import unidecode
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2018-04-11 14:13:20 +00:00
|
|
|
import datetime
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
|
|
|
|
import sickbeard
|
2015-12-05 04:09:23 +00:00
|
|
|
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2017-09-13 17:18:59 +00:00
|
|
|
class SearchResult(object):
|
2014-03-10 05:18:05 +00:00
|
|
|
"""
|
|
|
|
Represents a search result from an indexer.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, episodes):
|
|
|
|
self.provider = -1
|
|
|
|
|
2014-07-15 02:00:53 +00:00
|
|
|
# release show object
|
|
|
|
self.show = None
|
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
# URL to the NZB/torrent file
|
2015-03-01 02:21:31 +00:00
|
|
|
self.url = ''
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
# used by some providers to store extra info associated with the result
|
|
|
|
self.extraInfo = []
|
|
|
|
|
2017-02-13 20:00:55 +00:00
|
|
|
# assign function to get the data for the download
|
|
|
|
self.get_data_func = None
|
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
# list of TVEpisode objects that this result is associated with
|
|
|
|
self.episodes = episodes
|
|
|
|
|
|
|
|
# quality of the release
|
|
|
|
self.quality = Quality.UNKNOWN
|
|
|
|
|
|
|
|
# release name
|
2015-03-01 02:21:31 +00:00
|
|
|
self.name = ''
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
# size of the release (-1 = n/a)
|
|
|
|
self.size = -1
|
|
|
|
|
2014-07-15 02:00:53 +00:00
|
|
|
# release group
|
2015-03-01 02:21:31 +00:00
|
|
|
self.release_group = ''
|
2014-07-15 02:00:53 +00:00
|
|
|
|
2014-08-18 01:19:58 +00:00
|
|
|
# version
|
|
|
|
self.version = -1
|
2014-08-22 06:32:09 +00:00
|
|
|
|
2017-09-13 17:18:59 +00:00
|
|
|
# proper level
|
|
|
|
self._properlevel = 0
|
|
|
|
|
|
|
|
# is a repack
|
|
|
|
self.is_repack = False
|
|
|
|
|
|
|
|
# provider unique id
|
|
|
|
self.puid = None
|
|
|
|
|
|
|
|
@property
|
|
|
|
def properlevel(self):
|
|
|
|
return self._properlevel
|
|
|
|
|
|
|
|
@properlevel.setter
|
|
|
|
def properlevel(self, v):
|
|
|
|
if isinstance(v, (int, long)):
|
|
|
|
self._properlevel = v
|
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
def __str__(self):
|
|
|
|
|
2015-03-01 02:21:31 +00:00
|
|
|
if self.provider is None:
|
|
|
|
return 'Invalid provider, unable to print self'
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2017-08-23 17:39:30 +00:00
|
|
|
return '\n'.join([
|
|
|
|
'%s @ %s' % (self.provider.name, self.url),
|
|
|
|
'Extra Info:',
|
|
|
|
'\n'.join([' %s' % x for x in self.extraInfo]),
|
|
|
|
'Episode: %s' % self.episodes,
|
|
|
|
'Quality: %s' % Quality.qualityStrings[self.quality],
|
|
|
|
'Name: %s' % self.name,
|
|
|
|
'Size: %s' % self.size,
|
|
|
|
'Release Group: %s' % self.release_group])
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2017-02-13 20:00:55 +00:00
|
|
|
def get_data(self):
|
|
|
|
if None is not self.get_data_func:
|
|
|
|
try:
|
|
|
|
return self.get_data_func(self.url)
|
|
|
|
except (StandardError, Exception):
|
|
|
|
pass
|
|
|
|
if self.extraInfo and 0 < len(self.extraInfo):
|
|
|
|
return self.extraInfo[0]
|
|
|
|
return None
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2017-08-23 17:39:30 +00:00
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
class NZBSearchResult(SearchResult):
|
|
|
|
"""
|
|
|
|
Regular NZB result with an URL to the NZB
|
|
|
|
"""
|
2015-03-01 02:21:31 +00:00
|
|
|
resultType = 'nzb'
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
class NZBDataSearchResult(SearchResult):
|
|
|
|
"""
|
|
|
|
NZB result where the actual NZB XML data is stored in the extraInfo
|
|
|
|
"""
|
2015-03-01 02:21:31 +00:00
|
|
|
resultType = 'nzbdata'
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
class TorrentSearchResult(SearchResult):
|
|
|
|
"""
|
|
|
|
Torrent result with an URL to the torrent
|
|
|
|
"""
|
2015-03-01 02:21:31 +00:00
|
|
|
resultType = 'torrent'
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2014-08-22 06:32:09 +00:00
|
|
|
# torrent hash
|
2014-08-29 05:22:55 +00:00
|
|
|
content = None
|
2014-08-22 06:32:09 +00:00
|
|
|
hash = None
|
|
|
|
|
2014-08-29 05:22:55 +00:00
|
|
|
|
2017-08-23 17:39:30 +00:00
|
|
|
class ShowFilter(object):
|
|
|
|
def __init__(self, config, log=None):
|
|
|
|
self.config = config
|
|
|
|
self.log = log
|
|
|
|
self.bad_names = [re.compile('(?i)%s' % r) for r in (
|
|
|
|
'[*]+\s*(?:403:|do not add|dupli[^s]+\s*(?:\d+|<a\s|[*])|inval)',
|
|
|
|
'(?:inval|not? allow(ed)?)(?:[,\s]*period)?\s*[*]',
|
|
|
|
'[*]+\s*dupli[^\s*]+\s*[*]+\s*(?:\d+|<a\s)',
|
|
|
|
'\s(?:dupli[^s]+\s*(?:\d+|<a\s|[*]))'
|
|
|
|
)]
|
|
|
|
|
|
|
|
def _is_bad_name(self, show):
|
|
|
|
return isinstance(show, dict) and 'seriesname' in show and isinstance(show['seriesname'], (str, unicode)) \
|
|
|
|
and any([x.search(show['seriesname']) for x in self.bad_names])
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _fix_firstaired(show):
|
|
|
|
if 'firstaired' not in show:
|
|
|
|
show['firstaired'] = '1900-01-01'
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _dict_prevent_none(d, key, default):
|
|
|
|
v = None
|
|
|
|
if isinstance(d, dict):
|
|
|
|
v = d.get(key, default)
|
|
|
|
return (v, default)[None is v]
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _fix_seriesname(show):
|
|
|
|
if isinstance(show, dict) and 'seriesname' in show and isinstance(show['seriesname'], (str, unicode)):
|
|
|
|
show['seriesname'] = ShowFilter._dict_prevent_none(show, 'seriesname', '').strip()
|
|
|
|
|
|
|
|
|
|
|
|
class AllShowsNoFilterListUI(ShowFilter):
|
|
|
|
"""
|
|
|
|
This class is for indexer api. Used for searching, no filter or smart select
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, config, log=None):
|
|
|
|
super(AllShowsNoFilterListUI, self).__init__(config, log)
|
|
|
|
|
|
|
|
def select_series(self, all_series):
|
|
|
|
search_results = []
|
|
|
|
|
|
|
|
# get all available shows
|
|
|
|
if all_series:
|
|
|
|
for cur_show in all_series:
|
|
|
|
self._fix_seriesname(cur_show)
|
|
|
|
if cur_show in search_results or self._is_bad_name(cur_show):
|
|
|
|
continue
|
|
|
|
|
|
|
|
self._fix_firstaired(cur_show)
|
|
|
|
|
|
|
|
if cur_show not in search_results:
|
|
|
|
search_results += [cur_show]
|
|
|
|
|
|
|
|
return search_results
|
|
|
|
|
|
|
|
|
|
|
|
class AllShowsListUI(ShowFilter):
|
2014-03-25 05:57:24 +00:00
|
|
|
"""
|
2014-04-24 11:52:44 +00:00
|
|
|
This class is for indexer api. Instead of prompting with a UI to pick the
|
2014-03-25 05:57:24 +00:00
|
|
|
desired result out of a list of shows it tries to be smart about it
|
|
|
|
based on what shows are in SB.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, config, log=None):
|
2017-08-23 17:39:30 +00:00
|
|
|
super(AllShowsListUI, self).__init__(config, log)
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2017-08-23 17:39:30 +00:00
|
|
|
def select_series(self, all_series):
|
2017-02-17 03:16:51 +00:00
|
|
|
search_results = []
|
2014-05-26 07:45:11 +00:00
|
|
|
|
2014-03-25 05:57:24 +00:00
|
|
|
# get all available shows
|
2017-08-23 17:39:30 +00:00
|
|
|
if all_series:
|
|
|
|
search_term = self.config.get('searchterm', '').strip().lower()
|
2017-02-17 03:16:51 +00:00
|
|
|
if search_term:
|
2014-04-24 11:52:44 +00:00
|
|
|
# try to pick a show that's in my show list
|
2017-08-23 17:39:30 +00:00
|
|
|
for cur_show in all_series:
|
|
|
|
self._fix_seriesname(cur_show)
|
|
|
|
if cur_show in search_results or self._is_bad_name(cur_show):
|
2014-04-24 11:52:44 +00:00
|
|
|
continue
|
2014-05-26 07:45:11 +00:00
|
|
|
|
2017-02-17 03:16:51 +00:00
|
|
|
seriesnames = []
|
|
|
|
if 'seriesname' in cur_show:
|
|
|
|
name = cur_show['seriesname'].lower()
|
|
|
|
seriesnames += [name, unidecode(name.encode('utf-8').decode('utf-8'))]
|
2017-08-23 17:39:30 +00:00
|
|
|
if 'aliases' in cur_show:
|
|
|
|
if isinstance(cur_show['aliases'], list):
|
|
|
|
for a in cur_show['aliases']:
|
|
|
|
name = a.strip().lower()
|
|
|
|
seriesnames += [name, unidecode(name.encode('utf-8').decode('utf-8'))]
|
|
|
|
elif isinstance(cur_show['aliases'], (str, unicode)):
|
|
|
|
name = cur_show['aliases'].strip().lower()
|
|
|
|
seriesnames += name.split('|') + unidecode(name.encode('utf-8').decode('utf-8')).split('|')
|
2017-02-17 03:16:51 +00:00
|
|
|
|
|
|
|
if search_term in set(seriesnames):
|
2017-08-23 17:39:30 +00:00
|
|
|
self._fix_firstaired(cur_show)
|
2017-02-17 03:16:51 +00:00
|
|
|
|
|
|
|
if cur_show not in search_results:
|
|
|
|
search_results += [cur_show]
|
|
|
|
|
|
|
|
return search_results
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2014-08-29 05:22:55 +00:00
|
|
|
|
2017-08-23 17:39:30 +00:00
|
|
|
class ShowListUI(ShowFilter):
|
2014-03-10 05:18:05 +00:00
|
|
|
"""
|
|
|
|
This class is for tvdb-api. Instead of prompting with a UI to pick the
|
|
|
|
desired result out of a list of shows it tries to be smart about it
|
2015-12-05 04:09:23 +00:00
|
|
|
based on what shows are in SB.
|
2014-03-10 05:18:05 +00:00
|
|
|
"""
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
def __init__(self, config, log=None):
|
2017-08-23 17:39:30 +00:00
|
|
|
super(ShowListUI, self).__init__(config, log)
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2017-08-23 17:39:30 +00:00
|
|
|
def select_series(self, all_series):
|
2014-07-27 17:58:19 +00:00
|
|
|
try:
|
2014-03-25 05:57:24 +00:00
|
|
|
# try to pick a show that's in my show list
|
2017-08-23 17:39:30 +00:00
|
|
|
for curShow in all_series:
|
|
|
|
self._fix_seriesname(curShow)
|
|
|
|
if self._is_bad_name(curShow):
|
|
|
|
continue
|
2014-07-27 17:58:19 +00:00
|
|
|
if filter(lambda x: int(x.indexerid) == int(curShow['id']), sickbeard.showList):
|
2014-03-25 05:57:24 +00:00
|
|
|
return curShow
|
2017-08-23 17:39:30 +00:00
|
|
|
except (StandardError, Exception):
|
2014-07-27 17:58:19 +00:00
|
|
|
pass
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2014-07-27 17:58:19 +00:00
|
|
|
# if nothing matches then return first result
|
2017-08-23 17:39:30 +00:00
|
|
|
return all_series[0]
|
2014-03-10 05:18:05 +00:00
|
|
|
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
class Proper:
|
2017-09-13 17:18:59 +00:00
|
|
|
def __init__(self, name, url, date, show, parsed_show=None, size=-1, puid=None):
|
2014-03-10 05:18:05 +00:00
|
|
|
self.name = name
|
|
|
|
self.url = url
|
|
|
|
self.date = date
|
2017-09-13 17:18:59 +00:00
|
|
|
self.size = size
|
|
|
|
self.puid = puid
|
2014-03-10 05:18:05 +00:00
|
|
|
self.provider = None
|
|
|
|
self.quality = Quality.UNKNOWN
|
2014-08-18 01:19:58 +00:00
|
|
|
self.release_group = None
|
|
|
|
self.version = -1
|
2014-08-29 05:22:55 +00:00
|
|
|
|
2016-09-04 20:00:44 +00:00
|
|
|
self.parsed_show = parsed_show
|
2014-07-15 02:00:53 +00:00
|
|
|
self.show = show
|
2014-03-10 05:18:05 +00:00
|
|
|
self.indexer = None
|
|
|
|
self.indexerid = -1
|
|
|
|
self.season = -1
|
|
|
|
self.episode = -1
|
2014-05-03 09:23:26 +00:00
|
|
|
self.scene_season = -1
|
|
|
|
self.scene_episode = -1
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
def __str__(self):
|
2015-03-01 02:21:31 +00:00
|
|
|
return str(self.date) + ' ' + self.name + ' ' + str(self.season) + 'x' + str(self.episode) + ' of ' + str(
|
|
|
|
self.indexerid) + ' from ' + str(sickbeard.indexerApi(self.indexer).name)
|
2014-03-10 05:18:05 +00:00
|
|
|
|
|
|
|
|
2017-08-23 17:39:30 +00:00
|
|
|
class ErrorViewer:
|
2014-03-10 05:18:05 +00:00
|
|
|
"""
|
|
|
|
Keeps a static list of UIErrors to be displayed on the UI and allows
|
|
|
|
the list to be cleared.
|
|
|
|
"""
|
|
|
|
|
|
|
|
errors = []
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
ErrorViewer.errors = []
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def add(error):
|
|
|
|
ErrorViewer.errors.append(error)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def clear():
|
|
|
|
ErrorViewer.errors = []
|
|
|
|
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2017-08-23 17:39:30 +00:00
|
|
|
class UIError:
|
2014-03-10 05:18:05 +00:00
|
|
|
"""
|
|
|
|
Represents an error to be displayed in the web UI.
|
|
|
|
"""
|
2014-03-25 05:57:24 +00:00
|
|
|
|
2014-03-10 05:18:05 +00:00
|
|
|
def __init__(self, message):
|
|
|
|
self.message = message
|
|
|
|
self.time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
2015-12-05 04:09:23 +00:00
|
|
|
|
2016-10-04 14:05:14 +00:00
|
|
|
|
2015-12-05 04:09:23 +00:00
|
|
|
class OrderedDefaultdict(OrderedDict):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
if not args:
|
|
|
|
self.default_factory = None
|
|
|
|
else:
|
|
|
|
if not (args[0] is None or callable(args[0])):
|
|
|
|
raise TypeError('first argument must be callable or None')
|
|
|
|
self.default_factory = args[0]
|
|
|
|
args = args[1:]
|
|
|
|
super(OrderedDefaultdict, self).__init__(*args, **kwargs)
|
|
|
|
|
2017-08-23 17:39:30 +00:00
|
|
|
def __missing__(self, key):
|
2015-12-05 04:09:23 +00:00
|
|
|
if self.default_factory is None:
|
|
|
|
raise KeyError(key)
|
|
|
|
self[key] = default = self.default_factory()
|
|
|
|
return default
|
|
|
|
|
|
|
|
def __reduce__(self): # optional, for pickle support
|
|
|
|
args = (self.default_factory,) if self.default_factory else ()
|
2016-10-04 14:05:14 +00:00
|
|
|
return self.__class__, args, None, None, self.iteritems()
|
|
|
|
|
2018-04-11 14:13:20 +00:00
|
|
|
# backport from python 3
|
|
|
|
def move_to_end(self, key, last=True):
|
|
|
|
"""Move an existing element to the end (or beginning if last==False).
|
|
|
|
|
|
|
|
Raises KeyError if the element does not exist.
|
|
|
|
When last=True, acts like a fast version of self[key]=self.pop(key).
|
|
|
|
|
|
|
|
"""
|
|
|
|
link_prev, link_next, key = link = self._OrderedDict__map[key]
|
|
|
|
link_prev[1] = link_next
|
|
|
|
link_next[0] = link_prev
|
|
|
|
root = self._OrderedDict__root
|
|
|
|
if last:
|
|
|
|
last = root[0]
|
|
|
|
link[0] = last
|
|
|
|
link[1] = root
|
|
|
|
last[1] = root[0] = link
|
|
|
|
else:
|
|
|
|
first = root[1]
|
|
|
|
link[0] = root
|
|
|
|
link[1] = first
|
|
|
|
root[1] = first[0] = link
|
|
|
|
|
|
|
|
def first_key(self):
|
|
|
|
return self._OrderedDict__root[1][2]
|
|
|
|
|
|
|
|
def last_key(self):
|
|
|
|
return self._OrderedDict__root[0][2]
|
|
|
|
|
2016-10-04 14:05:14 +00:00
|
|
|
|
|
|
|
class ImageUrlList(list):
|
2017-08-23 17:39:30 +00:00
|
|
|
def __init__(self, max_age=30):
|
2016-10-04 14:05:14 +00:00
|
|
|
super(ImageUrlList, self).__init__()
|
|
|
|
self.max_age = max_age
|
|
|
|
|
|
|
|
def add_url(self, url):
|
|
|
|
self.remove_old()
|
2017-08-23 17:39:30 +00:00
|
|
|
cache_item = (url, datetime.datetime.now())
|
|
|
|
for n, x in enumerate(self):
|
|
|
|
if self._is_cache_item(x) and url == x[0]:
|
|
|
|
self[n] = cache_item
|
2016-10-04 14:05:14 +00:00
|
|
|
return
|
2017-08-23 17:39:30 +00:00
|
|
|
self.append(cache_item)
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _is_cache_item(item):
|
|
|
|
return isinstance(item, (tuple, list)) and 2 == len(item)
|
2016-10-04 14:05:14 +00:00
|
|
|
|
|
|
|
def remove_old(self):
|
|
|
|
age_limit = datetime.datetime.now() - datetime.timedelta(minutes=self.max_age)
|
2017-08-23 17:39:30 +00:00
|
|
|
self[:] = [x for x in self if self._is_cache_item(x) and age_limit < x[1]]
|
2016-10-04 14:05:14 +00:00
|
|
|
|
|
|
|
def __repr__(self):
|
2017-08-23 17:39:30 +00:00
|
|
|
return str([x[0] for x in self if self._is_cache_item(x)])
|
2016-10-04 14:05:14 +00:00
|
|
|
|
2017-08-23 17:39:30 +00:00
|
|
|
def __contains__(self, url):
|
2016-10-04 14:05:14 +00:00
|
|
|
for x in self:
|
2017-08-23 17:39:30 +00:00
|
|
|
if self._is_cache_item(x) and url == x[0]:
|
2016-10-04 14:05:14 +00:00
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2017-08-23 17:39:30 +00:00
|
|
|
def remove(self, url):
|
|
|
|
for x in self:
|
|
|
|
if self._is_cache_item(x) and url == x[0]:
|
|
|
|
super(ImageUrlList, self).remove(x)
|
2016-10-04 14:05:14 +00:00
|
|
|
break
|
Add choose to delete watched episodes from a list of played media at Kodi, Emby, and/or Plex.
Add episode watched state system that integrates with Kodi, Plex, and/or Emby, instructions at Shows/History/Layout/"Watched".
Add installable SickGear Kodi repository containing addon "SickGear Watched State Updater".
Change add Emby setting for watched state scheduler at Config/Notifications/Emby/"Update watched interval".
Change add Plex setting for watched state scheduler at Config/Notifications/Plex/"Update watched interval".
Add API cmd=sg.updatewatchedstate, instructions for use are linked to in layout "Watched" at /history.
Change history page table filter input values are saved across page refreshes.
Change history page table filter inputs, accept values like "dvd or web" to only display both.
Change history page table filter inputs, press 'ESC' key inside a filter input to reset it.
Add provider activity stats to Shows/History/Layout/ drop down.
Change move provider failures table from Manage/Media Search to Shows/History/Layout/Provider fails.
Change sort provider failures by most recent failure, and with paused providers at the top.
Change remove table form non-testing version 20007, that was reassigned.
2018-03-06 01:18:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
if 'nt' == os.name:
|
|
|
|
import ctypes
|
|
|
|
|
|
|
|
class WinEnv:
|
|
|
|
def __init__(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_environment_variable(name):
|
|
|
|
name = unicode(name) # ensures string argument is unicode
|
|
|
|
n = ctypes.windll.kernel32.GetEnvironmentVariableW(name, None, 0)
|
|
|
|
result = None
|
|
|
|
if n:
|
|
|
|
buf = ctypes.create_unicode_buffer(u'\0'*n)
|
|
|
|
ctypes.windll.kernel32.GetEnvironmentVariableW(name, buf, n)
|
|
|
|
result = buf.value
|
|
|
|
return result
|
|
|
|
|
|
|
|
def __getitem__(self, key):
|
|
|
|
return self.get_environment_variable(key)
|
|
|
|
|
|
|
|
def get(self, key, default=None):
|
|
|
|
r = self.get_environment_variable(key)
|
|
|
|
return r if r is not None else default
|
|
|
|
|
|
|
|
sickbeard.ENV = WinEnv()
|
|
|
|
else:
|
|
|
|
class LinuxEnv(object):
|
|
|
|
def __init__(self, environ):
|
|
|
|
self.environ = environ
|
|
|
|
|
|
|
|
def __getitem__(self, key):
|
|
|
|
v = self.environ.get(key)
|
|
|
|
try:
|
|
|
|
return v.decode(SYS_ENCODING) if isinstance(v, str) else v
|
|
|
|
except (UnicodeDecodeError, UnicodeEncodeError):
|
|
|
|
return v
|
|
|
|
|
|
|
|
def get(self, key, default=None):
|
|
|
|
v = self[key]
|
|
|
|
return v if v is not None else default
|
|
|
|
|
|
|
|
sickbeard.ENV = LinuxEnv(os.environ)
|