diff options
author | Mole Shang <[email protected]> | 2023-08-07 22:52:47 +0800 |
---|---|---|
committer | Mole Shang <[email protected]> | 2023-08-07 22:59:19 +0800 |
commit | 204ab98bea93754beef914fe93ee249e346ee628 (patch) | |
tree | c056c82f4de392be506ed2298dbb66411414e350 /src/process_url.c | |
parent | b6c2d97d3bf98c46656a7e6697c1c0f4686d7d97 (diff) | |
download | hinata-204ab98bea93754beef914fe93ee249e346ee628.tar.gz hinata-204ab98bea93754beef914fe93ee249e346ee628.tar.bz2 hinata-204ab98bea93754beef914fe93ee249e346ee628.zip |
hinata: support specifying cookies in curl_easy
We use tomlc99 to parse strings.
To use cookies for higher resolution video downloading, add a
config.toml in the executable path.
e.g.
```filename: config.toml
cookie="SESSDATA=xxx; some_more_cookie=xxx"
```
Diffstat (limited to 'src/process_url.c')
-rw-r--r-- | src/process_url.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/process_url.c b/src/process_url.c index bf2edfd..e51da98 100644 --- a/src/process_url.c +++ b/src/process_url.c @@ -39,6 +39,7 @@ mtx_t mtx; cnd_t cnd; bool corrupted; static const char *outdir_g, *referer_g; +static char *cookie_g; static callback_t callback_g; static callback_struct_t *p_callback_struct_g; static CURLU *h; @@ -113,6 +114,7 @@ static void curl_easy_setcommonopts(CURL *curl) { /* enable all supported built-in compressions, * since serveral sites enable gzip encoding */ curl_easy_setopt(curl, CURLOPT_ACCEPT_ENCODING, ""); + curl_easy_setopt(curl, CURLOPT_COOKIE, cookie_g); } static int progress_callback(void *clientp, curl_off_t dltotal, @@ -440,10 +442,11 @@ static char *callback_struct_convert_fullpath(char *filename) { return tmp; } -void curl_init(curl_conf_t *curl) { +void curl_init(char *cookie) { curl_global_init(CURL_GLOBAL_ALL); h = curl_url(); dl_queue = create_queue(); + cookie_g = cookie; mtx_init(&mtx, mtx_plain); cnd_init(&cnd); } @@ -467,6 +470,7 @@ void curl_cleanup(status_t *stat) { cnd_destroy(&cnd); } free_queue(&dl_queue); + free_and_nullify(cookie_g); curl_url_cleanup(h); curl_global_cleanup(); } |