2010-10-27 13:27:33 +02:00
|
|
|
|
2010-10-27 15:20:26 +02:00
|
|
|
import java.io.*;
|
|
|
|
import java.util.*;
|
2010-10-27 13:27:33 +02:00
|
|
|
|
|
|
|
import com.gc.android.market.api.MarketSession.Callback;
|
|
|
|
import com.gc.android.market.api.MarketSession;
|
|
|
|
import com.gc.android.market.api.model.Market.App;
|
|
|
|
import com.gc.android.market.api.model.Market.AppsResponse;
|
|
|
|
import com.gc.android.market.api.model.Market.AppsRequest;
|
|
|
|
import com.gc.android.market.api.model.Market.CommentsRequest;
|
|
|
|
import com.gc.android.market.api.model.Market.GetImageRequest;
|
|
|
|
import com.gc.android.market.api.model.Market.GetImageResponse;
|
|
|
|
import com.gc.android.market.api.model.Market.ResponseContext;
|
|
|
|
import com.gc.android.market.api.model.Market.GetImageRequest.AppImageUsage;
|
|
|
|
|
|
|
|
class test {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param args
|
|
|
|
*/
|
|
|
|
public static void main(String[] args) {
|
|
|
|
try {
|
2010-10-27 15:20:26 +02:00
|
|
|
if(args.length < 2) {
|
2010-10-27 13:27:33 +02:00
|
|
|
System.out.println("Parameters :\n" +
|
2010-10-27 15:20:26 +02:00
|
|
|
"email password");
|
2010-10-27 13:27:33 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
String login = args[0];
|
|
|
|
String password = args[1];
|
2010-10-27 15:20:26 +02:00
|
|
|
|
|
|
|
// Get a list of apps we want to check - i.e. those that
|
|
|
|
// we have metadata files for...
|
|
|
|
File dir = new File("../metadata");
|
|
|
|
List<String> apps = new ArrayList<String>();
|
|
|
|
String[] metafiles = dir.list();
|
|
|
|
for (int i=0; i<metafiles.length; i++) {
|
|
|
|
String metafile = metafiles[i];
|
|
|
|
if(metafile.endsWith(".txt")) {
|
|
|
|
String pkg = metafile.substring(0,
|
|
|
|
metafile.length() - 4);
|
|
|
|
apps.add(pkg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
System.out.println("Apps to check: " + apps.size());
|
2010-10-27 13:27:33 +02:00
|
|
|
|
|
|
|
MarketSession session = new MarketSession();
|
2010-11-27 10:10:33 +01:00
|
|
|
session.getContext().setAndroidId("87548757565689");
|
2010-10-27 13:27:33 +02:00
|
|
|
System.out.println("Login...");
|
|
|
|
session.login(login,password);
|
|
|
|
System.out.println("Login done");
|
|
|
|
|
|
|
|
MarketSession.Callback callback = new MarketSession.Callback() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResult(ResponseContext contex, Object oresp) {
|
2010-10-27 21:57:19 +02:00
|
|
|
try {
|
|
|
|
AppsResponse response = (AppsResponse)oresp;
|
|
|
|
if(response.getAppCount() != 1) {
|
|
|
|
System.out.println("Not in market, or multiple results");
|
|
|
|
} else {
|
|
|
|
App app = response.getAppList().get(0);
|
|
|
|
String filespec = "../metadata/" + app.getPackageName() + ".txt";
|
|
|
|
FileInputStream fi = new FileInputStream(filespec);
|
2011-01-27 19:59:57 +01:00
|
|
|
InputStreamReader isr = new InputStreamReader(fi, "UTF-8");
|
|
|
|
BufferedReader br = new BufferedReader(isr);
|
2010-10-27 21:57:19 +02:00
|
|
|
StringBuilder output = new StringBuilder();
|
|
|
|
boolean changed = false;
|
|
|
|
boolean vercodefound = false;
|
|
|
|
boolean versionfound = false;
|
|
|
|
String line, newline;
|
2011-01-27 19:59:57 +01:00
|
|
|
while (br.ready()) {
|
|
|
|
line = br.readLine();
|
2010-10-27 21:57:19 +02:00
|
|
|
if (line.startsWith("Market Version:")) {
|
|
|
|
versionfound = true;
|
|
|
|
newline="Market Version:" + app.getVersion();
|
|
|
|
if (!newline.equals(line)) {
|
|
|
|
changed = true;
|
|
|
|
line = newline;
|
|
|
|
}
|
|
|
|
} else if (line.startsWith("Market Version Code:")) {
|
|
|
|
vercodefound = true;
|
|
|
|
newline="Market Version Code:" + app.getVersionCode();
|
|
|
|
if (!newline.equals(line)) {
|
|
|
|
changed = true;
|
|
|
|
line = newline;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
output.append(line + "\n");
|
|
|
|
}
|
2011-01-27 19:59:57 +01:00
|
|
|
br.close();
|
|
|
|
isr.close();
|
2010-10-27 21:57:19 +02:00
|
|
|
fi.close();
|
|
|
|
if(!versionfound) {
|
|
|
|
changed = true;
|
|
|
|
output.append("Market Version:" + app.getVersion() + "\n");
|
|
|
|
}
|
|
|
|
if(!vercodefound) {
|
|
|
|
changed = true;
|
|
|
|
output.append("Market Version Code:" + app.getVersionCode() + "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed) {
|
|
|
|
System.out.println("..updating");
|
|
|
|
File of = new File(filespec);
|
|
|
|
BufferedWriter wi = new BufferedWriter(new FileWriter(of));
|
|
|
|
wi.write(output.toString());
|
|
|
|
wi.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (Exception ex) {
|
2010-11-27 10:10:33 +01:00
|
|
|
System.out.println("...Exception");
|
|
|
|
ex.printStackTrace();
|
2010-10-27 13:27:33 +02:00
|
|
|
}
|
|
|
|
}
|
2010-10-27 21:57:19 +02:00
|
|
|
|
2010-10-27 13:27:33 +02:00
|
|
|
};
|
2010-10-27 15:20:26 +02:00
|
|
|
|
|
|
|
for(String pkg : apps) {
|
|
|
|
System.out.println("Checking: " + pkg);
|
|
|
|
AppsRequest appsRequest = AppsRequest.newBuilder()
|
|
|
|
.setQuery("pname:" + pkg)
|
|
|
|
.setStartIndex(0).setEntriesCount(10)
|
|
|
|
.setWithExtendedInfo(true)
|
|
|
|
.build();
|
|
|
|
session.append(appsRequest, callback);
|
|
|
|
session.flush();
|
|
|
|
|
|
|
|
// Pause to avoid rate limit...
|
|
|
|
Thread.sleep(5000);
|
|
|
|
}
|
|
|
|
|
2010-10-27 13:27:33 +02:00
|
|
|
} catch(Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|