Proper token rotation
This commit is contained in:
@@ -383,24 +383,29 @@ func (t *TorrentManager) mountNewDownloads() {
|
||||
mountedCount := 0
|
||||
for i := range downloads {
|
||||
downloads[i].Token = token
|
||||
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 != "" {
|
||||
|
||||
if strings.HasPrefix(downloads[i].Link, "https://real-debrid.com/d/") {
|
||||
downloads[i].Link = downloads[i].Link[0:39]
|
||||
tokenMap.Set(downloads[i].Link, &downloads[i])
|
||||
continue
|
||||
}
|
||||
|
||||
filename := filepath.Base(downloads[i].Filename)
|
||||
|
||||
// account for resolution in the type
|
||||
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++
|
||||
}
|
||||
if mountedCount > 0 {
|
||||
t.log.Infof("Mounted %d new downloads", mountedCount)
|
||||
|
||||
Reference in New Issue
Block a user