Skip to content

Commit 804231e

Browse files
committed
Update to GCC 14.1.0
1 parent aea16e4 commit 804231e

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

src/m3u8errors.c

+2
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ const char* m3u8err_getmessage(const int code) {
9797
return "HTTP request failure";
9898
case M3U8ERR_CURL_SETOPT_FAILURE:
9999
return "Could not set options on HTTP client";
100+
case M3U8ERR_CURL_SLIST_FAILURE:
101+
return "Could not append item to list";
100102
case M3U8ERR_FSTREAM_LOCK_FAILURE:
101103
return "Could not lock file";
102104
case M3U8ERR_FSTREAM_OPEN_FAILURE:

src/m3u8errors.h

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#define M3U8ERR_CURL_INIT_FAILURE -41 /* Could not initialize the HTTP client due to an unexpected error */
5353
#define M3U8ERR_CURL_REQUEST_FAILURE -42 /* HTTP request failure */
5454
#define M3U8ERR_CURL_SETOPT_FAILURE -43 /* Could not set options on HTTP client */
55+
#define M3U8ERR_CURL_SLIST_FAILURE -779 /* Could not append item to list */
5556

5657
#define M3U8ERR_CURLM_ADD_FAILURE -44 /* Could not initialize the HTTP client due to an unexpected error */
5758
#define M3U8ERR_CURLM_REMOVE_FAILURE -45 /* Could not initialize the HTTP client due to an unexpected error */

src/main.c

+27
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ int main(int argc, argv_t* argv[]) {
177177
char* directory = NULL;
178178
char* name = NULL;
179179

180+
struct curl_slist* headers = NULL;
181+
180182
const char* file_extension = NULL;
181183

182184
size_t select_media_index = 0;
@@ -576,6 +578,29 @@ int main(int argc, argv_t* argv[]) {
576578
}
577579

578580
download_options.retry = (size_t) value;
581+
} else if (strcmp(argument->key, "H") == 0 || strcmp(argument->key, "header") == 0) {
582+
struct curl_slist* tmp = NULL;
583+
584+
if (argument->value == NULL) {
585+
err = M3U8ERR_CLI_ARGUMENT_VALUE_MISSING;
586+
goto end;
587+
}
588+
589+
tmp = curl_slist_append(headers, argument->value);
590+
591+
if (tmp == NULL) {
592+
err = M3U8ERR_CURL_SLIST_FAILURE;
593+
goto end;
594+
}
595+
596+
headers = tmp;
597+
598+
cerror->code = curl_easy_setopt(client->curl, CURLOPT_HTTPHEADER, headers);
599+
600+
if (cerror->code != CURLE_OK) {
601+
err = M3U8ERR_CURL_SETOPT_FAILURE;
602+
goto end;
603+
}
579604
} else if (strcmp(argument->key, "o") == 0 || strcmp(argument->key, "output") == 0) {
580605
if (argument->value == NULL) {
581606
err = M3U8ERR_CLI_ARGUMENT_VALUE_MISSING;
@@ -1093,6 +1118,8 @@ int main(int argc, argv_t* argv[]) {
10931118
free(directory);
10941119
free(name);
10951120

1121+
curl_slist_free_all(headers);
1122+
10961123
sslcerts_unload_certificates();
10971124

10981125
show_cursor();

src/program_help.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This file is auto-generated. Use the ../tools/program_help.h.py tool to regenera
66
#define PROGRAM_HELP_H
77

88
#define PROGRAM_HELP \
9-
"usage: kai [-h] [-v] -u URL [-k] [-A USER_AGENT] [-x URI] [--doh-url URL] [-e URL] [-r COUNT] [--debug] [-S] [--select-media MEDIA] [--select-stream VARIANT_STREAM] [--disable-autoselection] [--disable-progress-meter] [--prefer-ffmpegc] [-c CONCURRENCY] -o FILENAME\n" \
9+
"usage: kai [-h] [-v] -u URL [-k] [-A USER_AGENT] [-x URI] [--doh-url URL] [-e URL] [-r COUNT] [-H HEADER] [--debug] [-S] [--select-media MEDIA] [--select-stream VARIANT_STREAM] [--disable-autoselection] [--disable-progress-meter] [--prefer-ffmpegc] [-c CONCURRENCY] -o FILENAME\n" \
1010
"\n" \
1111
"A command-line utility to download contents from M3U8 playlists.\n" \
1212
"\n" \
@@ -23,6 +23,8 @@ This file is auto-generated. Use the ../tools/program_help.h.py tool to regenera
2323
" Send a custom Referer header to server.\n" \
2424
" -r COUNT, --retry COUNT\n" \
2525
" Specify how many times a failed HTTP request should be retried. Defaults to 0 (no retries).\n" \
26+
" -H HEADER, --header HEADER\n" \
27+
" Send a custom header to server. This argument can be specified multiple times.\n" \
2628
" --debug Enable verbose logging of network requests for debugging purposes.\n" \
2729
" -S, --list-streams List all available streams of the M3U8 playlist.\n" \
2830
" --select-media MEDIA Select which media stream to download. By default, no additional media streams are downloaded.\n" \

tools/program_help.h.py

+8
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@
8080
help = "Specify how many times a failed HTTP request should be retried. Defaults to 0 (no retries)."
8181
)
8282

83+
parser.add_argument(
84+
"-H",
85+
"--header",
86+
metavar = "HEADER",
87+
required = False,
88+
help = "Send a custom header to server. This argument can be specified multiple times."
89+
)
90+
8391
parser.add_argument(
8492
"--debug",
8593
required = False,

0 commit comments

Comments
 (0)