mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-01 03:56:38 +08:00
refactor: split modules and harden scraping workflows
This commit is contained in:
@@ -8,16 +8,25 @@ package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/ShukeBta/MediaStationGo/internal/service"
|
||||
)
|
||||
|
||||
const tasksLiveTorrentSnapshotMaxAge = 30 * time.Second
|
||||
|
||||
func tasksHandler(svc *service.Container) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
transcodes := svc.Transcoder.Active()
|
||||
_, torrents, _ := svc.Downloads.List(c.Request.Context())
|
||||
var transcodes []service.ActiveJob
|
||||
if svc.Transcoder != nil {
|
||||
transcodes = svc.Transcoder.Active()
|
||||
}
|
||||
var torrents []service.QBitTorrent
|
||||
if svc.Downloads != nil {
|
||||
torrents = svc.Downloads.LiveTorrentSnapshot(tasksLiveTorrentSnapshotMaxAge)
|
||||
}
|
||||
background := service.TaskSnapshot{}
|
||||
if svc.Tasks != nil {
|
||||
background = svc.Tasks.Snapshot()
|
||||
|
||||
Reference in New Issue
Block a user