Mount youtube videos properly
This commit is contained in:
@@ -117,7 +117,7 @@ func ServeDownloadsListForInfuse(torMgr *torrent.TorrentManager) ([]byte, error)
|
|||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
buf.WriteString(dav.File(download.Filename, download.Filesize, download.Generated))
|
buf.WriteString(dav.File(filename, download.Filesize, download.Generated))
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.WriteString("</d:multistatus>")
|
buf.WriteString("</d:multistatus>")
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ func ServeDownloadsList(torMgr *torrent.TorrentManager) ([]byte, error) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
buf.WriteString(dav.File(download.Filename, download.Filesize, download.Generated))
|
buf.WriteString(dav.File(filename, download.Filesize, download.Generated))
|
||||||
}
|
}
|
||||||
buf.WriteString("</d:multistatus>")
|
buf.WriteString("</d:multistatus>")
|
||||||
return buf.Bytes(), nil
|
return buf.Bytes(), nil
|
||||||
|
|||||||
@@ -97,12 +97,8 @@ func ServeDownloadsList(torMgr *torrent.TorrentManager) ([]byte, error) {
|
|||||||
filenames := torMgr.DownloadMap.Keys()
|
filenames := torMgr.DownloadMap.Keys()
|
||||||
sort.Strings(filenames)
|
sort.Strings(filenames)
|
||||||
for _, filename := range filenames {
|
for _, filename := range filenames {
|
||||||
download, ok := torMgr.DownloadMap.Get(filename)
|
|
||||||
if !ok {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
filePath := filepath.Join(config.DOWNLOADS, url.PathEscape(filename))
|
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
|
return buf.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -341,6 +341,16 @@ func (t *TorrentManager) mountNewDownloads() {
|
|||||||
isRealDebrid := strings.HasPrefix(downloads[i].Link, "https://real-debrid.com/d/")
|
isRealDebrid := strings.HasPrefix(downloads[i].Link, "https://real-debrid.com/d/")
|
||||||
if !isRealDebrid {
|
if !isRealDebrid {
|
||||||
filename := filepath.Base(downloads[i].Filename)
|
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])
|
t.DownloadMap.Set(filename, &downloads[i])
|
||||||
mountedCount++
|
mountedCount++
|
||||||
} else if token != "" {
|
} else if token != "" {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ type Download struct {
|
|||||||
Streamable int `json:"streamable"`
|
Streamable int `json:"streamable"`
|
||||||
Generated string `json:"-"` // jsonDate
|
Generated string `json:"-"` // jsonDate
|
||||||
Token string `json:"-"`
|
Token string `json:"-"`
|
||||||
|
Type string `json:"type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Download) UnmarshalJSON(data []byte) error {
|
func (d *Download) UnmarshalJSON(data []byte) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user