Helper tool for stitching together livestream VOD segments and uploading them to YouTube!

add warnings for exceeding metadata character length

+29 -13
+29 -13
main.go
··· 26 26 //go:embed res/help.txt 27 27 var helpText string 28 28 29 - const segmentExtension = "mkv" 29 + const SEGMENT_EXTENSION = "mkv" 30 + const MAX_TITLE_LEN = 100 31 + const MAX_DESCRIPTION_LEN = 5000 30 32 31 33 func showHelp() { 32 34 fmt.Println(helpText) ··· 194 196 } 195 197 196 198 // scan for VOD segments 197 - vodFiles, err := scanner.ScanSegments(metadata.FootageDir, segmentExtension) 199 + vodFiles, err := scanner.ScanSegments(metadata.FootageDir, SEGMENT_EXTENSION) 198 200 if err != nil { 199 201 log.Fatalf("Failed to fetch VOD filenames: %v", err) 200 202 os.Exit(1) ··· 202 204 if len(vodFiles) == 0 { 203 205 log.Fatalf( 204 206 "Directory contained no VOD files (expecting .%s)", 205 - segmentExtension, 207 + SEGMENT_EXTENSION, 206 208 ) 207 209 os.Exit(1) 208 210 } ··· 221 223 log.Fatalf("Failed to build video template: %v", err) 222 224 os.Exit(1) 223 225 } 226 + title, err := yt.BuildTemplate(video, templates.Title) 227 + if err != nil { 228 + log.Fatalf("Failed to build video title: %v", err) 229 + os.Exit(1) 230 + } 231 + description, err := yt.BuildTemplate(video, templates.Description) 232 + if err != nil { 233 + log.Fatalf("Failed to build video description: %v", err) 234 + os.Exit(1) 235 + } 236 + if len(title) > 100 { 237 + log.Fatalf( 238 + "Video title length exceeds %d characters (%d). YouTube may reject this!", 239 + MAX_TITLE_LEN, 240 + len(video.Title), 241 + ) 242 + } 243 + if len(description) > 5000 { 244 + log.Fatalf( 245 + "Video description length exceeds %d characters (%d). YouTube may reject this!", 246 + MAX_DESCRIPTION_LEN, 247 + len(description), 248 + ) 249 + } 224 250 if verbose { 225 251 enc := json.NewEncoder(os.Stdout) 226 252 fmt.Printf("\nVideo template: ") 227 253 enc.Encode(video) 228 254 229 - title, err := yt.BuildTemplate(video, templates.Title) 230 - if err != nil { 231 - log.Fatalf("Failed to build video title: %v", err) 232 - os.Exit(1) 233 - } 234 - description, err := yt.BuildTemplate(video, templates.Description) 235 - if err != nil { 236 - log.Fatalf("Failed to build video description: %v", err) 237 - os.Exit(1) 238 - } 239 255 fmt.Printf( 240 256 "\n================================\n\n" + 241 257 "< TITLE >\n%s\n\n" +