Fixed eye sore
This commit is contained in:
parent
f25d9448c3
commit
fa08c4088f
1 changed files with 17 additions and 15 deletions
32
download.go
32
download.go
|
@ -47,6 +47,8 @@ func downloadVideo(url string, path string, group GroupConfig) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
tempPath := MainConfig.TempDir+"/"+video.Info.ID
|
||||
|
||||
if video.Info.IsLive {
|
||||
log.Info("Video is a live stream. Skipping.")
|
||||
return nil
|
||||
|
@ -63,7 +65,7 @@ func downloadVideo(url string, path string, group GroupConfig) (err error) {
|
|||
|
||||
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()
|
||||
|
||||
io.Copy(file, videoDLResult)
|
||||
|
@ -83,7 +85,7 @@ func downloadVideo(url string, path string, group GroupConfig) (err error) {
|
|||
|
||||
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()
|
||||
|
||||
io.Copy(file, audioDLResult)
|
||||
|
@ -93,28 +95,28 @@ func downloadVideo(url string, path string, group GroupConfig) (err error) {
|
|||
}
|
||||
|
||||
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 {
|
||||
log.Errorf("Could not merge files \"%s\" and \"%s\" to \"%s\"", MainConfig.TempDir+"/"+video.Info.ID+"-vid", MainConfig.TempDir+"/"+video.Info.ID+"-audio", path)
|
||||
if err := mergeStreams(tempPath+"-vid",tempPath+"-audio", group.CFormat, path); err != nil {
|
||||
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 {
|
||||
log.Warnf("Could not remove file \"%s\"", MainConfig.TempDir+"/"+video.Info.ID+"-vid")
|
||||
if err := os.Remove(tempPath+"-vid"); err != nil {
|
||||
log.Warnf("Could not remove file \"%s\"", tempPath+"-vid")
|
||||
}
|
||||
if err := os.Remove(MainConfig.TempDir+"/"+video.Info.ID+"-audio"); err != nil {
|
||||
log.Warnf("Could not remove file \"%s\"", MainConfig.TempDir+"/"+video.Info.ID+"-audio")
|
||||
if err := os.Remove(tempPath+"-audio"); err != nil {
|
||||
log.Warnf("Could not remove file \"%s\"", tempPath+"-audio")
|
||||
}
|
||||
} 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 {
|
||||
log.Warnf("Could not remove file \"%s\"", MainConfig.TempDir+"/"+video.Info.ID+"-vid")
|
||||
if err := os.Remove(tempPath+"-vid"); err != nil {
|
||||
log.Warnf("Could not remove file \"%s\"", tempPath+"-vid")
|
||||
}
|
||||
} else if group.AudioFormat != "" {
|
||||
if err := copyFile(MainConfig.TempDir+"/"+video.Info.ID+"-audio", path); err != nil {
|
||||
log.Errorf("Could not copy file \"%s\" to \"%s\"", MainConfig.TempDir+"/"+video.Info.ID+"-audio", path)
|
||||
if err := copyFile(tempPath+"-audio", path); err != nil {
|
||||
log.Errorf("Could not copy file \"%s\" to \"%s\"", tempPath+"-audio", path)
|
||||
}
|
||||
if err := os.Remove(MainConfig.TempDir+"/"+video.Info.ID+"-audio"); err != nil {
|
||||
log.Warnf("Could not remove file \"%s\"", MainConfig.TempDir+"/"+video.Info.ID+"-audio")
|
||||
if err := os.Remove(tempPath+"-audio"); err != nil {
|
||||
log.Warnf("Could not remove file \"%s\"", tempPath+"-audio")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue