i2psnark: Add support for comment and url_list to Storage CLI

Add support for multiple urls to MetaInfo CLI
Add comment to release torrent
This commit is contained in:
zzz
2020-10-30 16:37:54 +00:00
parent 5c1a529df0
commit 90aab37002
3 changed files with 55 additions and 9 deletions

View File

@@ -792,7 +792,7 @@ public class MetaInfo
boolean error = false;
String created_by = null;
String announce = null;
String url = null;
List<String> url_list = null;
String comment = null;
Getopt g = new Getopt("Storage", args, "a:c:m:w:");
try {
@@ -812,7 +812,9 @@ public class MetaInfo
break;
case 'w':
url = g.getOptarg();
if (url_list == null)
url_list = new ArrayList<String>();
url_list.add(g.getOptarg());
break;
case '?':
@@ -827,7 +829,7 @@ public class MetaInfo
error = true;
}
if (error || args.length - g.getOptind() <= 0) {
System.err.println("Usage: MetaInfo [-a announceURL] [-c created-by] [-m comment] [-w web-seed-url] file.torrent [file2.torrent...]");
System.err.println("Usage: MetaInfo [-a announceURL] [-c created-by] [-m comment] [-w webseed-url]* file.torrent [file2.torrent...]");
System.exit(1);
}
for (int i = g.getOptind(); i < args.length; i++) {
@@ -842,11 +844,11 @@ public class MetaInfo
"\nWebSeed URLs: " + meta.getWebSeedURLs() +
"\nCreated By: " + meta.getCreatedBy() +
"\nComment: " + meta.getComment());
if (created_by != null || announce != null || url != null || comment != null) {
if (created_by != null || announce != null || url_list != null || comment != null) {
String cb = created_by != null ? created_by : meta.getCreatedBy();
String an = announce != null ? announce : meta.getAnnounce();
String cm = comment != null ? comment : meta.getComment();
List<String> urls = url != null ? Collections.singletonList(url) : meta.getWebSeedURLs();
List<String> urls = url_list != null ? url_list : meta.getWebSeedURLs();
// changes/adds creation date
MetaInfo meta2 = new MetaInfo(an, meta.getName(), null, meta.getFiles(), meta.getLengths(),
meta.getPieceLength(0), meta.getPieceHashes(), meta.getTotalLength(), meta.isPrivate(),