77#include < string>
88#include < nlohmann/json.hpp>
99#include " wiki.hpp"
10- const std::string API=" http ://localhost:8080 /api.php" ;
10+ const std::string API=" https ://wiki.byrdocs.org /api.php" ;
1111const std::string LOGIN=" /tmp/wiki_login_cookies" ;
1212const std::string CSRF=" /tmp/wiki_csrf_cookies" ;
1313const std::list<std::string> HEADER{std::format (" X-Byrdocs-Token:{}" ,std::getenv (" WIKITOKEN" ))};
1414int main (int argc,char *argv[]){
1515 try {
16- std::string file_path{argv[1 ]};
17- std::filesystem::path fs_path{file_path};
1816 if (argc!=2 ){
1917 std::cout<<std::format (R"( Usage: {} <path-to-file>)" ,argv[0 ])<<std::endl;
2018 return 1 ;
2119 }
20+ std::string file_path{argv[1 ]};
21+ std::filesystem::path fs_path{file_path};
2222 const std::string login_token=wiki::get_login_token (API,LOGIN);
2323 wiki::login (
2424 API,
2525 LOGIN,
2626 " CppHusky@uploader" ,
2727 std::getenv (" WIKIPASS_UPLOADER" ),
28- login_token
28+ login_token,
29+ HEADER
2930 );
3031 std::clog<<std::format (" Logged in. Started uploading {}..." ,argv[1 ])<<std::endl;
3132 const std::string csrf_token=wiki::get_csrf_token (API,LOGIN,CSRF);
@@ -46,9 +47,11 @@ int main(int argc,char *argv[]){
4647 csrf_token,
4748 HEADER
4849 );
49- std::clog<<result<<std::endl;
50- if (result[" upload" ][" result" ]!=" Success" )
51- return 3 ;
50+ if (result[" upload" ][" result" ]!=" Success" ){
51+ std::clog<<" The uploader bot encountered a non-success result. See the log in current directory for more information." <<std::endl;
52+ std::ofstream logs{std::format (" {}.log" ,filename)};
53+ logs<<result<<std::endl;
54+ }
5255 }catch (const curlpp::RuntimeError &e){
5356 std::cerr<<e.what ()<<std::endl;
5457 assert (false );
0 commit comments