do not assume precise objid as input 6/head
authorsamunders-core <samunders-core@users.noreply.github.com>
Thu, 8 Feb 2018 21:13:05 +0000 (22:13 +0100)
committerGitHub <noreply@github.com>
Thu, 8 Feb 2018 21:13:05 +0000 (22:13 +0100)
0_2_1_7_1_1_en -> 0_2_1_7_1_1_en_ -> 0_2_1_7_1_1 -> path/to/movie_en.srt

src/xupnpd_http.lua

index b0e394d..cfe7f76 100644 (file)
@@ -520,11 +520,17 @@ function http_handler(what,from,port,msg)
     -- Subtitle
     elseif url=='sub' then
 
-        local pls=find_playlist_object(object)
+        local srt = "%s.srt":format(object)
+       local pls=nil
+       object = "%s_":format(object)
+       while object:len() > 0 and (not pls or not pls.path) do
+           object = object:gsub("_[^_]*$", "")
+           pls=find_playlist_object(object)
+       end
 
         if not pls or not pls.path then http_send_headers(404) return end
 
-        local path=string.gsub(pls.path,'.%w+$','.srt')
+        local path=string.gsub(pls.path,'.%w+$',srt:gsub(object, ""))
 
         local flen=util.getflen(path)