Skip to content
Browse files

togg.py: improve year parsing further.

  • Loading branch information...
1 parent b15825b commit dfdd97fc0ad3131e3b19b1770484f0a32c3de767 @stassats committed Mar 27, 2010
Showing with 20 additions and 5 deletions.
  1. +20 −5 togg.py
View
25 togg.py
@@ -96,6 +96,13 @@ def is_various_artists(cue_album):
return False
+def parse_year(year):
+ if isinstance(year, basestring):
+ match = re.search("\d{4}", year)
+ if match:
+ year = match.group()
+ return year
+
def guess_from_cue(cue_file):
album = cue.parse_cue(cue_file)
if not album:
@@ -114,8 +121,14 @@ def guess_from_cue(cue_file):
track.year = album.date
track.number = cue_track.number
+ if album.date:
+ year = parse_year(album.date)
+ else:
+ year = parse_year(os.path.basename(
+ os.path.dirname(os.path.abspath(cue_file))))
+
return ("Various Artists" if va else album.performer,
- album.title, album.date, tracks)
+ album.title, year, tracks)
def guess_from_tags(files):
first = tag.Tag(files[0])
@@ -142,6 +155,12 @@ def guess_from_tags(files):
if not track.number:
track.set_number()
+ if year:
+ year = parse_year(year)
+ else:
+ year = parse_year(os.path.basename(
+ os.path.dirname(os.path.abspath(files[0]))))
+
return (artist, album, year, tracks)
##
@@ -170,10 +189,6 @@ def make_filename(tags):
file_name += album
if year:
- if isinstance(year, basestring):
- match = re.search("\d{4}", year)
- if match:
- year = match.group()
file_name += '_' + str(year)
return file_name

0 comments on commit dfdd97f

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