mirror of https://github.com/l3uddz/traktarr
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
663 B
29 lines
663 B
from misc.log import logger
|
|
|
|
log = logger.get_logger(__name__)
|
|
|
|
|
|
def get_year_from_timestamp(timestamp):
|
|
year = 0
|
|
try:
|
|
if not timestamp:
|
|
return 0
|
|
|
|
year = timestamp[:timestamp.index('-')]
|
|
except Exception:
|
|
log.exception("Exception parsing year from %s: ", timestamp)
|
|
return int(year) if str(year).isdigit() else 0
|
|
|
|
|
|
def is_ascii(string):
|
|
try:
|
|
string.encode('ascii')
|
|
except UnicodeEncodeError:
|
|
return False
|
|
except UnicodeDecodeError:
|
|
return False
|
|
except Exception:
|
|
log.exception(u"Exception checking if %r was ascii: ", string)
|
|
return False
|
|
return True
|