diff options
author | kdx <kikoodx@paranoici.org> | 2023-01-13 04:29:37 +0100 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-01-13 04:29:37 +0100 |
commit | 363c3d51d2d54bbeadb2c247b54039ce574146c2 (patch) | |
tree | c3ac16df94f4a8ed78b144bcd0ae3c275f2d1c1d | |
parent | 002c67a1eb237141d98ff493d92e9d867123bffb (diff) | |
download | cite-scrapper-363c3d51d2d54bbeadb2c247b54039ce574146c2.tar.gz |
boring style & skip download flag
-rw-r--r-- | cite.c | 24 | ||||
-rwxr-xr-x | scrap.sh | 6 |
2 files changed, 22 insertions, 8 deletions
@@ -22,13 +22,21 @@ typedef struct { Movie movies[64] = {0}; CURL *curl = NULL; -static void print_style(void) +static void print_style(int boring_css) { 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'/>"); + if (boring_css) + puts("<style>img{max-width: 100%;}body{margin:40px auto;" + "max-width:550px;line-height:1.6;font-size:18px;" + "font-family:sans-serif;color:#444;}h1,h2,h3{" + "line-height:1.2;padding-top: 14px;}</style>"); + else + puts("<link rel='stylesheet' type='text/css' " + "href='https://kdx.re/theme.css'/>"); + /* doq's style */ puts("</head>"); } @@ -65,12 +73,16 @@ static void print_movie(Movie *movie, int hide_fr) printf("\n"); } -static void download_poster(Movie *movie) +static void download_poster(Movie *movie, int skip) { char out_path[512]; char *last_slash = movie->poster; while (strchr(last_slash, '/') != NULL) last_slash = strchr(last_slash, '/') + 1; + if (skip) { + strcpy(movie->poster, last_slash); + return; + } strcpy(out_path, "cite/"); strcat(out_path, last_slash); FILE *const fp = fopen(out_path, "wb"); @@ -199,7 +211,7 @@ static int append_movie_times(Movie *movie, const xmlNode *node) int main(int argc, char **argv) { - if (argc != 3) + if (argc != 5) return 1; xmlDoc *const document = xmlReadFile(argv[1], NULL, 0); if (document == NULL) { @@ -231,11 +243,11 @@ int main(int argc, char **argv) append_movie_times(movie, mov); } } - print_style(); + print_style(atoi(argv[3])); 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); + download_poster(movie, atoi(argv[4])); print_movie(movie, atoi(argv[2])); } puts("</body>"); @@ -2,6 +2,8 @@ ./build.sh || exit 1 curl -o seances.xml 'http://www.citebd.org/IMG/xml/allocineseances-4.xml' || exit 1 mkdir -p cite -./scrap seances.xml 0 >cite/index.html || exit 1 -./scrap seances.xml 1 >cite/nofr.html || exit 1 +./scrap seances.xml 0 0 0 >cite/index.html || exit 1 +./scrap seances.xml 1 0 1 >cite/nofr.html || exit 1 +./scrap seances.xml 0 1 1 >cite/boring.html || exit 1 +./scrap seances.xml 1 1 1 >cite/boringnofr.html || exit 1 rsync -rvu --delete cite root@kdx.re:/var/www/html |