Added filter rules
This commit is contained in:
parent
0c3104dfc8
commit
07b9fb4053
3 changed files with 59 additions and 21 deletions
32
config-sample.toml
Normal file
32
config-sample.toml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
TempDir = "/tmp/"
|
||||||
|
|
||||||
|
[Group.LinuxYouTubers]
|
||||||
|
URL = [ "https://www.youtube.com/@DistroTube", "https://www.youtube.com/@MentalOutlaw" ]
|
||||||
|
OutputDir = "videos/%Channel%/%Playlist%/"
|
||||||
|
FileName = "%Timestamp% - %Title%.mkv"
|
||||||
|
CFormat = "matroska"
|
||||||
|
VideoFormat = "bestvideo[height<=720]"
|
||||||
|
AudioFormat = "bestaudio"
|
||||||
|
NumVideos = 5
|
||||||
|
SizeLimit = 200000000
|
||||||
|
|
||||||
|
[Group.Odysee]
|
||||||
|
URL = [ "https://odysee.com/@DistroTube:2", "https://odysee.com/@AlphaNerd:8" ]
|
||||||
|
OutputDir = "videos2/%Channel%/"
|
||||||
|
FileName = "%Timestamp% - %Title%.mp4"
|
||||||
|
CFormat = "mp4"
|
||||||
|
VideoFormat = "best[height<=720]"
|
||||||
|
NumVideos = 5
|
||||||
|
SizeLimit = 200000000
|
||||||
|
|
||||||
|
[Group.Music]
|
||||||
|
URL = [ "https://www.youtube.com/@NoCopyrightSounds", "https://www.youtube.com/@incompetech_kmac" ]
|
||||||
|
OutputDir = "music/%Channel%/"
|
||||||
|
FileName = "%Title%.webm"
|
||||||
|
CFormat = "webm"
|
||||||
|
AudioFormat = "bestaudio"
|
||||||
|
NumVideos = 5
|
||||||
|
SizeLimit = 10000000
|
||||||
|
Filters = [
|
||||||
|
{Name = "No Shorts", Input = "%Playlist%", Pattern = ".*- Shorts$", AllowDeny = false}
|
||||||
|
]
|
21
config.toml
21
config.toml
|
@ -1,21 +0,0 @@
|
||||||
TempDir = "/tmp/"
|
|
||||||
|
|
||||||
[Group.PCBuilders]
|
|
||||||
URL = [ "https://www.youtube.com/@BudgetBuildsOfficial", "https://www.youtube.com/@RandomGaminginHD" ]
|
|
||||||
OutputDir = "videos/%Channel%/%Playlist%/"
|
|
||||||
FileName = "%Timestamp% - %Title%.mkv"
|
|
||||||
CFormat = "matroska"
|
|
||||||
VideoFormat = "bestvideo[height<=720]"
|
|
||||||
AudioFormat = "bestaudio"
|
|
||||||
NumVideos = 2
|
|
||||||
SizeLimit = 4294967296
|
|
||||||
|
|
||||||
[Group.Odysee]
|
|
||||||
URL = [ "https://odysee.com/@AlphaNerd:8", "https://odysee.com/@rossmanngroup:a" ]
|
|
||||||
OutputDir = "videos2/%Channel%/"
|
|
||||||
FileName = "%Timestamp% - %Title%.mkv"
|
|
||||||
CFormat = "mp4"
|
|
||||||
VideoFormat = "best[height<=720]"
|
|
||||||
AudioFormat = ""
|
|
||||||
NumVideos = 2
|
|
||||||
SizeLimit = 4294967296
|
|
27
ytva.go
27
ytva.go
|
@ -7,6 +7,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
//"io"
|
//"io"
|
||||||
//"reflect"
|
//"reflect"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
//"google.golang.org/api/option"
|
//"google.golang.org/api/option"
|
||||||
//"google.golang.org/api/youtube/v3"
|
//"google.golang.org/api/youtube/v3"
|
||||||
|
@ -47,6 +48,12 @@ type GroupConfig struct {
|
||||||
AudioFormat string
|
AudioFormat string
|
||||||
NumVideos uint
|
NumVideos uint
|
||||||
SizeLimit float64
|
SizeLimit float64
|
||||||
|
Filters []struct {
|
||||||
|
Name string
|
||||||
|
Input string
|
||||||
|
Pattern string
|
||||||
|
AllowDeny bool
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var MainConfig _config
|
var MainConfig _config
|
||||||
|
@ -116,15 +123,35 @@ func main() {
|
||||||
|
|
||||||
log.Infof("Channel Name: %s", channel.Info.Channel)
|
log.Infof("Channel Name: %s", channel.Info.Channel)
|
||||||
|
|
||||||
|
video:
|
||||||
for _, v := range channel.Info.Entries {
|
for _, v := range channel.Info.Entries {
|
||||||
log.Debugf("-------------------------------------")
|
log.Debugf("-------------------------------------")
|
||||||
log.Debugf("Title: %s", v.Title)
|
log.Debugf("Title: %s", v.Title)
|
||||||
|
log.Debugf("AltTitle: %s", v.AltTitle)
|
||||||
log.Debugf("URL: %s", v.WebpageURL)
|
log.Debugf("URL: %s", v.WebpageURL)
|
||||||
|
log.Debugf("URL: %s", v.URL)
|
||||||
log.Debugf("Playlist: %s", v.Playlist)
|
log.Debugf("Playlist: %s", v.Playlist)
|
||||||
log.Debugf("PublishedAt: %s", v.UploadDate)
|
log.Debugf("PublishedAt: %s", v.UploadDate)
|
||||||
log.Debugf("IsLive: %t", v.IsLive)
|
log.Debugf("IsLive: %t", v.IsLive)
|
||||||
//log.Debugf("Description: %s\n", item.Snippet.Description)
|
//log.Debugf("Description: %s\n", item.Snippet.Description)
|
||||||
|
|
||||||
|
if len(group.Filters) > 0 {
|
||||||
|
for _, filter := range group.Filters {
|
||||||
|
testStr := fillPlaceholders(filter.Input, v)
|
||||||
|
|
||||||
|
matched, err := regexp.MatchString(filter.Pattern, testStr)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matched && !filter.AllowDeny) || (!matched && filter.AllowDeny) {
|
||||||
|
log.Infof("Skipping \"%s\" due to filter rule \"%s\".", v.Title, filter.Name)
|
||||||
|
continue video
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dirPath := fillPlaceholders(group.OutputDir, v)
|
dirPath := fillPlaceholders(group.OutputDir, v)
|
||||||
fileName := fillPlaceholders(group.FileName, v)
|
fileName := fillPlaceholders(group.FileName, v)
|
||||||
path := dirPath+"/"+fileName
|
path := dirPath+"/"+fileName
|
||||||
|
|
Loading…
Reference in a new issue