summaryrefslogtreecommitdiff
path: root/src/tangara/audio/playlist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tangara/audio/playlist.cpp')
-rw-r--r--src/tangara/audio/playlist.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/tangara/audio/playlist.cpp b/src/tangara/audio/playlist.cpp
index 6ed5f162..89d7e378 100644
--- a/src/tangara/audio/playlist.cpp
+++ b/src/tangara/audio/playlist.cpp
@@ -308,6 +308,33 @@ auto Playlist::nextItem(std::span<TCHAR> buf)
if (line.ends_with('\r')) {
line = line.substr(0, line.size() - 1);
}
+
+ const char *kMacFilePrefix = "file:///Volumes/";
+ // Handle absolute URIs that came from VLC on Mac by stripping the leading file:///Volumes/Foo/.
+ if (line.find(kMacFilePrefix) == 0) {
+ size_t second_slash = line.find("/", strlen(kMacFilePrefix));
+ if (second_slash != std::string::npos) {
+ line = line.substr(second_slash + 1);
+ }
+ }
+
+ mutated_ = "";
+ // Does this look like a URL-encoded path? Decode it to a filename.
+ // Tangara handles filenames, not URIs.
+ if (line.find('%') != std::string::npos) {
+ mutated_.reserve(line.size());
+ for (size_t n = 0; n < line.size(); ++n) {
+ if (n < (line.size() - 2) && line[n] == '%' &&
+ std::isxdigit(line[n+1]) && std::isxdigit(line[n+2])) {
+ char value = std::stoi(std::string(line.substr(n+1, 2)), 0, 16);
+ mutated_ += value;
+ n += 2;
+ } else {
+ mutated_ += line[n];
+ }
+ }
+ line = mutated_;
+ }
return line;
}