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

@@ -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 != "" {