Enhancements

Fix compatibility with some broken Shadowrocket links.
Add direct option to generator to download subscriptions or use local files directly.
Add return code to report generator error.
Add output code page restore.
This commit is contained in:
Tindy X committed 2020-02-28 11:39:01 +08:00
1 parent 8fe8dcbe86
commit 6ff431ef10
3 files changed
+47 -2

No files matched your search

+29
View File
@@ -1762,6 +1762,33 @@ int simpleGenerator()
}
else
{
if(ini.GetBool("direct") == true)
{
std::string url = ini.Get("url");
if(fileExist(url))
content = fileGet(url, false);
else
{
//check for proxy settings
std::string proxy;
if(proxy_subscription == "SYSTEM")
proxy = getSystemProxy();
else if(proxy_subscription == "NONE")
proxy = "";
else
proxy = proxy_subscription;
content = webGet(url, proxy);
}
if(content.empty())
{
std::cerr<<"Artifact '"<<x<<"' generate ERROR! Please check your link.\n\n";
if(sections.size() == 1)
return -1;
}
// add UTF-8 BOM
fileWrite(path, "\xEF\xBB\xBF" + content, true);
continue;
}
ini.GetItems(allItems);
allItems.emplace("expand", "true");
for(auto &y : allItems)
@@ -1776,6 +1803,8 @@ int simpleGenerator()
if(ret_code != 200)
{
std::cerr<<"Artifact '"<<x<<"' generate ERROR! Reason: "<<content<<"\n\n";
if(sections.size() == 1)
return -1;
continue;
}
fileWrite(path, content, true);