mirror of
https://github.com/beetbox/beets.git
synced 2025-12-09 10:05:35 +01:00
Implement recommendations by sampsyo
Implemented all recommendations.
This commit is contained in:
parent
3c3e579dcc
commit
06d4fe254d
1 changed files with 7 additions and 5 deletions
|
|
@ -229,14 +229,16 @@ def item_file(item_id):
|
|||
try:
|
||||
unicode_item_path = util.text_string(item.path)
|
||||
except (UnicodeDecodeError, UnicodeEncodeError):
|
||||
unicode_item_path = u"fallback" + os.path.splitext(item_path)[1]
|
||||
unicode_item_path = util.displayable_path(item.path)
|
||||
|
||||
base_filename = os.path.basename(unicode_item_path)
|
||||
try:
|
||||
# Imitate http.server behaviour
|
||||
os.path.basename(unicode_item_path).encode("latin-1", "strict")
|
||||
safe_filename = os.path.basename(unicode_item_path)
|
||||
except (UnicodeDecodeError, UnicodeEncodeError):
|
||||
safe_filename = unidecode(os.path.basename(unicode_item_path))
|
||||
base_filename.encode("latin-1", "strict")
|
||||
except UnicodeEncodeError:
|
||||
safe_filename = unidecode(base_filename)
|
||||
else:
|
||||
safe_filename = base_filename
|
||||
|
||||
response = flask.send_file(
|
||||
item_path,
|
||||
|
|
|
|||
Loading…
Reference in a new issue