fix conv command erroring out with permissions denied

This commit is contained in:
lyx0 2023-12-27 13:12:13 +01:00
parent eda759a437
commit 942e5a6eee

View file

@ -91,6 +91,7 @@ func (app *application) ConvertAndSave(fName, link string, msg twitch.PrivateMes
} }
func (app *application) ConvertToMP4(link string, msg twitch.PrivateMessage) { func (app *application) ConvertToMP4(link string, msg twitch.PrivateMessage) {
fName := "in"
goutubedl.Path = "yt-dlp" goutubedl.Path = "yt-dlp"
uuid_og := uuid.NewString() uuid_og := uuid.NewString()
uuid_new := uuid.NewString() uuid_new := uuid.NewString()
@ -110,7 +111,7 @@ func (app *application) ConvertToMP4(link string, msg twitch.PrivateMessage) {
return return
} }
//app.Send(target, "Downloaded.", msg) //app.Send(target, "Downloaded.", msg)
fileName := fmt.Sprintf("%s.%s", uuid_og, rExt) fileName := fmt.Sprintf("/public/uploads/%s.%s", uuid_og, rExt)
f, err := os.Create(fileName) f, err := os.Create(fileName)
//app.Send(target, fmt.Sprintf("Filename: %s", fileName), msg) //app.Send(target, fmt.Sprintf("Filename: %s", fileName), msg)
if err != nil { if err != nil {
@ -128,7 +129,7 @@ func (app *application) ConvertToMP4(link string, msg twitch.PrivateMessage) {
downloadResult.Close() downloadResult.Close()
f.Close() f.Close()
out := "/public/uploads/output.mp4" out := fmt.Sprintf("/public/uploads/%s.mp4", fName)
fn, err := os.Create(out) fn, err := os.Create(out)
if err != nil { if err != nil {
app.Log.Errorln(err) app.Log.Errorln(err)
@ -141,6 +142,7 @@ func (app *application) ConvertToMP4(link string, msg twitch.PrivateMessage) {
Output(out). Output(out).
OverWriteOutput().ErrorToStdOut().Run() OverWriteOutput().ErrorToStdOut().Run()
defer os.Remove(fileName)
go app.NewUpload("yaf", out, msg.Channel, uuid_new, msg) go app.NewUpload("yaf", out, msg.Channel, uuid_new, msg)
} }