]> git.sesse.net Git - vlc/commitdiff
lua: http: fix artwork not being displayed on windows.
authorSam Malone <samicemalone@gmail.com>
Fri, 24 Jan 2014 09:24:42 +0000 (09:24 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 24 Jan 2014 09:46:42 +0000 (10:46 +0100)
Close #7607

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
share/lua/intf/http.lua

index 9a7926cf78078b86dc88cc52de366feaeac45b30..bc9c6e1bfb7a8ce046027382420c2e8dee7cc95c 100644 (file)
@@ -156,9 +156,13 @@ function callback_art(data, request, args)
         end
         local metas = item:metas()
         local filename = vlc.strings.decode_uri(string.gsub(metas["artwork_url"],"file://",""))
+        local windowsdrive = string.match(filename, "^/%a:/.+$")  --match windows drive letter
+        if windowsdrive then
+            filename = string.sub(filename, 2)  --remove starting forward slash before the drive letter
+        end
         local size = vlc.net.stat(filename).size
         local ext = string.match(filename,"%.([^%.]-)$")
-        local raw = io.open(filename):read("*a")
+        local raw = io.open(filename, 'rb'):read("*a")
         local content = [[Content-Type: ]]..mimes[ext]..[[
 
 Content-Length: ]]..size..[[