From cf21d5cd74b98c0099731e1bb8580bc916b25f46 Mon Sep 17 00:00:00 2001 From: nedko Date: Tue, 10 Sep 2024 14:50:21 +0300 Subject: [PATCH] Fixed donwloader to work with direct cookie. Cleaned some files. --- .gitignore | 1 + README.md | 2 ++ curl_dl.cpp | 4 ++-- example_download.json | 7 ------- example_download2.json | 10 ---------- example_login.json | 4 ---- main.cpp | 6 ++++++ 7 files changed, 11 insertions(+), 23 deletions(-) delete mode 100644 example_download.json delete mode 100644 example_download2.json delete mode 100644 example_login.json diff --git a/.gitignore b/.gitignore index e7b0f39..5144836 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ config.json +cookies.txt mcat_dl* .vscode/* diff --git a/README.md b/README.md index 399ec1f..c95655b 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ See config_example.json for the template. Invoke `make` to compile. Requires libcurl. +Login via browser and export `cid` cookie to cookies.txt (Netscape format) + Invoke `mcat_dl` with catalog ID as extra arguments to download. # Download File Structure diff --git a/curl_dl.cpp b/curl_dl.cpp index 78e92ba..7d8b6de 100644 --- a/curl_dl.cpp +++ b/curl_dl.cpp @@ -185,13 +185,13 @@ bool CURL_DL::download(const string& url, ostream* out, curl_easy_reset(m_handle); // Enable cookie engine - curl_easy_setopt(m_handle, CURLOPT_COOKIEFILE, ""); + curl_easy_setopt(m_handle, CURLOPT_COOKIEFILE, "cookies.txt"); // Enable error messages curl_easy_setopt(m_handle, CURLOPT_ERRORBUFFER, m_error); // Set User-Agent - curl_easy_setopt(m_handle, CURLOPT_USERAGENT, "Internedko Archiver"); + curl_easy_setopt(m_handle, CURLOPT_USERAGENT, "Internedko Downloader"); if ((nullptr == params) || (params->count("no-redir") == 0)) { diff --git a/example_download.json b/example_download.json deleted file mode 100644 index 7e27848..0000000 --- a/example_download.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "comment": "This file will attempt to download MCLP001, MCLP001-X, MCLP002, ... MCLP010-X", - "prefix": "MCLP", - "suffix_try": "-X", - "start": 1, - "end": 10 -} diff --git a/example_download2.json b/example_download2.json deleted file mode 100644 index 87ef15d..0000000 --- a/example_download2.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "comment": "This file will attempt to download MCS1091, MCS1195, MCS1425, MCS1426", - "releases": - [ - "MCS1091", - "MCS1195", - "MCS1425", - "MCS1426" - ] -} diff --git a/example_login.json b/example_login.json deleted file mode 100644 index 40474d0..0000000 --- a/example_login.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "Email": "USER", - "Password": "PASS" -} diff --git a/main.cpp b/main.cpp index 981a1f6..324b848 100644 --- a/main.cpp +++ b/main.cpp @@ -160,12 +160,15 @@ int main(int argc, char **argv) json_extract(config, "eyed3_exec", eyed3_exec); json_extract(config, "metaflac_exec", metaflac_exec); + // Disable LOGIN +#if 0 ok = mcat.login(email, pass); if (!ok) { cout << "Could not login" << endl; return -1; } +#endif if (argc < 2) { @@ -331,11 +334,14 @@ int main(int argc, char **argv) } } + // Disable LOGOUT +#if 0 ok = mcat.logout(); if (!ok) { cout << "Could not log out" << endl; } +#endif return 0; }