1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-06 02:23:24 +00:00

dlna: simplify search method for associating subtitles with media nodes

Seems to be some corner cases that are not being handled, so taking a different
approach that should be a little more robust.

Also, changing resources to be served under a subpath:  We've been serving
media at /res?path=%2Fdir%2Ffilename.mp4; change that to be just /r/dir/filename.mp4.
It's cleaner, easier to reason about, and a necessary first step towards just
serving the resources via httplib anyway.
This commit is contained in:
Dan Walters
2019-10-07 10:25:02 -05:00
committed by Nick Craig-Wood
parent eff11b44cf
commit 572d302620
9 changed files with 120 additions and 56 deletions

View File

@@ -218,3 +218,14 @@ func serveError(what interface{}, w http.ResponseWriter, text string, err error)
fs.Errorf(what, "%s: %v", text, err)
http.Error(w, text+".", http.StatusInternalServerError)
}
// Splits a path into (root, ext) such that root + ext == path, and ext is empty
// or begins with a period. Extended version of path.Ext().
func splitExt(path string) (string, string) {
for i := len(path) - 1; i >= 0 && path[i] != '/'; i-- {
if path[i] == '.' {
return path[:i], path[i:]
}
}
return path, ""
}