diff options
-rw-r--r-- | cite.c | 30 |
1 files changed, 26 insertions, 4 deletions
@@ -15,6 +15,7 @@ typedef struct { char nationality[256]; char pitch[2048]; char poster[256]; + char week_times[4096]; char times[4096]; } Movie; @@ -23,8 +24,12 @@ CURL *curl = NULL; static void print_style(void) { + puts("<!DOCTYPE html>"); + puts("<html>"); + puts("<head>"); puts("<meta charset=\"UTF-8\">"); puts("<link rel='stylesheet' type='text/css' href='https://kdx.re/theme.css'/>"); + puts("</head>"); } static void print_times(Movie *movie) @@ -129,11 +134,13 @@ static int set_movie_base_fields(Movie *movie, const xmlNode *node) const xmlChar *nationality = xmlGetProp(node, "nationalite"); const xmlChar *pitch = xmlGetProp(node, "synopsis"); const xmlChar *poster = xmlGetProp(node, "affichette"); + const xmlChar *week_times = xmlNodeGetContent(times_node); const xmlChar *times = xmlNodeGetContent(times_node->next); if (title == NULL || og_title == NULL || directors == NULL || actors == NULL || prod_year == NULL || release_date == NULL || duration == NULL || main_genres == NULL || nationality == NULL || - pitch == NULL || poster == NULL || times == NULL) { + pitch == NULL || poster == NULL || week_times == NULL || + times == NULL) { err = 1; goto set_fields_panic; } @@ -148,7 +155,10 @@ static int set_movie_base_fields(Movie *movie, const xmlNode *node) strncpy(movie->nationality, nationality, sizeof(movie->nationality) - 1); strncpy(movie->pitch, pitch, sizeof(movie->pitch) - 1); strncpy(movie->poster, poster, sizeof(movie->poster) - 1); - strncpy(movie->times, times, sizeof(movie->times) - 1); + strncpy(movie->week_times, week_times, sizeof(movie->week_times) - 1); + strcpy(movie->times, "<b>"); + strncat(movie->times, times, sizeof(movie->times) - 1); + strncat(movie->times, "</b>", sizeof(movie->times) - 1); set_fields_panic: xfree(title); xfree(og_title); @@ -161,6 +171,8 @@ set_fields_panic: xfree(nationality); xfree(pitch); xfree(poster); + xfree(week_times); + xfree(times); return err; } @@ -169,11 +181,18 @@ static int append_movie_times(Movie *movie, const xmlNode *node) const xmlNode *times_node = node->children; if (times_node == NULL || times_node->next == NULL) return 1; + const xmlChar *week_times = xmlNodeGetContent(times_node); const xmlChar *times = xmlNodeGetContent(times_node->next); - if (times == NULL) + if (week_times == NULL || times == NULL) { + xfree(week_times); + xfree(times); return 1; + } + strncat(movie->week_times, "\n", sizeof(movie->week_times) - 1); + strncat(movie->week_times, week_times, sizeof(movie->week_times) - 1); strncat(movie->times, ";", sizeof(movie->times) - 1); strncat(movie->times, times, sizeof(movie->times) - 1); + xfree(week_times); xfree(times); return 0; } @@ -213,11 +232,14 @@ int main(int argc, char **argv) } } print_style(); - printf("<h1><a href=\"http://www.citebd.org/spip.php?film2912\">cinéma de la cité</a></h1>\n"); + puts("<body>"); + puts("<h1><a href=\"http://www.citebd.org/spip.php?film2912\">cinéma de la cité</a></h1>"); for (Movie *movie = movies; movie->id != 0; movie++) { download_poster(movie); print_movie(movie, atoi(argv[2])); } + puts("</body>"); + puts("</html>"); curl_easy_cleanup(curl); xmlFreeDoc(document); xmlCleanupParser(); |