|
|
|
@ -140,18 +140,58 @@ public class Downloader implements Consumer<DownloadTask> |
|
|
|
|
|
|
|
|
|
List<Format> formats = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
int codeCol = 0; |
|
|
|
|
int extCol = 1; |
|
|
|
|
int resCol = 2; |
|
|
|
|
int noteCol = 3; |
|
|
|
|
int sizeCol = -1; |
|
|
|
|
int bitrateCol = -1; |
|
|
|
|
|
|
|
|
|
List<String> list = output.lines().collect(Collectors.toList()); |
|
|
|
|
int i = 0; |
|
|
|
|
while (!list.get(i).contains("Available formats")) |
|
|
|
|
i++; |
|
|
|
|
i++; |
|
|
|
|
if (list.get(i).contains("FILESIZE")) |
|
|
|
|
{ |
|
|
|
|
String[] split = list.get(i).split("\\s+"); |
|
|
|
|
for (int j = 0; j < split.length; j++) |
|
|
|
|
{ |
|
|
|
|
switch (split[j]) |
|
|
|
|
{ |
|
|
|
|
case "ID": |
|
|
|
|
codeCol = j; |
|
|
|
|
break; |
|
|
|
|
case "EXT": |
|
|
|
|
extCol = j; |
|
|
|
|
break; |
|
|
|
|
case "RESOLUTION": |
|
|
|
|
resCol = j; |
|
|
|
|
break; |
|
|
|
|
case "MORE": |
|
|
|
|
noteCol = j; |
|
|
|
|
break; |
|
|
|
|
case "FILESIZE": |
|
|
|
|
sizeCol = j; |
|
|
|
|
break; |
|
|
|
|
case "TBR": |
|
|
|
|
bitrateCol = j; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
i += 2; |
|
|
|
|
} |
|
|
|
|
for (; i < list.size(); i++) |
|
|
|
|
{ |
|
|
|
|
String line = list.get(i); |
|
|
|
|
String[] split = line.split("\\s\\s+", 4); |
|
|
|
|
String[] split = line.split("\\s+", Math.max(4, noteCol - 1)); |
|
|
|
|
if (split.length < 4) |
|
|
|
|
continue; |
|
|
|
|
formats.add(new Format(split[0], split[1], split[2], split[3])); |
|
|
|
|
final Format format = new Format(split[codeCol], split[extCol], split[resCol], split[noteCol]); |
|
|
|
|
if (sizeCol >= 0) |
|
|
|
|
format.setSize(Util.parseSize(split[sizeCol])); |
|
|
|
|
if (bitrateCol >= 0) |
|
|
|
|
format.setSampleRate(Util.parseSampleRate(split[bitrateCol])); |
|
|
|
|
formats.add(format); |
|
|
|
|
} |
|
|
|
|
song.setFormats(formats); |
|
|
|
|
|
|
|
|
|