Skip to content
Browse files

Fixed issue with release year parsing

  • Loading branch information...
1 parent 53f2e90 commit d3cf48321dc044b12d2be4aeeff4afbfd934bc97 @dbrgn committed
Showing with 6 additions and 5 deletions.
  1. +6 −5 shiva/utils.py
View
11 shiva/utils.py
@@ -7,7 +7,7 @@
import translitcodec # don't remove!
import mutagen
-from dateutil import parser as date_parser
+import dateutil.parser
PUNCT_RE = re.compile(r'[\t !"#$%&\'()*\-/<=>?@\[\\\]^_`{|},.]+')
@@ -105,10 +105,11 @@ def album(self, value):
@property
def release_year(self):
"""The album release year."""
- DEFAULT_DATE = datetime.datetime(datetime.MINYEAR, 1, 1)
- date = date_parser.parse(self._getter('date', ''), default=DEFAULT_DATE).date()
- if date != DEFAULT_DATE:
- return date.year
+ default_date = datetime.datetime(datetime.MINYEAR, 1, 1)
+ date = self._getter('date', '')
+ parsed_date = dateutil.parser.parse(date, default=default_date)
+ if parsed_date != default_date:
+ return parsed_date.year
return None
@release_year.setter

0 comments on commit d3cf483

Please sign in to comment.
Something went wrong with that request. Please try again.