Refactors 2

This commit is contained in:
Ben Adrian Sarmiento
2024-07-11 22:33:20 +02:00
parent 4aafe5b4fc
commit 7509f0fa59
6 changed files with 12 additions and 48 deletions

View File

@@ -66,10 +66,9 @@ func VidHubFile(path string, fileSize int64, added string) string {
<d:displayname>%s</d:displayname>
<d:getcontentlength>%d</d:getcontentlength>
<d:getlastmodified>%s</d:getlastmodified>
<d:getcontenttype>%s</d:getcontenttype>
<d:resourcetype></d:resourcetype>
</d:prop>
<d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>
</d:response>`, customPathEscape(path), html.EscapeString(filename), fileSize, added, getContentType(filename))
</d:response>`, customPathEscape(path), html.EscapeString(filename), fileSize, added)
}

View File

@@ -2,7 +2,6 @@ package dav
import (
"net/url"
"path/filepath"
"strings"
)
@@ -27,31 +26,3 @@ func escapeForXML(input string) string {
input = strings.ReplaceAll(input, "@", "%40")
return input
}
func getContentType(filename string) string {
filename = strings.ToLower(filename)
switch filepath.Ext(filename) {
case ".avi":
return "video/x-msvideo"
case ".m2ts":
return "video/mp2t"
case ".m4v":
return "video/x-m4v"
case ".mkv":
return "video/x-matroska"
case ".mov":
return "video/quicktime"
case ".mp4":
return "video/mp4"
case ".mpg":
return "video/mpeg"
case ".mpeg":
return "video/mpeg"
case ".ts":
return "video/mp2t"
case ".wmv":
return "video/x-ms-wmv"
default:
return "application/octet-stream"
}
}