diff --git a/cinera/cinera.c b/cinera/cinera.c index a0c0242..bc51fa5 100644 --- a/cinera/cinera.c +++ b/cinera/cinera.c @@ -14,7 +14,7 @@ typedef struct version CINERA_APP_VERSION = { .Major = 0, .Minor = 5, - .Patch = 31 + .Patch = 32 }; // TODO(matt): Copy in the DB 3 stuff from cinera_working.c @@ -1162,10 +1162,11 @@ BuildCredits(buffer *CreditsMenu, bool *HasCreditsMenu, HMML_VideoMetaData *Meta { if(SearchCredentials(CreditsMenu, HasCreditsMenu, Metadata->member, "Host")) { - printf("No credentials for %s. Please contact matt@handmadedev.org with their:\n" + printf("No credentials for member %s. Please contact matt@handmadedev.org with their:\n" " Full name\n" " Homepage URL (optional)\n" " Financial support info, e.g. Patreon URL (optional)\n", Metadata->member); + return CreditsError_NoCredentials; } } else @@ -1176,6 +1177,7 @@ BuildCredits(buffer *CreditsMenu, bool *HasCreditsMenu, HMML_VideoMetaData *Meta " \n" " \n"); } + fprintf(stderr, "Missing \"member\" in the [video] node\n"); return CreditsError_NoHost; } @@ -1185,10 +1187,11 @@ BuildCredits(buffer *CreditsMenu, bool *HasCreditsMenu, HMML_VideoMetaData *Meta { if(SearchCredentials(CreditsMenu, HasCreditsMenu, Metadata->co_hosts[i], "Co-host")) { - printf("No credentials for %s. Please contact matt@handmadedev.org with their:\n" + printf("No credentials for co-host %s. Please contact matt@handmadedev.org with their:\n" " Full name\n" " Homepage URL (optional)\n" " Financial support info, e.g. Patreon URL (optional)\n", Metadata->co_hosts[i]); + return CreditsError_NoCredentials; } } } @@ -1199,10 +1202,11 @@ BuildCredits(buffer *CreditsMenu, bool *HasCreditsMenu, HMML_VideoMetaData *Meta { if(SearchCredentials(CreditsMenu, HasCreditsMenu, Metadata->guests[i], "Guest")) { - printf("No credentials for %s. Please contact matt@handmadedev.org with their:\n" + printf("No credentials for guest %s. Please contact matt@handmadedev.org with their:\n" " Full name\n" " Homepage URL (optional)\n" " Financial support info, e.g. Patreon URL (optional)\n", Metadata->guests[i]); + return CreditsError_NoCredentials; } } } @@ -1213,10 +1217,11 @@ BuildCredits(buffer *CreditsMenu, bool *HasCreditsMenu, HMML_VideoMetaData *Meta { if(SearchCredentials(CreditsMenu, HasCreditsMenu, Metadata->annotators[i], "Annotator")) { - printf("No credentials for %s. Please contact matt@handmadedev.org with their:\n" + printf("No credentials for annotator %s. Please contact matt@handmadedev.org with their:\n" " Full name\n" " Homepage URL (optional)\n" " Financial support info, e.g. Patreon URL (optional)\n", Metadata->annotators[i]); + return CreditsError_NoCredentials; } } } @@ -1228,6 +1233,7 @@ BuildCredits(buffer *CreditsMenu, bool *HasCreditsMenu, HMML_VideoMetaData *Meta " \n" " \n"); } + fprintf(stderr, "Missing \"annotator\" in the [video] node\n"); return CreditsError_NoAnnotator; } @@ -1238,7 +1244,7 @@ BuildCredits(buffer *CreditsMenu, bool *HasCreditsMenu, HMML_VideoMetaData *Meta " \n"); } - return 0; + return RC_SUCCESS; } int @@ -2275,6 +2281,16 @@ MediumExists(char *Medium) return FALSE; } +#define HMMLCleanup() \ + DeclaimBuffer(&FilterState); \ + DeclaimBuffer(&CreditsMenu); \ + DeclaimBuffer(&FilterMedia); \ + DeclaimBuffer(&FilterTopics); \ + DeclaimBuffer(&FilterMenu); \ + DeclaimBuffer(&ReferenceMenu); \ + DeclaimBuffer(&QuoteMenu); \ + hmml_free(&HMML); + int HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filename) { @@ -2468,22 +2484,14 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen "
\n" "
\n", HMML.metadata.id, StringsDiffer(Config.Theme, "") ? Config.Theme : HMML.metadata.project); - int CreditsErrorCode = BuildCredits(&CreditsMenu, &HasCreditsMenu, &HMML.metadata); - if(CreditsErrorCode) + switch(BuildCredits(&CreditsMenu, &HasCreditsMenu, &HMML.metadata)) { - switch(CreditsErrorCode) - { - case CreditsError_NoHost: - fprintf(stderr, "%s: Missing \"member\" in the [video] node. Skipping...\n", Filename); - goto Cleanup; - break; - case CreditsError_NoAnnotator: - fprintf(stderr, "%s: Missing \"annotator\" in the [video] node. Skipping...\n", Filename); - goto Cleanup; - break; - default: - break; - } + case CreditsError_NoHost: + case CreditsError_NoAnnotator: + case CreditsError_NoCredentials: + fprintf(stderr, "\e[1;31mSkipping\e[0m %s - %s\n", BaseFilename, HMML.metadata.title); + HMMLCleanup(); + return RC_ERROR_HMML; } if(Config.Edition != EDITION_SINGLE) @@ -2500,6 +2508,7 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen printf("\n\n --- Entering Annotations Loop ---\n\n\n\n"); #endif + int PreviousTimecode = 0; for(int AnnotationIndex = 0; AnnotationIndex < HMML.annotation_count; ++AnnotationIndex) { #if DEBUG @@ -2508,6 +2517,17 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen HMML_Annotation *Anno = HMML.annotations + AnnotationIndex; + if(TimecodeToSeconds(Anno->time) < PreviousTimecode) + { + fprintf(stderr, "%s:%d: Timecode %s is chronologically before previous timecode\n" + "\e[1;31mSkipping\e[0m %s - %s\n", + Filename, Anno->line, Anno->time, + BaseFilename, HMML.metadata.title); + HMMLCleanup(); + return RC_ERROR_HMML; + } + PreviousTimecode = TimecodeToSeconds(Anno->time); + if(Config.Edition != EDITION_SINGLE) { CopyStringToBuffer(&CollationBuffers->Search, "\"%d\": \"", TimecodeToSeconds(Anno->time)); @@ -2530,6 +2550,7 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen // Text // CategoryIcons + // TODO(matt): Shouldn't all of these guys DeclaimBuffer() before returning? if(ClaimBuffer(&Annotation, "Annotation", Kilobytes(8)) == RC_ARENA_FULL) { hmml_free(&HMML); return RC_ARENA_FULL; }; if(ClaimBuffer(&AnnotationHeader, "AnnotationHeader", 512) == RC_ARENA_FULL) { hmml_free(&HMML); return RC_ARENA_FULL; }; if(ClaimBuffer(&AnnotationClass, "AnnotationClass", 256) == RC_ARENA_FULL) { hmml_free(&HMML); return RC_ARENA_FULL; }; @@ -3626,7 +3647,6 @@ AppendedIdentifier: // ReferenceMenu // QuoteMenu -Cleanup: DeclaimBuffer(&FilterState); DeclaimBuffer(&CreditsMenu);