mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-01 00:43:37 +00:00
Merge pull request #672 from JackDandy/feature/ChangeAddShowPri
Change adding show processing to be highest priority.
This commit is contained in:
commit
518a341783
6 changed files with 78 additions and 24 deletions
|
@ -46,6 +46,8 @@
|
|||
* Add scene qualities WEB.h264 to SDTV, 720p.WEB.h264 to WEB DL 720p, and 1080p.WEB.h264 to WEB DL 1080p
|
||||
* Change improve handling when provider PiSexy is missing expected data
|
||||
* Change show list second level sort criteria
|
||||
* Change adding show processing to be highest priority
|
||||
* Use timezones to check unaired status during show update/adding
|
||||
|
||||
|
||||
### 0.11.10 (2016-03-17 19:00:00 UTC)
|
||||
|
|
|
@ -403,6 +403,8 @@
|
|||
</h3>
|
||||
</div>
|
||||
#else:
|
||||
#set $network_timezone = $network_timezones.get_network_timezone($show.network)
|
||||
#set $network_time = $network_timezones.parse_time($show.airs)
|
||||
#for $epResult in $sqlResults
|
||||
#set $epStr = '%sx%s' % ($epResult['season'], $epResult['episode'])
|
||||
#if not $epStr in $epCats or (0 == int($epResult['season']) and not $sickbeard.DISPLAY_SHOW_SPECIALS)
|
||||
|
@ -526,7 +528,7 @@
|
|||
</td>
|
||||
|
||||
<td class="col-airdate">
|
||||
<span class="${fuzzydate}">#if 1 == int($epResult['airdate']) then 'never' else $sbdatetime.sbdatetime.sbfdate($sbdatetime.sbdatetime.convert_to_setting($network_timezones.parse_date_time($epResult['airdate'], $show.airs, $show.network)))#</span>
|
||||
<span class="${fuzzydate}">#if 1 == int($epResult['airdate']) then 'never' else $sbdatetime.sbdatetime.sbfdate($sbdatetime.sbdatetime.convert_to_setting($network_timezones.parse_date_time($epResult['airdate'], $network_time, $network_timezone)))#</span>
|
||||
</td>
|
||||
|
||||
#if $sickbeard.USE_SUBTITLES and $show.subtitles
|
||||
|
|
|
@ -26,6 +26,7 @@ class QueuePriorities:
|
|||
LOW = 10
|
||||
NORMAL = 20
|
||||
HIGH = 30
|
||||
VERYHIGH = 40
|
||||
|
||||
|
||||
class GenericQueue(object):
|
||||
|
|
|
@ -36,9 +36,19 @@ am_regex = re.compile(r'(A[. ]? ?M)', flags=re.I)
|
|||
pm_regex = re.compile(r'(P[. ]? ?M)', flags=re.I)
|
||||
|
||||
network_dict = None
|
||||
network_dupes = None
|
||||
|
||||
sb_timezone = tz.tzlocal()
|
||||
|
||||
country_timezones = {
|
||||
'AU': 'Australia/Sydney', 'AR': 'America/Buenos_Aires', 'AUSTRALIA': 'Australia/Sydney', 'BR': 'America/Sao_Paulo',
|
||||
'CA': 'Canada/Eastern', 'CZ': 'Europe/Prague', 'DE': 'Europe/Berlin', 'ES': 'Europe/Madrid',
|
||||
'FI': 'Europe/Helsinki', 'FR': 'Europe/Paris', 'HK': 'Asia/Hong_Kong', 'IE': 'Europe/Dublin',
|
||||
'IS': 'Atlantic/Reykjavik', 'IT': 'Europe/Rome', 'JP': 'Asia/Tokyo', 'MX': 'America/Mexico_City',
|
||||
'MY': 'Asia/Kuala_Lumpur', 'NL': 'Europe/Amsterdam', 'NZ': 'Pacific/Auckland', 'PH': 'Asia/Manila',
|
||||
'PT': 'Europe/Lisbon', 'RU': 'Europe/Kaliningrad', 'SE': 'Europe/Stockholm', 'SG': 'Asia/Singapore',
|
||||
'TW': 'Asia/Taipei', 'UK': 'Europe/London', 'US': 'US/Eastern', 'ZA': 'Africa/Johannesburg'}
|
||||
|
||||
|
||||
# helper to remove failed temp download
|
||||
def _remove_zoneinfo_failed(filename):
|
||||
|
@ -205,45 +215,61 @@ def update_network_dict():
|
|||
|
||||
# load network timezones from db into dict
|
||||
def load_network_dict():
|
||||
global network_dict, network_dupes
|
||||
|
||||
my_db = db.DBConnection('cache.db')
|
||||
sql_name = 'REPLACE(LOWER(network_name), " ", "")'
|
||||
try:
|
||||
my_db = db.DBConnection('cache.db')
|
||||
cur_network_list = my_db.select('SELECT * FROM network_timezones')
|
||||
sql = 'SELECT %s AS network_name, timezone FROM [network_timezones] ' % sql_name + \
|
||||
'GROUP BY %s HAVING COUNT(*) = 1 ORDER BY %s;' % (sql_name, sql_name)
|
||||
cur_network_list = my_db.select(sql)
|
||||
if cur_network_list is None or len(cur_network_list) < 1:
|
||||
update_network_dict()
|
||||
cur_network_list = my_db.select('SELECT * FROM network_timezones')
|
||||
d = dict(cur_network_list)
|
||||
cur_network_list = my_db.select(sql)
|
||||
network_dict = dict(cur_network_list)
|
||||
except:
|
||||
d = {}
|
||||
global network_dict
|
||||
network_dict = d
|
||||
network_dict = {}
|
||||
|
||||
try:
|
||||
|
||||
case_dupes = my_db.select('SELECT * FROM [network_timezones] WHERE %s IN ' % sql_name +
|
||||
'(SELECT %s FROM [network_timezones]' % sql_name +
|
||||
' GROUP BY %s HAVING COUNT(*) > 1)' % sql_name +
|
||||
' ORDER BY %s;' % sql_name)
|
||||
network_dupes = dict(case_dupes)
|
||||
except:
|
||||
network_dupes = {}
|
||||
|
||||
|
||||
# get timezone of a network or return default timezone
|
||||
def get_network_timezone(network, network_dict):
|
||||
def get_network_timezone(network):
|
||||
if network is None:
|
||||
return sb_timezone
|
||||
|
||||
timezone = None
|
||||
|
||||
try:
|
||||
if zoneinfo.ZONEFILENAME is not None:
|
||||
if not network_dict:
|
||||
load_network_dict()
|
||||
try:
|
||||
n_t = tz.gettz(network_dict[network])
|
||||
timezone = tz.gettz(network_dupes.get(network) or network_dict.get(network.replace(' ', '').lower()))
|
||||
except:
|
||||
return sb_timezone
|
||||
pass
|
||||
|
||||
if n_t is not None:
|
||||
return n_t
|
||||
else:
|
||||
return sb_timezone
|
||||
else:
|
||||
return sb_timezone
|
||||
if timezone is None:
|
||||
cc = re.search(r'\(([a-z]+)\)$', network, flags=re.I)
|
||||
try:
|
||||
timezone = tz.gettz(country_timezones.get(cc.group(1).upper()))
|
||||
except:
|
||||
pass
|
||||
except:
|
||||
return sb_timezone
|
||||
pass
|
||||
|
||||
return timezone if timezone is not None else sb_timezone
|
||||
|
||||
|
||||
# parse date and time string into local time
|
||||
def parse_date_time(d, t, network):
|
||||
if network_dict is None:
|
||||
load_network_dict()
|
||||
def parse_time(t):
|
||||
mo = time_regex.search(t)
|
||||
if mo is not None and len(mo.groups()) >= 5:
|
||||
if mo.group(5) is not None:
|
||||
|
@ -274,9 +300,23 @@ def parse_date_time(d, t, network):
|
|||
hr = 0
|
||||
m = 0
|
||||
|
||||
return hr, m
|
||||
|
||||
|
||||
# parse date and time string into local time
|
||||
def parse_date_time(d, t, network):
|
||||
|
||||
if isinstance(t, basestring):
|
||||
(hr, m) = parse_time(t)
|
||||
else:
|
||||
(hr, m) = t
|
||||
|
||||
te = datetime.datetime.fromordinal(helpers.tryInt(d))
|
||||
try:
|
||||
foreign_timezone = get_network_timezone(network, network_dict)
|
||||
if isinstance(network, basestring):
|
||||
foreign_timezone = get_network_timezone(network)
|
||||
else:
|
||||
foreign_timezone = network
|
||||
foreign_naive = datetime.datetime(te.year, te.month, te.day, hr, m, tzinfo=foreign_timezone)
|
||||
return foreign_naive
|
||||
except:
|
||||
|
|
|
@ -250,6 +250,8 @@ class QueueItemAdd(ShowQueueItem):
|
|||
# this will initialize self.show to None
|
||||
ShowQueueItem.__init__(self, ShowQueueActions.ADD, self.show, scheduled_update)
|
||||
|
||||
self.priority = generic_queue.QueuePriorities.VERYHIGH
|
||||
|
||||
def _getName(self):
|
||||
"""
|
||||
Returns the show name if there is a show object created, if not returns
|
||||
|
|
|
@ -50,6 +50,7 @@ from sickbeard import notifiers
|
|||
from sickbeard import postProcessor
|
||||
from sickbeard import subtitles
|
||||
from sickbeard import history
|
||||
from sickbeard import network_timezones
|
||||
from sickbeard.blackandwhitelist import BlackAndWhiteList
|
||||
|
||||
from sickbeard import encodingKludge as ek
|
||||
|
@ -1772,8 +1773,14 @@ class TVEpisode(object):
|
|||
# if we don't have the file
|
||||
if not ek.ek(os.path.isfile, self.location):
|
||||
|
||||
today = datetime.date.today()
|
||||
future_airtime = self.airdate > today + datetime.timedelta(days=1) or \
|
||||
(not self.airdate < today - datetime.timedelta(days=1) and
|
||||
network_timezones.parse_date_time(self.airdate.toordinal(), self.show.airs, self.show.network) +
|
||||
datetime.timedelta(minutes=helpers.tryInt(self.show.runtime, 60)) > datetime.datetime.now(network_timezones.sb_timezone))
|
||||
|
||||
# if it hasn't aired yet set the status to UNAIRED
|
||||
if self.airdate >= datetime.date.today() and self.status in [SKIPPED, UNAIRED, UNKNOWN, WANTED]:
|
||||
if future_airtime and self.status in [SKIPPED, UNAIRED, UNKNOWN, WANTED]:
|
||||
logger.log('Episode airs in the future, marking it %s' % statusStrings[UNAIRED], logger.DEBUG)
|
||||
self.status = UNAIRED
|
||||
|
||||
|
|
Loading…
Reference in a new issue