diff --git a/CHANGES.md b/CHANGES.md index a047487f..8e301a73 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -45,6 +45,7 @@ * Change disable ToTV due to non-deletable yet reported hacker BTC inbox scam and also little to no new content listings * Fix Episode View KeyError: 'state-title' failure for shows without a runtime * Update py-unrar2 library 99.3 to 99.6 (2fe1e98) +* Fix py-unrar2 on unix to handle different date formats output by different unrar command line versions [develop changelog] Enable Alpha Ratio again now that the secure login page over https is fixed diff --git a/HACKS.txt b/HACKS.txt index 75c4b37f..c569ab61 100644 --- a/HACKS.txt +++ b/HACKS.txt @@ -6,3 +6,4 @@ Libs with customisations... /lib/requests/packages/urllib3/connectionpool.py /lib/requests/packages/urllib3/util/ssl_.py /tornado +/lib/unrar2/unix.py diff --git a/lib/unrar2/unix.py b/lib/unrar2/unix.py index 12cced48..9e826a48 100644 --- a/lib/unrar2/unix.py +++ b/lib/unrar2/unix.py @@ -153,7 +153,7 @@ class RarFileImplementation(object): data['size'] = int(fields[0]) attr = fields[5] data['isdir'] = 'd' in attr.lower() - data['datetime'] = time.strptime(fields[3]+" "+fields[4], '%d-%m-%y %H:%M') + data['datetime'] = self.rarcmd_dt(fields[3], fields[4]) data['comment'] = None data['volume'] = None yield data @@ -169,13 +169,21 @@ class RarFileImplementation(object): data['size'] = int(fields[1]) attr = fields[0] data['isdir'] = 'd' in attr.lower() - data['datetime'] = time.strptime(fields[2]+" "+fields[3], '%d-%m-%y %H:%M') + data['datetime'] = self.rarcmd_dt(fields[2], fields[3]) data['comment'] = None - data['volume'] = None + data['volume'] = None yield data i += 1 line = source.next() + @staticmethod + def rarcmd_dt(param_date=time.strftime('%Y-%m-%d'), param_time=time.strftime('%H:%M')): + for str_fmt in '%Y-%m-%d %H:%M', '%Y-%m-%d %H:%M': + try: + return time.strptime('%s %s' % (param_date, param_time), str_fmt) + except ValueError: + pass + return time.strptime('%s %s' % (time.strftime('%Y-%m-%d'), time.strftime('%H:%M')), '%Y-%m-%d %H:%M') def read_files(self, checker): res = []