Hentai-Downloader/source/app.d

71 lines
1.2 KiB
D
Raw Normal View History

2020-04-13 13:19:14 -04:00
import std.stdio;
import std.string;
// My classes
import config.downloaderconfig;
import sites.hentaicafe;
import sites.nhentai;
import inputhandler;
void printHelp()
{
writeln(`
2020-04-13 13:49:21 -04:00
Usage:
-h Display this help message
-b <text file> Batchmode -> Downloads all links in the given text file
<link> Download only one manga`);
2020-04-13 13:19:14 -04:00
}
void main(string[] args)
{
/* writeln(args); */
if(args.length < 2)
{
printHelp();
return;
}
if(args.length == 2)
{
// -h arg
if(args[1] == "-h")
{
printHelp();
return;
}
2020-04-13 13:19:14 -04:00
// Direct link was supplied
string url = args[1];
// Call the factory with the link that was supplied
siteFactory(url);
}
else if(args.length >= 3)
{
// Batchmode
import std.file : readText;
string filename = args[2];
// Read all the links into memory
string fileContents = readText(filename);
// Transform fileContents into an array
string[] urls = fileContents.split("\n");
// Sanitize the urls
foreach(string url; urls)
{
// If the url is empty move on to the next
if(strip(url) == "") continue;
url = strip(url);
}
/* writeln(urls); */
// Call the factory
siteFactory(urls);
}
}