Fixed eye sore

This commit is contained in:
Logan G 2024-12-31 18:04:03 -07:00
parent f25d9448c3
commit fa08c4088f
Signed by: logan
GPG key ID: E328528C921E7A7A

View file

@ -47,6 +47,8 @@ func downloadVideo(url string, path string, group GroupConfig) (err error) {
return err return err
} }
tempPath := MainConfig.TempDir+"/"+video.Info.ID
if video.Info.IsLive { if video.Info.IsLive {
log.Info("Video is a live stream. Skipping.") log.Info("Video is a live stream. Skipping.")
return nil return nil
@ -63,7 +65,7 @@ func downloadVideo(url string, path string, group GroupConfig) (err error) {
defer videoDLResult.Close() defer videoDLResult.Close()
file, err := os.OpenFile(MainConfig.TempDir+"/"+video.Info.ID+"-vid", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644) file, err := os.OpenFile(tempPath+"-vid", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
defer file.Close() defer file.Close()
io.Copy(file, videoDLResult) io.Copy(file, videoDLResult)
@ -83,7 +85,7 @@ func downloadVideo(url string, path string, group GroupConfig) (err error) {
defer audioDLResult.Close() defer audioDLResult.Close()
file, err := os.OpenFile(MainConfig.TempDir+"/"+video.Info.ID+"-audio", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644) file, err := os.OpenFile(tempPath+"-audio", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
defer file.Close() defer file.Close()
io.Copy(file, audioDLResult) io.Copy(file, audioDLResult)
@ -93,28 +95,28 @@ func downloadVideo(url string, path string, group GroupConfig) (err error) {
} }
if group.VideoFormat != "" && group.AudioFormat != "" { if group.VideoFormat != "" && group.AudioFormat != "" {
if err := mergeStreams(MainConfig.TempDir+"/"+video.Info.ID+"-vid",MainConfig.TempDir+"/"+video.Info.ID+"-audio", group.CFormat, path); err != nil { if err := mergeStreams(tempPath+"-vid",tempPath+"-audio", group.CFormat, path); err != nil {
log.Errorf("Could not merge files \"%s\" and \"%s\" to \"%s\"", MainConfig.TempDir+"/"+video.Info.ID+"-vid", MainConfig.TempDir+"/"+video.Info.ID+"-audio", path) log.Errorf("Could not merge files \"%s\" and \"%s\" to \"%s\"", tempPath+"-vid", tempPath+"-audio", path)
} }
if err := os.Remove(MainConfig.TempDir+"/"+video.Info.ID+"-vid"); err != nil { if err := os.Remove(tempPath+"-vid"); err != nil {
log.Warnf("Could not remove file \"%s\"", MainConfig.TempDir+"/"+video.Info.ID+"-vid") log.Warnf("Could not remove file \"%s\"", tempPath+"-vid")
} }
if err := os.Remove(MainConfig.TempDir+"/"+video.Info.ID+"-audio"); err != nil { if err := os.Remove(tempPath+"-audio"); err != nil {
log.Warnf("Could not remove file \"%s\"", MainConfig.TempDir+"/"+video.Info.ID+"-audio") log.Warnf("Could not remove file \"%s\"", tempPath+"-audio")
} }
} else if group.VideoFormat != "" { } else if group.VideoFormat != "" {
copyFile(MainConfig.TempDir+"/"+video.Info.ID+"-vid", path) copyFile(tempPath+"-vid", path)
if err := os.Remove(MainConfig.TempDir+"/"+video.Info.ID+"-vid"); err != nil { if err := os.Remove(tempPath+"-vid"); err != nil {
log.Warnf("Could not remove file \"%s\"", MainConfig.TempDir+"/"+video.Info.ID+"-vid") log.Warnf("Could not remove file \"%s\"", tempPath+"-vid")
} }
} else if group.AudioFormat != "" { } else if group.AudioFormat != "" {
if err := copyFile(MainConfig.TempDir+"/"+video.Info.ID+"-audio", path); err != nil { if err := copyFile(tempPath+"-audio", path); err != nil {
log.Errorf("Could not copy file \"%s\" to \"%s\"", MainConfig.TempDir+"/"+video.Info.ID+"-audio", path) log.Errorf("Could not copy file \"%s\" to \"%s\"", tempPath+"-audio", path)
} }
if err := os.Remove(MainConfig.TempDir+"/"+video.Info.ID+"-audio"); err != nil { if err := os.Remove(tempPath+"-audio"); err != nil {
log.Warnf("Could not remove file \"%s\"", MainConfig.TempDir+"/"+video.Info.ID+"-audio") log.Warnf("Could not remove file \"%s\"", tempPath+"-audio")
} }
} }