Compare commits

..

No commits in common. "5e569df5abf80fe92d4c4568708ef260742b6a34" and "5e9774f70dc8c879e98173cf3d6d63ce10285c14" have entirely different histories.

4 changed files with 15 additions and 83 deletions

View file

@ -2,7 +2,7 @@ TempDir = "/tmp/"
[Group.LinuxYouTubers]
URL = [ "https://www.youtube.com/@DistroTube", "https://www.youtube.com/@MentalOutlaw" ]
OutputDir = "videos/Linux/%Channel%/%Playlist%/"
OutputDir = "videos/%Channel%/%Playlist%/"
FileName = "%Timestamp% - %Title%.mkv"
CFormat = "matroska"
VideoFormat = "bestvideo[height<=720]"
@ -12,16 +12,16 @@ SizeLimit = 200000000
[Group.Odysee]
URL = [ "https://odysee.com/@DistroTube:2", "https://odysee.com/@AlphaNerd:8" ]
OutputDir = "videos/Odysee/%Channel%/"
OutputDir = "videos2/%Channel%/"
FileName = "%Timestamp% - %Title%.mp4"
CFormat = "mp4"
VideoFormat = "best[height<=720]"
NumVideos = 5
SizeLimit = 200000000
[Group.YouTubeMusic]
[Group.Music]
URL = [ "https://www.youtube.com/@NoCopyrightSounds", "https://www.youtube.com/@incompetech_kmac" ]
OutputDir = "videos/Music/%Channel%/"
OutputDir = "music/%Channel%/"
FileName = "%Title%.webm"
CFormat = "webm"
AudioFormat = "bestaudio"
@ -30,12 +30,3 @@ SizeLimit = 10000000
Filters = [
{Name = "No Shorts", Input = "%Playlist%", Pattern = ".*- Shorts$", AllowDeny = false}
]
[Group.OdyseeAudio]
URL = [ "https://odysee.com/@DistroTube:2", "https://odysee.com/@AlphaNerd:8" ]
OutputDir = "videos/Audio/%Channel%/"
FileName = "%Timestamp% - %Title%.m4a"
CFormat = "ipod"
ExtractFormat = "best"
NumVideos = 5
SizeLimit = 10000000

View file

@ -43,11 +43,7 @@ func downloadVideo(url string, path string, group GroupConfig) (err error) {
log.Debugf("URL \"%s\" exists.", url)
video, err := goutubedl.New(context.Background(), url, goutubedl.Options{
MergeOutputFormat: "",
DownloadSubtitles: group.DownloadSubtitles,
DownloadThumbnail: group.DownloadThumbnails,
})
video, err := goutubedl.New(context.Background(), url, goutubedl.Options{})
if err != nil {
return err
}
@ -82,28 +78,7 @@ func downloadVideo(url string, path string, group GroupConfig) (err error) {
}
/* AUDIO */
if group.ExtractFormat != "" {
log.Debugf("Extracting audio from \"%s\" with format \"%s\"", video.Info.ID, group.ExtractFormat)
audioDLResult, err := video.Download(context.Background(), group.ExtractFormat)
if err != nil {
return err
}
defer audioDLResult.Close()
file, err := os.OpenFile(tempPath+"-extract", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
if err != nil {
return err
}
defer file.Close()
io.Copy(file, audioDLResult)
audioDLResult.Close()
file.Close()
} else if group.AudioFormat != "" {
if group.AudioFormat != "" {
log.Debugf("Downloading audio \"%s\" with format \"%s\"", video.Info.ID, group.AudioFormat)
audioDLResult, err := video.Download(context.Background(), group.AudioFormat)
@ -137,14 +112,6 @@ func downloadVideo(url string, path string, group GroupConfig) (err error) {
if err := os.Remove(tempPath+"-audio"); err != nil {
log.Warnf("Could not remove file \"%s\"", tempPath+"-audio")
}
} else if group.ExtractFormat != "" {
if err := extractAudio(tempPath+"-extract", group.CFormat, path); err != nil {
log.Errorf("Could not extract audio from \"%s\" to \"%s\"", tempPath+"-extract", path)
}
if err := os.Remove(tempPath+"-extract"); err != nil {
log.Warnf("Could not remove file \"%s\"", tempPath+"-extract")
}
} else if group.VideoFormat != "" {
copyFile(tempPath+"-vid", path)

View file

@ -29,26 +29,3 @@ func mergeStreams(path1 string, path2 string, format string, output string) (err
return ffmpeg.Output(input, output, kwArgs).OverWriteOutput().ErrorToStdOut().Silent(silent).Run()
}
func extractAudio(path1 string, format string, output string) (err error) {
input := []*ffmpeg.Stream{ffmpeg.Input(path1)}
defaultArgs := ffmpeg.KwArgs{"map": "0:a", "c:a": "copy", "format": format}
var ffmpegLogLevel ffmpeg.KwArgs
var silent bool
if Flags.Verbose {
ffmpegLogLevel = ffmpeg.KwArgs{"v": "info"}
silent = false
} else if Flags.Quiet {
ffmpegLogLevel = ffmpeg.KwArgs{"v": "quiet"}
silent = true
} else {
ffmpegLogLevel = ffmpeg.KwArgs{"v": "error"}
silent = true
}
kwArgs := ffmpeg.MergeKwArgs([]ffmpeg.KwArgs{ffmpegLogLevel, defaultArgs})
return ffmpeg.Output(input, output, kwArgs).OverWriteOutput().ErrorToStdOut().Silent(silent).Run()
}

21
ytva.go
View file

@ -41,18 +41,15 @@ type _config struct {
}
type GroupConfig struct {
URL []string
OutputDir string
FileName string
CFormat string
ExtractFormat string
VideoFormat string
AudioFormat string
DownloadSubtitles bool // Currently useless
DownloadThumbnails bool // Currently useless
NumVideos uint
SizeLimit float64
Filters []struct {
URL []string
OutputDir string
FileName string
CFormat string
VideoFormat string
AudioFormat string
NumVideos uint
SizeLimit float64
Filters []struct {
Name string
Input string
Pattern string