Skip to content

Commit

Permalink
Merge pull request #322 from whipper-team/feature/issue-279-disc-temp…
Browse files Browse the repository at this point in the history
…late-keyerror

Raise exception if template has invalid variables
  • Loading branch information
JoeLametta authored Nov 2, 2018
2 parents a011ca8 + 69bac86 commit 9c72ebc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ read_offset = 6 ; drive read offset in positive/negative frames (no leading +)
unknown = True
output_directory = ~/My Music
track_template = new/%%A/%%y - %%d/%%t - %%n ; note: the format char '%' must be represented '%%'
disc_template = %(track_template)s
disc_template = new/%%A/%%y - %%d/%%A - %%d
# ...
```

Expand Down
4 changes: 4 additions & 0 deletions whipper/common/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ def getPath(self, outdir, template, mbdiscid, metadata, track_number=None):
"""
assert isinstance(outdir, unicode), "%r is not unicode" % outdir
assert isinstance(template, unicode), "%r is not unicode" % template
matches = re.findall(r"%[^A,S,d,y,r,R,x,X]", template)
if '%' in template and matches:
raise ValueError('disc template string contains invalid '
'variable(s): {}.'.format(', '.join(matches)))
v = {}
v['A'] = 'Unknown Artist'
v['d'] = mbdiscid # fallback for title
Expand Down

0 comments on commit 9c72ebc

Please sign in to comment.