cinera.c: Validate timecode chronology
Also correctly skip .hmml files for credentials-related reasons
This commit is contained in:
parent
1603245fad
commit
9d9d8a6332
|
@ -14,7 +14,7 @@ typedef struct
|
||||||
version CINERA_APP_VERSION = {
|
version CINERA_APP_VERSION = {
|
||||||
.Major = 0,
|
.Major = 0,
|
||||||
.Minor = 5,
|
.Minor = 5,
|
||||||
.Patch = 31
|
.Patch = 32
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO(matt): Copy in the DB 3 stuff from cinera_working.c
|
// 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"))
|
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"
|
" Full name\n"
|
||||||
" Homepage URL (optional)\n"
|
" Homepage URL (optional)\n"
|
||||||
" Financial support info, e.g. Patreon URL (optional)\n", Metadata->member);
|
" Financial support info, e.g. Patreon URL (optional)\n", Metadata->member);
|
||||||
|
return CreditsError_NoCredentials;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1176,6 +1177,7 @@ BuildCredits(buffer *CreditsMenu, bool *HasCreditsMenu, HMML_VideoMetaData *Meta
|
||||||
" </div>\n"
|
" </div>\n"
|
||||||
" </div>\n");
|
" </div>\n");
|
||||||
}
|
}
|
||||||
|
fprintf(stderr, "Missing \"member\" in the [video] node\n");
|
||||||
return CreditsError_NoHost;
|
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"))
|
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"
|
" Full name\n"
|
||||||
" Homepage URL (optional)\n"
|
" Homepage URL (optional)\n"
|
||||||
" Financial support info, e.g. Patreon URL (optional)\n", Metadata->co_hosts[i]);
|
" 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"))
|
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"
|
" Full name\n"
|
||||||
" Homepage URL (optional)\n"
|
" Homepage URL (optional)\n"
|
||||||
" Financial support info, e.g. Patreon URL (optional)\n", Metadata->guests[i]);
|
" 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"))
|
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"
|
" Full name\n"
|
||||||
" Homepage URL (optional)\n"
|
" Homepage URL (optional)\n"
|
||||||
" Financial support info, e.g. Patreon URL (optional)\n", Metadata->annotators[i]);
|
" 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
|
||||||
" </div>\n"
|
" </div>\n"
|
||||||
" </div>\n");
|
" </div>\n");
|
||||||
}
|
}
|
||||||
|
fprintf(stderr, "Missing \"annotator\" in the [video] node\n");
|
||||||
return CreditsError_NoAnnotator;
|
return CreditsError_NoAnnotator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1238,7 +1244,7 @@ BuildCredits(buffer *CreditsMenu, bool *HasCreditsMenu, HMML_VideoMetaData *Meta
|
||||||
" </div>\n");
|
" </div>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return RC_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -2275,6 +2281,16 @@ MediumExists(char *Medium)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define HMMLCleanup() \
|
||||||
|
DeclaimBuffer(&FilterState); \
|
||||||
|
DeclaimBuffer(&CreditsMenu); \
|
||||||
|
DeclaimBuffer(&FilterMedia); \
|
||||||
|
DeclaimBuffer(&FilterTopics); \
|
||||||
|
DeclaimBuffer(&FilterMenu); \
|
||||||
|
DeclaimBuffer(&ReferenceMenu); \
|
||||||
|
DeclaimBuffer(&QuoteMenu); \
|
||||||
|
hmml_free(&HMML);
|
||||||
|
|
||||||
int
|
int
|
||||||
HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filename)
|
HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filename)
|
||||||
{
|
{
|
||||||
|
@ -2468,22 +2484,14 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen
|
||||||
" <div class=\"video_container\" data-videoId=\"%s\"></div>\n"
|
" <div class=\"video_container\" data-videoId=\"%s\"></div>\n"
|
||||||
" <div class=\"markers_container %s\">\n", HMML.metadata.id, StringsDiffer(Config.Theme, "") ? Config.Theme : HMML.metadata.project);
|
" <div class=\"markers_container %s\">\n", HMML.metadata.id, StringsDiffer(Config.Theme, "") ? Config.Theme : HMML.metadata.project);
|
||||||
|
|
||||||
int CreditsErrorCode = BuildCredits(&CreditsMenu, &HasCreditsMenu, &HMML.metadata);
|
switch(BuildCredits(&CreditsMenu, &HasCreditsMenu, &HMML.metadata))
|
||||||
if(CreditsErrorCode)
|
|
||||||
{
|
{
|
||||||
switch(CreditsErrorCode)
|
case CreditsError_NoHost:
|
||||||
{
|
case CreditsError_NoAnnotator:
|
||||||
case CreditsError_NoHost:
|
case CreditsError_NoCredentials:
|
||||||
fprintf(stderr, "%s: Missing \"member\" in the [video] node. Skipping...\n", Filename);
|
fprintf(stderr, "\e[1;31mSkipping\e[0m %s - %s\n", BaseFilename, HMML.metadata.title);
|
||||||
goto Cleanup;
|
HMMLCleanup();
|
||||||
break;
|
return RC_ERROR_HMML;
|
||||||
case CreditsError_NoAnnotator:
|
|
||||||
fprintf(stderr, "%s: Missing \"annotator\" in the [video] node. Skipping...\n", Filename);
|
|
||||||
goto Cleanup;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config.Edition != EDITION_SINGLE)
|
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");
|
printf("\n\n --- Entering Annotations Loop ---\n\n\n\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int PreviousTimecode = 0;
|
||||||
for(int AnnotationIndex = 0; AnnotationIndex < HMML.annotation_count; ++AnnotationIndex)
|
for(int AnnotationIndex = 0; AnnotationIndex < HMML.annotation_count; ++AnnotationIndex)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
@ -2508,6 +2517,17 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen
|
||||||
|
|
||||||
HMML_Annotation *Anno = HMML.annotations + AnnotationIndex;
|
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)
|
if(Config.Edition != EDITION_SINGLE)
|
||||||
{
|
{
|
||||||
CopyStringToBuffer(&CollationBuffers->Search, "\"%d\": \"", TimecodeToSeconds(Anno->time));
|
CopyStringToBuffer(&CollationBuffers->Search, "\"%d\": \"", TimecodeToSeconds(Anno->time));
|
||||||
|
@ -2530,6 +2550,7 @@ HMMLToBuffers(buffers *CollationBuffers, template **BespokeTemplate, char *Filen
|
||||||
// Text
|
// Text
|
||||||
// CategoryIcons
|
// 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(&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(&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; };
|
if(ClaimBuffer(&AnnotationClass, "AnnotationClass", 256) == RC_ARENA_FULL) { hmml_free(&HMML); return RC_ARENA_FULL; };
|
||||||
|
@ -3626,7 +3647,6 @@ AppendedIdentifier:
|
||||||
// ReferenceMenu
|
// ReferenceMenu
|
||||||
// QuoteMenu
|
// QuoteMenu
|
||||||
|
|
||||||
Cleanup:
|
|
||||||
DeclaimBuffer(&FilterState);
|
DeclaimBuffer(&FilterState);
|
||||||
|
|
||||||
DeclaimBuffer(&CreditsMenu);
|
DeclaimBuffer(&CreditsMenu);
|
||||||
|
|
Loading…
Reference in New Issue