Skip to content

Commit

Permalink
Update to GCC 14.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartatz committed Jun 24, 2024
1 parent aea16e4 commit 804231e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/m3u8errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ const char* m3u8err_getmessage(const int code) {
return "HTTP request failure";
case M3U8ERR_CURL_SETOPT_FAILURE:
return "Could not set options on HTTP client";
case M3U8ERR_CURL_SLIST_FAILURE:
return "Could not append item to list";
case M3U8ERR_FSTREAM_LOCK_FAILURE:
return "Could not lock file";
case M3U8ERR_FSTREAM_OPEN_FAILURE:
Expand Down
1 change: 1 addition & 0 deletions src/m3u8errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#define M3U8ERR_CURL_INIT_FAILURE -41 /* Could not initialize the HTTP client due to an unexpected error */
#define M3U8ERR_CURL_REQUEST_FAILURE -42 /* HTTP request failure */
#define M3U8ERR_CURL_SETOPT_FAILURE -43 /* Could not set options on HTTP client */
#define M3U8ERR_CURL_SLIST_FAILURE -779 /* Could not append item to list */

#define M3U8ERR_CURLM_ADD_FAILURE -44 /* Could not initialize the HTTP client due to an unexpected error */
#define M3U8ERR_CURLM_REMOVE_FAILURE -45 /* Could not initialize the HTTP client due to an unexpected error */
Expand Down
27 changes: 27 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ int main(int argc, argv_t* argv[]) {
char* directory = NULL;
char* name = NULL;

struct curl_slist* headers = NULL;

const char* file_extension = NULL;

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

download_options.retry = (size_t) value;
} else if (strcmp(argument->key, "H") == 0 || strcmp(argument->key, "header") == 0) {
struct curl_slist* tmp = NULL;

if (argument->value == NULL) {
err = M3U8ERR_CLI_ARGUMENT_VALUE_MISSING;
goto end;
}

tmp = curl_slist_append(headers, argument->value);

if (tmp == NULL) {
err = M3U8ERR_CURL_SLIST_FAILURE;
goto end;
}

headers = tmp;

cerror->code = curl_easy_setopt(client->curl, CURLOPT_HTTPHEADER, headers);

if (cerror->code != CURLE_OK) {
err = M3U8ERR_CURL_SETOPT_FAILURE;
goto end;
}
} else if (strcmp(argument->key, "o") == 0 || strcmp(argument->key, "output") == 0) {
if (argument->value == NULL) {
err = M3U8ERR_CLI_ARGUMENT_VALUE_MISSING;
Expand Down Expand Up @@ -1093,6 +1118,8 @@ int main(int argc, argv_t* argv[]) {
free(directory);
free(name);

curl_slist_free_all(headers);

sslcerts_unload_certificates();

show_cursor();
Expand Down
4 changes: 3 additions & 1 deletion src/program_help.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This file is auto-generated. Use the ../tools/program_help.h.py tool to regenera
#define PROGRAM_HELP_H

#define PROGRAM_HELP \
"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" \
"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" \
"\n" \
"A command-line utility to download contents from M3U8 playlists.\n" \
"\n" \
Expand All @@ -23,6 +23,8 @@ This file is auto-generated. Use the ../tools/program_help.h.py tool to regenera
" Send a custom Referer header to server.\n" \
" -r COUNT, --retry COUNT\n" \
" Specify how many times a failed HTTP request should be retried. Defaults to 0 (no retries).\n" \
" -H HEADER, --header HEADER\n" \
" Send a custom header to server. This argument can be specified multiple times.\n" \
" --debug Enable verbose logging of network requests for debugging purposes.\n" \
" -S, --list-streams List all available streams of the M3U8 playlist.\n" \
" --select-media MEDIA Select which media stream to download. By default, no additional media streams are downloaded.\n" \
Expand Down
8 changes: 8 additions & 0 deletions tools/program_help.h.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@
help = "Specify how many times a failed HTTP request should be retried. Defaults to 0 (no retries)."
)

parser.add_argument(
"-H",
"--header",
metavar = "HEADER",
required = False,
help = "Send a custom header to server. This argument can be specified multiple times."
)

parser.add_argument(
"--debug",
required = False,
Expand Down

0 comments on commit 804231e

Please sign in to comment.