1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 19:12:26 -05:00

Fix for date/time display issues.

Fix for manual snatches not updating status in realtime.
This commit is contained in:
echel0n 2014-05-18 11:21:18 -07:00
parent cf18b3eec8
commit f4b71b7203
4 changed files with 53 additions and 25 deletions

View File

@ -50,7 +50,11 @@ class DailySearcher():
for curProviderCount, curProvider in enumerate(providers): for curProviderCount, curProvider in enumerate(providers):
threading.currentThread().name = origThreadName + " :: [" + curProvider.name + "]" threading.currentThread().name = origThreadName + " :: [" + curProvider.name + "]"
try:
curProvider.cache.updateCache() curProvider.cache.updateCache()
except exceptions.AuthException, e:
logger.log(u"Authentication error: " + ex(e), logger.ERROR)
continue
logger.log(u"Checking to see if any shows have wanted episodes available for the last week ...") logger.log(u"Checking to see if any shows have wanted episodes available for the last week ...")

View File

@ -265,7 +265,8 @@ def parse_date_time(d, t, network):
return datetime.datetime(te.year, te.month, te.day, hr, m, tzinfo=sb_timezone) return datetime.datetime(te.year, te.month, te.day, hr, m, tzinfo=sb_timezone)
else: else:
foreign_timezone = get_network_timezone(network, network_dict) foreign_timezone = get_network_timezone(network, network_dict)
return datetime.datetime(te.year, te.month, te.day, hr, m, tzinfo=foreign_timezone) foreign_naive = datetime.datetime(te.year, te.month, te.day, hr, m, tzinfo=foreign_timezone)
return foreign_naive.astimezone(sb_timezone)
except: except:
return datetime.datetime(te.year, te.month, te.day, hr, m) return datetime.datetime(te.year, te.month, te.day, hr, m)

View File

@ -100,16 +100,15 @@ class sbdatetime(datetime.datetime):
@static_or_instance @static_or_instance
def sbftime(self, dt=None, show_seconds=False, t_preset=None): def sbftime(self, dt=None, show_seconds=False, t_preset=None):
try: try:locale.setlocale(locale.LC_TIME, self.ORIG_LC_TIME)
locale.setlocale(locale.LC_TIME, self.ORIG_LC_TIME) except:pass
except:
pass
try: try:
if sbdatetime.has_locale: if sbdatetime.has_locale:
locale.setlocale(locale.LC_TIME, 'us_US') locale.setlocale(locale.LC_TIME, 'us_US')
except: except:
sbdatetime.has_locale = False sbdatetime.has_locale = False
strt = '' strt = ''
try: try:
if self is None: if self is None:
@ -133,6 +132,7 @@ class sbdatetime(datetime.datetime):
locale.setlocale(locale.LC_TIME, self.ORIG_LC_TIME) locale.setlocale(locale.LC_TIME, self.ORIG_LC_TIME)
except: except:
sbdatetime.has_locale = False sbdatetime.has_locale = False
return strt return strt
# display Date in Sickbeard Format # display Date in Sickbeard Format
@ -158,6 +158,12 @@ class sbdatetime(datetime.datetime):
else: else:
strd = self.strftime(sickbeard.DATE_PRESET) strd = self.strftime(sickbeard.DATE_PRESET)
finally: finally:
try:
locale.setlocale(locale.LC_TIME, self.ORIG_LC_TIME)
except:
pass
return strd return strd
# display Datetime in Sickbeard Format # display Datetime in Sickbeard Format
@ -210,4 +216,5 @@ class sbdatetime(datetime.datetime):
locale.setlocale(locale.LC_TIME, self.ORIG_LC_TIME) locale.setlocale(locale.LC_TIME, self.ORIG_LC_TIME)
except: except:
sbdatetime.has_locale = False sbdatetime.has_locale = False
return strd return strd

View File

@ -80,18 +80,6 @@ class SearchQueue(generic_queue.GenericQueue):
else: else:
logger.log(u"Not adding item, it's already in the queue", logger.DEBUG) logger.log(u"Not adding item, it's already in the queue", logger.DEBUG)
def snatch_item(self, item):
for result in item:
# just use the first result for now
logger.log(u"Downloading " + result.name + " from " + result.provider.name)
item.success = search.snatchEpisode(result)
# give the CPU a break
time.sleep(2)
# return results of snatch
return item
class DailySearchQueueItem(generic_queue.QueueItem): class DailySearchQueueItem(generic_queue.QueueItem):
def __init__(self, show, segment): def __init__(self, show, segment):
generic_queue.QueueItem.__init__(self, 'Daily Search', DAILY_SEARCH) generic_queue.QueueItem.__init__(self, 'Daily Search', DAILY_SEARCH)
@ -112,8 +100,14 @@ class DailySearchQueueItem(generic_queue.QueueItem):
if not len(foundResults): if not len(foundResults):
logger.log(u"No needed episodes found during daily search for [" + self.show.name + "]") logger.log(u"No needed episodes found during daily search for [" + self.show.name + "]")
else: else:
for curResult in foundResults: for curEp in foundResults:
SearchQueue().snatch_item(curResult) for result in curEp:
# just use the first result for now
logger.log(u"Downloading " + result.name + " from " + result.provider.name)
search.snatchEpisode(result)
# give the CPU a break
time.sleep(2)
generic_queue.QueueItem.finish(self) generic_queue.QueueItem.finish(self)
@ -129,8 +123,6 @@ class ManualSearchQueueItem(generic_queue.QueueItem):
def execute(self): def execute(self):
generic_queue.QueueItem.execute(self) generic_queue.QueueItem.execute(self)
queueItem = self
try: try:
logger.log("Beginning manual search for [" + self.segment.prettyName() + "]") logger.log("Beginning manual search for [" + self.segment.prettyName() + "]")
searchResult = search.searchProviders(self.show, self.segment.season, [self.segment], True) searchResult = search.searchProviders(self.show, self.segment.season, [self.segment], True)
@ -139,7 +131,13 @@ class ManualSearchQueueItem(generic_queue.QueueItem):
threading.currentThread().name = self.thread_name threading.currentThread().name = self.thread_name
if searchResult: if searchResult:
self.success = SearchQueue().snatch_item(searchResult) # just use the first result for now
logger.log(u"Downloading " + searchResult[0].name + " from " + searchResult[0].provider.name)
self.success = search.snatchEpisode(searchResult[0])
# give the CPU a break
time.sleep(2)
else: else:
ui.notifications.message('No downloads were found', ui.notifications.message('No downloads were found',
"Couldn't find a download for <i>%s</i>" % self.segment.prettyName()) "Couldn't find a download for <i>%s</i>" % self.segment.prettyName())
@ -149,6 +147,10 @@ class ManualSearchQueueItem(generic_queue.QueueItem):
except Exception: except Exception:
logger.log(traceback.format_exc(), logger.DEBUG) logger.log(traceback.format_exc(), logger.DEBUG)
def finish(self):
# don't let this linger if something goes wrong
if self.success == None:
self.success = False
generic_queue.QueueItem.finish(self) generic_queue.QueueItem.finish(self)
class BacklogQueueItem(generic_queue.QueueItem): class BacklogQueueItem(generic_queue.QueueItem):
@ -176,7 +178,14 @@ class BacklogQueueItem(generic_queue.QueueItem):
threading.currentThread().name = self.thread_name threading.currentThread().name = self.thread_name
if searchResult: if searchResult:
SearchQueue().snatch_item(searchResult) for result in searchResult:
# just use the first result for now
logger.log(u"Downloading " + result.name + " from " + result.provider.name)
search.snatchEpisode(result)
# give the CPU a break
time.sleep(2)
else: else:
logger.log(u"No needed episodes found during backlog search for [" + self.show.name + "]") logger.log(u"No needed episodes found during backlog search for [" + self.show.name + "]")
@ -221,7 +230,14 @@ class FailedQueueItem(generic_queue.QueueItem):
threading.currentThread().name = self.thread_name threading.currentThread().name = self.thread_name
if searchResult: if searchResult:
SearchQueue().snatch_item(searchResult) for result in searchResult:
# just use the first result for now
logger.log(u"Downloading " + result.name + " from " + result.provider.name)
search.snatchEpisode(result)
# give the CPU a break
time.sleep(2)
else: else:
logger.log(u"No episodes found to retry for failed downloads return from providers!") logger.log(u"No episodes found to retry for failed downloads return from providers!")
except Exception, e: except Exception, e: