initial: modular iptv-dl with runtime config from ~/.iptv-downloader/config.json
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#include "server.h"
|
||||
#include "http.h"
|
||||
#include "handlers.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void *handle_conn(void *arg) {
|
||||
int fd = *(int*)arg; free(arg);
|
||||
Req req;
|
||||
if (parse_request(fd, &req) < 0) { close(fd); return NULL; }
|
||||
|
||||
if (strcmp(req.method, "GET") == 0) {
|
||||
if (!strcmp(req.path,"/") || !strcmp(req.path,"")) handle_index(fd);
|
||||
else if (!strcmp(req.path,"/iptv.css")) send_css(fd);
|
||||
else if (!strcmp(req.path,"/series")) handle_series_cats(fd);
|
||||
else if (!strcmp(req.path,"/series/cat")) handle_series_list(fd, req.query);
|
||||
else if (!strcmp(req.path,"/series/show")) handle_series_show(fd, req.query);
|
||||
else if (!strcmp(req.path,"/movies")) handle_movie_cats(fd);
|
||||
else if (!strcmp(req.path,"/movies/cat")) handle_movie_list(fd, req.query);
|
||||
else if (!strcmp(req.path,"/search")) handle_search(fd, req.query);
|
||||
else if (!strcmp(req.path,"/downloads")) handle_downloads(fd);
|
||||
else if (!strcmp(req.path,"/api/downloads")) handle_api_downloads(fd);
|
||||
else if (!strcmp(req.path,"/api/notifications")) handle_api_notifications(fd);
|
||||
else {
|
||||
/* try static JS files */
|
||||
send_static_js(fd, req.path);
|
||||
}
|
||||
} else if (strcmp(req.method, "POST") == 0) {
|
||||
if (!strcmp(req.path,"/api/download")) handle_api_download(fd, req.body);
|
||||
else if (!strcmp(req.path,"/api/download_movie")) handle_api_download_movie(fd, req.body);
|
||||
else if (!strcmp(req.path,"/api/cancel")) handle_api_cancel(fd, req.body);
|
||||
else if (!strcmp(req.path,"/api/clear")) handle_api_clear(fd);
|
||||
else if (!strcmp(req.path,"/api/clear-cancelled")) handle_api_clear_cancelled(fd);
|
||||
else if (!strcmp(req.path,"/api/retry-interrupted")) handle_api_retry_interrupted(fd);
|
||||
else if (!strcmp(req.path,"/api/clean-partials")) handle_api_clean_partials(fd);
|
||||
else if (!strcmp(req.path,"/api/notifications/test")) handle_api_notifications_test(fd);
|
||||
else if (!strcmp(req.path,"/api/notifications/dismiss")) handle_api_notifications_dismiss(fd, req.body);
|
||||
else send_404(fd);
|
||||
} else send_404(fd);
|
||||
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
Reference in New Issue
Block a user