supply hostname for job listing
fix download race condition adjusted error handling
This commit is contained in:
parent
decb57bbed
commit
9acd4b08c2
2 changed files with 10 additions and 5 deletions
|
@ -82,7 +82,7 @@ func (v YoutubeVideo) getFilename() string {
|
|||
if len(name) < 1 {
|
||||
name = v.id
|
||||
}
|
||||
return v.dir + "/" + name + ".mp4"
|
||||
return v.dir + "/" + v.id + "/" + name + ".mp4"
|
||||
}
|
||||
|
||||
func (v YoutubeVideo) getAbbrevDescription() string {
|
||||
|
@ -97,7 +97,12 @@ func (v YoutubeVideo) getAbbrevDescription() string {
|
|||
func (v YoutubeVideo) download() error {
|
||||
videoPath := v.getFilename()
|
||||
|
||||
_, err := os.Stat(videoPath)
|
||||
err := os.Mkdir(v.dir+"/"+v.id, 0750)
|
||||
if err != nil && !strings.Contains(err.Error(), "file exists") {
|
||||
return errors.Wrap(err, 0)
|
||||
}
|
||||
|
||||
_, err = os.Stat(videoPath)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
return err
|
||||
} else if err == nil {
|
||||
|
@ -112,7 +117,7 @@ func (v YoutubeVideo) download() error {
|
|||
}
|
||||
|
||||
var downloadedFile *os.File
|
||||
downloadedFile, err = os.Create(v.getFilename())
|
||||
downloadedFile, err = os.Create(videoPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
"github.com/mitchellh/go-ps"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"google.golang.org/api/googleapi/transport"
|
||||
youtube "google.golang.org/api/youtube/v3"
|
||||
"google.golang.org/api/youtube/v3"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -255,7 +255,6 @@ func (s *Sync) startWorker(workerNum int) {
|
|||
log.Errorln(logMsg)
|
||||
fatalErrors := []string{
|
||||
":5279: read: connection reset by peer",
|
||||
"net/http: request canceled (Client.Timeout exceeded while awaiting headers)",
|
||||
"no space left on device",
|
||||
}
|
||||
if util.InSliceContains(err.Error(), fatalErrors) || s.StopOnError {
|
||||
|
@ -271,6 +270,7 @@ func (s *Sync) startWorker(workerNum int) {
|
|||
"Error in daemon: Cannot publish empty file",
|
||||
"Error extracting sts from embedded url response",
|
||||
"Client.Timeout exceeded while awaiting headers)",
|
||||
"video is bigger than 1GB, skipping for now",
|
||||
}
|
||||
if util.InSliceContains(err.Error(), errorsNoRetry) {
|
||||
log.Println("This error should not be retried at all")
|
||||
|
|
Loading…
Reference in a new issue