]*>.*?
]*>(.*?)
" );
Matcher m = null;
String postContent = "";
@@ -434,7 +376,6 @@ public class ForumScraper {
return postContent;
}
-
/**
* Calculates an MD5 hash of the first post in a thread.
*/
@@ -443,7 +384,6 @@ public class ForumScraper {
return PackUtilities.calcStreamMD5( new ByteArrayInputStream( rawDesc.getBytes( Charset.forName("UTF-8") ) ) );
}
-
/**
* Downloads a URL and returns the string content, decoded as UTF-8.
*/
@@ -492,7 +432,6 @@ public class ForumScraper {
return result;
}
-
/**
* Writes collated catalog entries to a file, as human-editable xml.
*/
@@ -563,7 +502,6 @@ public class ForumScraper {
return dst;
}
-
/**
* Parses dumped xml and returns a new catalog.
*/
@@ -611,6 +549,42 @@ public class ForumScraper {
}
+
+ @Command(
+ name = "ForumScraper",
+ abbreviateSynopsis = true,
+ sortOptions = false,
+ description = "Harvest new forum content to edit into the moddb catalog.",
+ footer = "%nLoad an existing catalog as the moddb, and scrape.%nManually edit the catalog by copy/pasting scraped snippets.%nLoad the edited catalog and dump back to json."
+ )
+ public static class ScraperCommand {
+ @Option(names = "--load-json", paramLabel = "FILE", description = "load moddb from a json catalog")
+ File jsonSrcFile;
+
+ @Option(names = "--load-xml", paramLabel = "FILE", description = "load moddb from an xml file")
+ File xmlSrcFile;
+
+ @Option(names = "--scrape", paramLabel = "FILE", description = "write changed forum posts to an xml file")
+ File scrapeDstFile;
+
+ @Option(names = "--dump-json", paramLabel = "FILE", description = "write the moddb to a json file")
+ File jsonDstFile;
+
+ @Option(names = "--dump-xml", paramLabel = "FILE", description = "write the moddb to an xml file")
+ File xmlDstFile;
+
+ @Option(names = "--hash-thread", paramLabel = "URL", description = "print the hash of a specific thread")
+ String hashThreadURL;
+
+ @Option(names = "--first-post", paramLabel = "URL", description = "print the first post of a thread (debugging)")
+ String firstPostURL;
+
+ @Option(names = {"-h", "--help"}, usageHelp = true, description = "display this help and exit")
+ boolean helpRequested;
+ }
+
+
+
/** Information gleaned from scraping the forum. */
private static class ScrapeResult {
public String threadURL = null;