Add more metadata
This commit is contained in:
@@ -60,14 +60,14 @@ func createSingleTorrentResponse(torrent realdebrid.Torrent, db *repo.Database)
|
||||
path := filepath.Join(currentPath, filenameV2)
|
||||
response := dav.File(
|
||||
path,
|
||||
int(unrestrict.Filesize),
|
||||
torrent.Added, // Assuming you want to use the torrent added time here
|
||||
unrestrict.Filesize,
|
||||
convertDate(torrent.Added),
|
||||
link,
|
||||
)
|
||||
responses = append(responses, response)
|
||||
} else {
|
||||
// This link is not cached yet
|
||||
unrestrictFn := func() (realdebrid.UnrestrictResponse, error) {
|
||||
unrestrictFn := func() (*realdebrid.UnrestrictResponse, error) {
|
||||
return realdebrid.UnrestrictCheck(os.Getenv("RD_TOKEN"), link)
|
||||
}
|
||||
unrestrict := realdebrid.RetryUntilOk(unrestrictFn)
|
||||
@@ -79,15 +79,14 @@ func createSingleTorrentResponse(torrent realdebrid.Torrent, db *repo.Database)
|
||||
Host: "",
|
||||
})
|
||||
continue
|
||||
} else {
|
||||
db.Insert(torrent.Hash, torrent.Filename, *unrestrict)
|
||||
}
|
||||
db.Insert(torrent.Hash, torrent.Filename, *unrestrict)
|
||||
filenameV2 := davextra.InsertLinkFragment(unrestrict.Filename, davextra.GetLinkFragment(unrestrict.Link))
|
||||
path := filepath.Join(currentPath, filenameV2)
|
||||
response := dav.File(
|
||||
path,
|
||||
int(unrestrict.Filesize),
|
||||
torrent.Added,
|
||||
unrestrict.Filesize,
|
||||
convertDate(torrent.Added),
|
||||
link,
|
||||
)
|
||||
responses = append(responses, response)
|
||||
|
||||
@@ -116,7 +116,7 @@ func Router(mux *http.ServeMux, db *repo.Database) {
|
||||
return
|
||||
}
|
||||
|
||||
unrestrictFn := func() (realdebrid.UnrestrictResponse, error) {
|
||||
unrestrictFn := func() (*realdebrid.UnrestrictResponse, error) {
|
||||
return realdebrid.UnrestrictLink(os.Getenv("RD_TOKEN"), unrestrict.Link)
|
||||
}
|
||||
resp := realdebrid.RetryUntilOk(unrestrictFn)
|
||||
|
||||
15
internal/dav/util.go
Normal file
15
internal/dav/util.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package dav
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func convertDate(input string) string {
|
||||
t, err := time.Parse(time.RFC3339, input)
|
||||
if err != nil {
|
||||
fmt.Println("Error:", err)
|
||||
return ""
|
||||
}
|
||||
return t.Format("Mon, 02 Jan 2006 15:04:05 GMT")
|
||||
}
|
||||
Reference in New Issue
Block a user