From cef6732a9dc2e9ae6b56d5bd22d14af4cad670eb Mon Sep 17 00:00:00 2001 From: evilhero Date: Thu, 13 Jul 2017 14:03:32 -0400 Subject: [PATCH] FIX:(#1678) When searching 32p, would use os-based dates for comparisons which caused problems when it was not English. Now will convert non-English timestamps into an English format so that comparisons will work properly again. --- mylar/auth32p.py | 3 ++- mylar/rsscheck.py | 8 ++++---- mylar/search.py | 17 +++++++++++++++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/mylar/auth32p.py b/mylar/auth32p.py index 93a889c9..1f25deb9 100644 --- a/mylar/auth32p.py +++ b/mylar/auth32p.py @@ -352,7 +352,8 @@ class info32p(object): 'leechers': a['leechers'], 'scanner': a['scanner'], 'chkit': {'id': x['id'], 'series': x['series']}, - 'pubdate': datetime.datetime.fromtimestamp(float(a['upload_time'])).strftime('%a, %d %b %Y %H:%M:%S')}) + 'pubdate': datetime.datetime.fromtimestamp(float(a['upload_time'])).strftime('%a, %d %b %Y %H:%M:%S'), + 'int_pubdate': float(a['upload_time'])}) if len(results32p) > 0: diff --git a/mylar/rsscheck.py b/mylar/rsscheck.py index eec3a647..3557a62b 100755 --- a/mylar/rsscheck.py +++ b/mylar/rsscheck.py @@ -274,15 +274,15 @@ def torrents(pickfeed=None, seriesname=None, issue=None, feedinfo=None): tmpsz_end = tmp1 + 2 tmpsz_st += 2 - if 'GB' in tmpsz[tmpsz_st:tmpsz_end]: + if 'KB' in tmpsz[tmpsz_st:tmpsz_end]: + szform = 'KB' + sz = 'K' + elif 'GB' in tmpsz[tmpsz_st:tmpsz_end]: szform = 'GB' sz = 'G' elif 'MB' in tmpsz[tmpsz_st:tmpsz_end]: szform = 'MB' sz = 'M' - elif 'KB' in tmpsz[tmpsz_st:tmpsz_end]: - szform = 'KB' - sz = 'K' elif 'TB' in tmpsz[tmpsz_st:tmpsz_end]: szform = 'TB' sz = 'T' diff --git a/mylar/search.py b/mylar/search.py index 75d20f23..cfbf8933 100755 --- a/mylar/search.py +++ b/mylar/search.py @@ -820,7 +820,7 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, Publisher, IssueDa #---- date constaints. # if the posting date is prior to the publication date, dump it and save the time. - #logger.info('entry' + str(entry)) + #logger.fdebug('entry: %s' % entry) if nzbprov == 'experimental' or nzbprov =='32P': pubdate = entry['pubdate'] else: @@ -855,7 +855,20 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, Publisher, IssueDa if any([postdate_int is None, type(postdate_int) != int]) or not all([nzbprov == '32P', rss == 'no']): # convert it to a tuple dateconv = email.utils.parsedate_tz(pubdate) - dateconv2 = datetime.datetime(*dateconv[:6]) + if all([nzbprov == '32P', dateconv is None, rss == 'no']): + try: + pubdate = email.utils.formatdate(entry['int_pubdate'], localtime=True, usegmt=False) + except: + logger.warn('Unable to parsedate to a long-date that I can undestand : %s' % entry['int_pubdate']) + else: + logger.fdebug('Successfully converted to : %s' % pubdate) + dateconv = email.utils.parsedate_tz(pubdate) + + try: + dateconv2 = datetime.datetime(*dateconv[:6]) + except TypeError as e: + logger.warn('Unable to convert timestamp from : %s [%s]' % ((dateconv,), e)) + try: # convert it to a numeric time, then subtract the timezone difference (+/- GMT) if dateconv[-1] is not None: