aboutsummaryrefslogtreecommitdiff
path: root/rebuild.py
diff options
context:
space:
mode:
authorJordan <me@jordan.im>2020-04-05 21:08:55 -0700
committerJordan <me@jordan.im>2020-04-05 21:08:55 -0700
commit65c0e04bb3bb1fd715be12f44f44ad05373754c0 (patch)
tree71ed443886fc2c5dba16cf3448ff3ee3b8c39587 /rebuild.py
parent7da67c278b703baf8b0c960a3085a2a5b7c0e83b (diff)
downloadroka-65c0e04bb3bb1fd715be12f44f44ad05373754c0.tar.gz
roka-65c0e04bb3bb1fd715be12f44f44ad05373754c0.zip
ensure HTML-safety of attributes; only-whitespace values treated as unpopulated
Diffstat (limited to 'rebuild.py')
-rwxr-xr-xrebuild.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/rebuild.py b/rebuild.py
index 55b0d50..90103b2 100755
--- a/rebuild.py
+++ b/rebuild.py
@@ -65,17 +65,19 @@ def get_books(root_path):
attr = dict()
attr['path'] = file_path
attr['duration'] = tag.duration
- if tag.title:
+ if tag.title and not tag.title.isspace():
attr['title'] = tag.title
else:
- attr['title'] = file_path.split('/')[-1]
- if tag.album:
+ attr['title'] = os.path.split(file_path)[1]
+
+ if tag.album and not tag.album.isspace():
attr['album'] = tag.album
book['title'] = tag.album
else:
- attr['album'] = book_path.split('/')[-1]
- book['title'] = book_path.split('/')[-1]
- if tag.artist:
+ attr['album'] = os.path.split(book_path)[1]
+ book['title'] = os.path.split(book_path)[1]
+
+ if tag.artist and not tag.artist.isspace():
attr['author'] = tag.artist
book['author'] = tag.artist
else: