Skip to content

Commit

Permalink
Remove existing file when forced downloading
Browse files Browse the repository at this point in the history
  • Loading branch information
boggydigital committed Dec 11, 2024
1 parent f9cf1dc commit 6fbc8bc
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cli/download_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,15 @@ func downloadVideo(

absFilename := filepath.Join(absVideosDir, relFilename)

if _, err := os.Stat(absFilename); !options.Force && err == nil {
//local file already exists - won't attempt to download again
return nil
if _, err := os.Stat(absFilename); err == nil {
if !options.Force {
if err := os.Remove(absFilename); err != nil {
return err
}
} else {
//local file already exists - won't attempt to download again
return nil
}
}

if err := downloadWithYtDlp(videoId, absFilename); err != nil {
Expand Down

0 comments on commit 6fbc8bc

Please sign in to comment.