rclaudio: catch exception when parsing bad date, set date to the epoch
This commit is contained in:
parent
f2407c3394
commit
31f6793495
@ -255,18 +255,21 @@ class AudioTagExtractor(RclBaseHandler):
|
|||||||
# was wrong, because dmtime is the unix integer time. We have
|
# was wrong, because dmtime is the unix integer time. We have
|
||||||
# removed the alias, and set dmtime from the parsed date value.
|
# removed the alias, and set dmtime from the parsed date value.
|
||||||
def parsedate(self, dt):
|
def parsedate(self, dt):
|
||||||
dt = dt.decode('utf-8', errors='ignore')
|
try:
|
||||||
if len(dt) > 10:
|
dt = dt.decode('utf-8', errors='ignore')
|
||||||
dt = dt[0:10]
|
if len(dt) > 10:
|
||||||
l = dt.split('-')
|
dt = dt[0:10]
|
||||||
if len(l) > 3 or len(l) == 2 or len(l[0]) != 4 or l[0] == '0000':
|
l = dt.split('-')
|
||||||
return ''
|
if len(l) > 3 or len(l) == 2 or len(l[0]) != 4 or l[0] == '0000':
|
||||||
if len(l) == 1:
|
return ''
|
||||||
pdt = datetime.datetime.strptime(dt, "%Y")
|
if len(l) == 1:
|
||||||
elif len(l) == 3:
|
pdt = datetime.datetime.strptime(dt, "%Y")
|
||||||
pdt = datetime.datetime.strptime(dt, "%Y-%m-%d")
|
elif len(l) == 3:
|
||||||
val = time.mktime(pdt.timetuple())
|
pdt = datetime.datetime.strptime(dt, "%Y-%m-%d")
|
||||||
return "%d" % val
|
val = time.mktime(pdt.timetuple())
|
||||||
|
return "%d" % val
|
||||||
|
except:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def html_text(self, filename):
|
def html_text(self, filename):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user