automatically upload nearby thumbnail.png

This commit is contained in:
ari melody 2026-06-23 18:28:50 +01:00
parent fc1d6b20c1
commit 2fcbc31f77
Signed by: ari
GPG key ID: 60B5F0386E3DDB7E
4 changed files with 75 additions and 19 deletions

17
main.go
View file

@ -216,6 +216,17 @@ func main() {
enc.Encode(vodFiles)
}
// scan for thumbnail
thumbnailPath, thumbnailSizeBytes, err := scanner.ScanThumbnail(directory)
if err != nil {
log.Fatalf("Failed to fetch thumbnail: %v", err)
os.Exit(1)
}
thumbnail := &yt.Thumbnail{
Filepath: thumbnailPath,
SizeBytes: thumbnailSizeBytes,
}
// build video template for upload
video, err := yt.BuildVideo(metadata)
if err != nil {
@ -263,7 +274,7 @@ func main() {
// concatenate VOD segments into full VOD
fullVodExists := func () bool {
// check if full VOD already exists with expected duration
fullVodProbe, err := scanner.ProbeSegment(video.Filename)
fullVodProbe, err := scanner.ProbeSegment(video.Filepath)
if err != nil { return false }
video.SizeBytes = fullVodProbe.Format.Size
var totalLength float64 = 0
@ -317,7 +328,7 @@ func main() {
}
// okay actually upload now!
ytVideo, err := yt.UploadVideo(ctx, tokenSource, video, templates)
ytVideo, err := yt.UploadVideo(ctx, tokenSource, video, thumbnail, templates)
if err != nil {
log.Fatalf("Failed to upload video: %v", err)
os.Exit(1)
@ -341,7 +352,7 @@ func main() {
// delete full VOD after upload, if requested
if deleteFullVod {
err = os.Remove(video.Filename)
err = os.Remove(video.Filepath)
if err != nil {
log.Fatalf("Failed to delete full VOD: %v", err)
}