Compare commits
4 commits
5e9774f70d
...
5e569df5ab
Author | SHA1 | Date | |
---|---|---|---|
5e569df5ab | |||
f62e8232d6 | |||
1d454fb886 | |||
7c72c89950 |
4 changed files with 83 additions and 15 deletions
|
@ -2,7 +2,7 @@ TempDir = "/tmp/"
|
||||||
|
|
||||||
[Group.LinuxYouTubers]
|
[Group.LinuxYouTubers]
|
||||||
URL = [ "https://www.youtube.com/@DistroTube", "https://www.youtube.com/@MentalOutlaw" ]
|
URL = [ "https://www.youtube.com/@DistroTube", "https://www.youtube.com/@MentalOutlaw" ]
|
||||||
OutputDir = "videos/%Channel%/%Playlist%/"
|
OutputDir = "videos/Linux/%Channel%/%Playlist%/"
|
||||||
FileName = "%Timestamp% - %Title%.mkv"
|
FileName = "%Timestamp% - %Title%.mkv"
|
||||||
CFormat = "matroska"
|
CFormat = "matroska"
|
||||||
VideoFormat = "bestvideo[height<=720]"
|
VideoFormat = "bestvideo[height<=720]"
|
||||||
|
@ -12,16 +12,16 @@ SizeLimit = 200000000
|
||||||
|
|
||||||
[Group.Odysee]
|
[Group.Odysee]
|
||||||
URL = [ "https://odysee.com/@DistroTube:2", "https://odysee.com/@AlphaNerd:8" ]
|
URL = [ "https://odysee.com/@DistroTube:2", "https://odysee.com/@AlphaNerd:8" ]
|
||||||
OutputDir = "videos2/%Channel%/"
|
OutputDir = "videos/Odysee/%Channel%/"
|
||||||
FileName = "%Timestamp% - %Title%.mp4"
|
FileName = "%Timestamp% - %Title%.mp4"
|
||||||
CFormat = "mp4"
|
CFormat = "mp4"
|
||||||
VideoFormat = "best[height<=720]"
|
VideoFormat = "best[height<=720]"
|
||||||
NumVideos = 5
|
NumVideos = 5
|
||||||
SizeLimit = 200000000
|
SizeLimit = 200000000
|
||||||
|
|
||||||
[Group.Music]
|
[Group.YouTubeMusic]
|
||||||
URL = [ "https://www.youtube.com/@NoCopyrightSounds", "https://www.youtube.com/@incompetech_kmac" ]
|
URL = [ "https://www.youtube.com/@NoCopyrightSounds", "https://www.youtube.com/@incompetech_kmac" ]
|
||||||
OutputDir = "music/%Channel%/"
|
OutputDir = "videos/Music/%Channel%/"
|
||||||
FileName = "%Title%.webm"
|
FileName = "%Title%.webm"
|
||||||
CFormat = "webm"
|
CFormat = "webm"
|
||||||
AudioFormat = "bestaudio"
|
AudioFormat = "bestaudio"
|
||||||
|
@ -30,3 +30,12 @@ SizeLimit = 10000000
|
||||||
Filters = [
|
Filters = [
|
||||||
{Name = "No Shorts", Input = "%Playlist%", Pattern = ".*- Shorts$", AllowDeny = false}
|
{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
|
||||||
|
|
37
download.go
37
download.go
|
@ -43,7 +43,11 @@ func downloadVideo(url string, path string, group GroupConfig) (err error) {
|
||||||
|
|
||||||
log.Debugf("URL \"%s\" exists.", url)
|
log.Debugf("URL \"%s\" exists.", url)
|
||||||
|
|
||||||
video, err := goutubedl.New(context.Background(), url, goutubedl.Options{})
|
video, err := goutubedl.New(context.Background(), url, goutubedl.Options{
|
||||||
|
MergeOutputFormat: "",
|
||||||
|
DownloadSubtitles: group.DownloadSubtitles,
|
||||||
|
DownloadThumbnail: group.DownloadThumbnails,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -78,7 +82,28 @@ func downloadVideo(url string, path string, group GroupConfig) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* AUDIO */
|
/* AUDIO */
|
||||||
if group.AudioFormat != "" {
|
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 != "" {
|
||||||
log.Debugf("Downloading audio \"%s\" with format \"%s\"", video.Info.ID, group.AudioFormat)
|
log.Debugf("Downloading audio \"%s\" with format \"%s\"", video.Info.ID, group.AudioFormat)
|
||||||
|
|
||||||
audioDLResult, err := video.Download(context.Background(), group.AudioFormat)
|
audioDLResult, err := video.Download(context.Background(), group.AudioFormat)
|
||||||
|
@ -112,6 +137,14 @@ func downloadVideo(url string, path string, group GroupConfig) (err error) {
|
||||||
if err := os.Remove(tempPath+"-audio"); err != nil {
|
if err := os.Remove(tempPath+"-audio"); err != nil {
|
||||||
log.Warnf("Could not remove file \"%s\"", tempPath+"-audio")
|
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 != "" {
|
} else if group.VideoFormat != "" {
|
||||||
copyFile(tempPath+"-vid", path)
|
copyFile(tempPath+"-vid", path)
|
||||||
|
|
||||||
|
|
23
ffmpeg.go
23
ffmpeg.go
|
@ -29,3 +29,26 @@ func mergeStreams(path1 string, path2 string, format string, output string) (err
|
||||||
|
|
||||||
return ffmpeg.Output(input, output, kwArgs).OverWriteOutput().ErrorToStdOut().Silent(silent).Run()
|
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
21
ytva.go
|
@ -41,15 +41,18 @@ type _config struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupConfig struct {
|
type GroupConfig struct {
|
||||||
URL []string
|
URL []string
|
||||||
OutputDir string
|
OutputDir string
|
||||||
FileName string
|
FileName string
|
||||||
CFormat string
|
CFormat string
|
||||||
VideoFormat string
|
ExtractFormat string
|
||||||
AudioFormat string
|
VideoFormat string
|
||||||
NumVideos uint
|
AudioFormat string
|
||||||
SizeLimit float64
|
DownloadSubtitles bool // Currently useless
|
||||||
Filters []struct {
|
DownloadThumbnails bool // Currently useless
|
||||||
|
NumVideos uint
|
||||||
|
SizeLimit float64
|
||||||
|
Filters []struct {
|
||||||
Name string
|
Name string
|
||||||
Input string
|
Input string
|
||||||
Pattern string
|
Pattern string
|
||||||
|
|
Loading…
Add table
Reference in a new issue