aboutsummaryrefslogtreecommitdiff
path: root/controller
diff options
context:
space:
mode:
Diffstat (limited to 'controller')
-rw-r--r--controller/controller.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/controller/controller.go b/controller/controller.go
index f89d267..3552304 100644
--- a/controller/controller.go
+++ b/controller/controller.go
@@ -1,12 +1,22 @@
package controller
import (
+ "context"
"net/http"
+ "git.sr.ht/~gabrielgio/midr/db"
+ "git.sr.ht/~gabrielgio/midr/yt"
+ work "git.sr.ht/~sircmpwn/dowork"
"github.com/gin-gonic/gin"
- "gitlab.com/gabrielgio/midr/db"
)
+func spawnWorker(link string, output string) {
+ work.Submit(func(ctx context.Context) error {
+ yt.RunYtDlpProcess(link, output)
+ return nil
+ })
+}
+
func GetEntries(c *gin.Context) {
var entries []db.YdlEntry
db.DB.Find(&entries)
@@ -32,8 +42,8 @@ func CreateEntry(c *gin.Context) {
var entry db.YdlEntry
c.ShouldBind(&entry)
db.DB.Create(&entry)
+ spawnWorker(entry.Link, entry.Output_folder)
c.Redirect(http.StatusFound, "/")
-
}
func DeleteEntry(c *gin.Context) {