Allow tags with spaces in !tags.m3u using double delimiters

This commit is contained in:
bnnm 2019-11-28 23:22:55 +01:00
parent 49bcedc5cb
commit a9594a10f4
2 changed files with 21 additions and 7 deletions

View File

@ -213,7 +213,7 @@ have total samples after those.
Certain formats have encrypted data, and need a key to decrypt. vgmstream Certain formats have encrypted data, and need a key to decrypt. vgmstream
will try to find the correct key from a list, but it can be provided by will try to find the correct key from a list, but it can be provided by
a companion file: a companion file:
- .adx: .adxkey (keystring, keycode, or derived 6 byte start/mult/add key) - .adx: .adxkey (keystring, 8 byte keycode, or derived 6 byte start/mult/add key)
- .ahx: .ahxkey (derived 6 byte start/mult/add key) - .ahx: .ahxkey (derived 6 byte start/mult/add key)
- .hca: .hcakey (8 byte decryption key, a 64-bit number) - .hca: .hcakey (8 byte decryption key, a 64-bit number)
- May be followed by 2 byte AWB scramble key for newer HCA - May be followed by 2 byte AWB scramble key for newer HCA
@ -294,12 +294,12 @@ ordering), the file itself just 'looks' like an M3U.
Format is: Format is:
``` ```
# ignored comment # ignored comment
# $GLOBAL_COMMAND value (extra features) # $GLOBAL_COMMAND (extra features)
# @GLOBAL_TAG value (applies all following tracks) # @GLOBAL_TAG text (applies all following tracks)
# %LOCAL_TAG value (applies to next track only) # %LOCAL_TAG text (applies to next track only)
filename1 filename1
# %LOCAL_TAG value (applies to next track only) # %LOCAL_TAG text (applies to next track only)
filename2 filename2
``` ```
Accepted tags depend on the player (foobar: any; winamp: see ATF config), Accepted tags depend on the player (foobar: any; winamp: see ATF config),
@ -315,6 +315,16 @@ Playlist formatting should follow player's config. ASCII or UTF-8 tags work.
in the tag file). in the tag file).
- *AUTOALBUM*: sets *%ALBUM* tag automatically using the containing dir as album. - *AUTOALBUM*: sets *%ALBUM* tag automatically using the containing dir as album.
Some players like foobar accept tags with spaces. To use them surround the tag
with both characters.
```
# @GLOBAL TAG WITH SPACES@ text
# ...
# %LOCAL TAG WITH SPACES% text
filename1
```
As a side effect if text has @/% inside you also need them: `# @ALBUMARTIST@ Tom-H@ck`
Note that since you can use global tags don't need to put all files inside. Note that since you can use global tags don't need to put all files inside.
This would be a perfectly valid *!tags.m3u*: This would be a perfectly valid *!tags.m3u*:
``` ```

View File

@ -201,7 +201,9 @@ int vgmstream_tags_next_tag(VGMSTREAM_TAGS* tags, STREAMFILE* tagfile) {
if (tags->section_found) { if (tags->section_found) {
/* find possible file tag */ /* find possible file tag */
ok = sscanf(line, "# %%%[^ \t] %[^\r\n] ", tags->key,tags->val); ok = sscanf(line, "# %%%[^%%]%% %[^\r\n] ", tags->key,tags->val); /* key with spaces */
if (ok != 2)
ok = sscanf(line, "# %%%[^ \t] %[^\r\n] ", tags->key,tags->val); /* key without */
if (ok == 2) { if (ok == 2) {
tags_clean(tags); tags_clean(tags);
return 1; return 1;
@ -224,7 +226,9 @@ int vgmstream_tags_next_tag(VGMSTREAM_TAGS* tags, STREAMFILE* tagfile) {
} }
/* find possible global tag */ /* find possible global tag */
ok = sscanf(line, "# @%[^ \t] %[^\r\n]", tags->key,tags->val); ok = sscanf(line, "# @%[^@]@ %[^\r\n]", tags->key,tags->val); /* key with spaces */
if (ok != 2)
ok = sscanf(line, "# @%[^ \t] %[^\r\n]", tags->key,tags->val); /* key without */
if (ok == 2) { if (ok == 2) {
tags_clean(tags); tags_clean(tags);
return 1; return 1;