Compare commits
No commits in common. "5e9774f70dc8c879e98173cf3d6d63ce10285c14" and "eada3e28d7bdbfd03686e625dec3a44c6a465c7f" have entirely different histories.
5e9774f70d
...
eada3e28d7
5 changed files with 3 additions and 45 deletions
14
download.go
14
download.go
|
@ -8,7 +8,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
//"strconv"
|
//"strconv"
|
||||||
"path/filepath"
|
|
||||||
|
|
||||||
|
|
||||||
"github.com/charmbracelet/log"
|
"github.com/charmbracelet/log"
|
||||||
|
@ -48,10 +47,7 @@ func downloadVideo(url string, path string, group GroupConfig) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
tempPath := filepath.Join(MainConfig.TempDir, sanitizeFilename(replaceDelimiters(video.Info.ID)))
|
tempPath := MainConfig.TempDir+"/"+video.Info.ID
|
||||||
tempPath = filepath.Clean(tempPath)
|
|
||||||
|
|
||||||
log.Debugf("Using temp path \"%s\".", tempPath)
|
|
||||||
|
|
||||||
/* VIDEO */
|
/* VIDEO */
|
||||||
if group.VideoFormat != "" {
|
if group.VideoFormat != "" {
|
||||||
|
@ -65,10 +61,6 @@ func downloadVideo(url string, path string, group GroupConfig) (err error) {
|
||||||
defer videoDLResult.Close()
|
defer videoDLResult.Close()
|
||||||
|
|
||||||
file, err := os.OpenFile(tempPath+"-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)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
io.Copy(file, videoDLResult)
|
io.Copy(file, videoDLResult)
|
||||||
|
@ -89,10 +81,6 @@ func downloadVideo(url string, path string, group GroupConfig) (err error) {
|
||||||
defer audioDLResult.Close()
|
defer audioDLResult.Close()
|
||||||
|
|
||||||
file, err := os.OpenFile(tempPath+"-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)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
defer file.Close()
|
defer file.Close()
|
||||||
|
|
||||||
io.Copy(file, audioDLResult)
|
io.Copy(file, audioDLResult)
|
||||||
|
|
25
file.go
25
file.go
|
@ -5,8 +5,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
|
||||||
"regexp"
|
|
||||||
|
|
||||||
|
|
||||||
"github.com/charmbracelet/log"
|
"github.com/charmbracelet/log"
|
||||||
|
@ -60,26 +58,3 @@ func copyFile(src, dst string) (error) {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func replaceDelimiters(input string) string {
|
|
||||||
replacer := strings.NewReplacer(
|
|
||||||
"/", "/",
|
|
||||||
"\\", "\",
|
|
||||||
)
|
|
||||||
return replacer.Replace(input)
|
|
||||||
}
|
|
||||||
|
|
||||||
func sanitizeFilename(filename string) string {
|
|
||||||
invalidFilenameChars := regexp.MustCompile(`[^a-zA-Z0-9._-/\[[:blank:]]]+`)
|
|
||||||
|
|
||||||
sanitized := invalidFilenameChars.ReplaceAllString(filename, "-")
|
|
||||||
|
|
||||||
// Trim any leading or trailing spaces or underscores.
|
|
||||||
sanitized = strings.Trim(sanitized, " _.")
|
|
||||||
|
|
||||||
if sanitized == "" {
|
|
||||||
sanitized = " "
|
|
||||||
}
|
|
||||||
|
|
||||||
return sanitized
|
|
||||||
}
|
|
||||||
|
|
1
go.mod
1
go.mod
|
@ -7,7 +7,6 @@ require (
|
||||||
github.com/alexflint/go-arg v1.5.1
|
github.com/alexflint/go-arg v1.5.1
|
||||||
github.com/charmbracelet/log v0.4.0
|
github.com/charmbracelet/log v0.4.0
|
||||||
github.com/h2non/filetype v1.1.3
|
github.com/h2non/filetype v1.1.3
|
||||||
github.com/kennygrant/sanitize v1.2.4
|
|
||||||
github.com/u2takey/ffmpeg-go v0.5.0
|
github.com/u2takey/ffmpeg-go v0.5.0
|
||||||
github.com/wader/goutubedl v0.0.0-20241224160441-33e26ae8181c
|
github.com/wader/goutubedl v0.0.0-20241224160441-33e26ae8181c
|
||||||
)
|
)
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -33,8 +33,6 @@ github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHW
|
||||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
||||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||||
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||||
github.com/kennygrant/sanitize v1.2.4 h1:gN25/otpP5vAsO2djbMhF/LQX6R7+O1TB4yv8NzpJ3o=
|
|
||||||
github.com/kennygrant/sanitize v1.2.4/go.mod h1:LGsjYYtgxbetdg5owWB2mpgUL6e2nfw2eObZ0u0qvak=
|
|
||||||
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||||
|
|
6
ytva.go
6
ytva.go
|
@ -8,7 +8,6 @@ import (
|
||||||
//"io"
|
//"io"
|
||||||
//"reflect"
|
//"reflect"
|
||||||
"regexp"
|
"regexp"
|
||||||
"path/filepath"
|
|
||||||
|
|
||||||
//"google.golang.org/api/option"
|
//"google.golang.org/api/option"
|
||||||
//"google.golang.org/api/youtube/v3"
|
//"google.golang.org/api/youtube/v3"
|
||||||
|
@ -123,7 +122,6 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("Channel Name: %s", channel.Info.Channel)
|
log.Infof("Channel Name: %s", channel.Info.Channel)
|
||||||
log.Debugf("Got %d entries", len(channel.Info.Entries))
|
|
||||||
|
|
||||||
video:
|
video:
|
||||||
for _, v := range channel.Info.Entries {
|
for _, v := range channel.Info.Entries {
|
||||||
|
@ -161,9 +159,9 @@ func main() {
|
||||||
|
|
||||||
dirPath := fillPlaceholders(group.OutputDir, v)
|
dirPath := fillPlaceholders(group.OutputDir, v)
|
||||||
fileName := fillPlaceholders(group.FileName, v)
|
fileName := fillPlaceholders(group.FileName, v)
|
||||||
path := filepath.Join(dirPath, filepath.Clean(sanitizeFilename(replaceDelimiters(fileName))))
|
path := dirPath+"/"+fileName
|
||||||
|
|
||||||
log.Debugf("Output: \"%s\"", path)
|
log.Debugf("Output: %s", path)
|
||||||
|
|
||||||
if _, err := os.Stat(dirPath); err != nil {
|
if _, err := os.Stat(dirPath); err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue