diff options
-rwxr-xr-x[-rw-r--r--] | blasearch.java | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/blasearch.java b/blasearch.java index a5af42c..6ca2295 100644..100755 --- a/blasearch.java +++ b/blasearch.java @@ -32,6 +32,8 @@ public class blasearch { { String query = ""; + String version = "v1.2.1"; + /* Build query from query or arguments, depending on whether arguments were given. */ if (args.length == 0) { @@ -48,7 +50,10 @@ public class blasearch { query += args[i]; } } - + if (query.equals("-v") || query.equals("--version")) { + System.out.println(version); + System.exit(0); + } // Change all ' ' to '+' query = query.replaceAll(" ", "+"); @@ -73,11 +78,20 @@ public class blasearch { for(int i=0; i<lines.length; i++){ // Get the useful information (the urls!) - if(lines[i].startsWith("\"url\"")){ + if(lines[i].startsWith("\"unescapedUrl\"")){ tempString = lines[i]; // Blat the non-url information - tempString = tempString.substring(7, tempString.length()-1); - results.add(tempString); + tempString = tempString.substring(16, tempString.length()-1); + String[] searchParts = tempString.split("\\\\u"); + String searchResult = searchParts[0]; + if (searchParts.length > 1) { + for (int j = 1; j < searchParts.length; j++) { + int hexVal = Integer.parseInt(searchParts[j].substring(0,4),16); + searchResult += (char)hexVal; + searchResult += searchParts[j].substring(4); + } + } + results.add(searchResult); } } |