change storage structure for seasons episodes
parent
da38522dc3
commit
5ac21eed3a
13
main.go
13
main.go
|
|
@ -45,18 +45,17 @@ func do(client *youtubedl.Client) error {
|
|||
}
|
||||
|
||||
for _, result := range results {
|
||||
target := fmt.Sprintf(
|
||||
"s%02d%02de%02d_%s.%%(ext)s",
|
||||
result.Date.Year()-2000,
|
||||
result.Date.Month(),
|
||||
result.Date.Day(),
|
||||
strings.Join(strings.Split(result.Title, " ")[2:], "_"),
|
||||
)
|
||||
seasonNumber := fmt.Sprintf("%02d%02d", result.Date.Year()-2000, result.Date.Month())
|
||||
episodeNumber := fmt.Sprintf("%02d", result.Date.Day())
|
||||
season := fmt.Sprintf("Season_%s", seasonNumber)
|
||||
episode := fmt.Sprintf("Episode_%s_-_%s", episodeNumber, strings.Join(strings.Split(result.Title, " ")[2:], "_"))
|
||||
target := fmt.Sprintf("%s/%s.%%(ext)s", season, episode)
|
||||
target = path.Join(config.Root, target)
|
||||
if _, err := os.Stat(strings.ReplaceAll(target, "%(ext)s", "mp4")); !os.IsNotExist(err) {
|
||||
log.Printf("already exists: %s", target)
|
||||
continue
|
||||
}
|
||||
os.MkdirAll(path.Dir(target), os.ModePerm)
|
||||
if err := client.Download(result.Link, target); err != nil {
|
||||
errs += ", " + err.Error()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue