Mount youtube videos properly

This commit is contained in:
Ben Adrian Sarmiento
2024-06-28 22:40:39 +02:00
parent c781a5fc7c
commit 6038380d38
5 changed files with 14 additions and 7 deletions

View File

@@ -117,7 +117,7 @@ func ServeDownloadsListForInfuse(torMgr *torrent.TorrentManager) ([]byte, error)
if !ok {
continue
}
buf.WriteString(dav.File(download.Filename, download.Filesize, download.Generated))
buf.WriteString(dav.File(filename, download.Filesize, download.Generated))
}
buf.WriteString("</d:multistatus>")

View File

@@ -128,7 +128,7 @@ func ServeDownloadsList(torMgr *torrent.TorrentManager) ([]byte, error) {
if !ok {
continue
}
buf.WriteString(dav.File(download.Filename, download.Filesize, download.Generated))
buf.WriteString(dav.File(filename, download.Filesize, download.Generated))
}
buf.WriteString("</d:multistatus>")
return buf.Bytes(), nil

View File

@@ -97,12 +97,8 @@ func ServeDownloadsList(torMgr *torrent.TorrentManager) ([]byte, error) {
filenames := torMgr.DownloadMap.Keys()
sort.Strings(filenames)
for _, filename := range filenames {
download, ok := torMgr.DownloadMap.Get(filename)
if !ok {
continue
}
filePath := filepath.Join(config.DOWNLOADS, url.PathEscape(filename))
buf.WriteString(fmt.Sprintf("<li><a href=\"/http/%s\">%s</a></li>", filePath, download.Filename))
buf.WriteString(fmt.Sprintf("<li><a href=\"/http/%s\">%s</a></li>", filePath, filename))
}
return buf.Bytes(), nil
}

View File

@@ -341,6 +341,16 @@ func (t *TorrentManager) mountNewDownloads() {
isRealDebrid := strings.HasPrefix(downloads[i].Link, "https://real-debrid.com/d/")
if !isRealDebrid {
filename := filepath.Base(downloads[i].Filename)
if strings.Contains(downloads[i].Type, "x") {
// extract extension from the filename
ext := filepath.Ext(filename)
trimmed := strings.TrimSuffix(filename, ext)
// it's a resolution so extract 2nd part and add it to the filename
parts := strings.Split(downloads[i].Type, "x")
if len(parts) > 1 {
filename = fmt.Sprintf("%s (%sp)%s", trimmed, parts[1], ext)
}
}
t.DownloadMap.Set(filename, &downloads[i])
mountedCount++
} else if token != "" {

View File

@@ -25,6 +25,7 @@ type Download struct {
Streamable int `json:"streamable"`
Generated string `json:"-"` // jsonDate
Token string `json:"-"`
Type string `json:"type"`
}
func (d *Download) UnmarshalJSON(data []byte) error {