SciLor's Open Source Forums

Wrong/Fake SongIDs
Page 1 of 1

Author:  tornadochaser [ Mon Jun 14, 2010 11:57 pm ]
Post subject:  Wrong/Fake SongIDs


I have a similar app for Android that I wrote and I was wondering if you are having the same "occasional" issue that I am... Sometimes when connected over a 3G or Edge network the song search to Grooveshark's servers returns results with "fake" SongIDs. This does not usually occur when connected over WiFi... I've had this problem since I originally wrote the program and haven't been able to solve it as of yet. I have noted that the JSON data comes back formatted slightly different when the SongIDs are fake but I haven't figured out how to eliminate the problem from the root cause. Feel free to contact me directly if you wish...

Author:  SciLor [ Tue Jun 15, 2010 12:03 pm ]
Post subject:  Re: Wrong/Fake SongIDs

I also have that problem. I have managed to decrease it, by using a valid,dynamic "country" instead of a predefined one.

You may post your steps to connect to grooveshark(tm) here, so I can tell you what I make different!

Author:  tornadochaser [ Tue Jun 15, 2010 6:05 pm ]
Post subject:  Re: Wrong/Fake SongIDs

Thanks! Ya I'm just using static country parameters so that will hopefully help... Also I didn't know if they were maybe trying to filter out IPs from mobile devices since I have no issues when using WiFi (although the country parameters I'm using are what I got with an Http Sniffer from my home network)... Here's my song search function... Sorry the code is a bit crude right now...
   static Object GSAPI_songSearch(String SongSearch) {
      String url = "";
      String ret_string="";
      JSONObject JSONHeaders = new JSONObject();
      JSONObject JSONParameters = new JSONObject();
      JSONObject JSONCountry = new JSONObject();
      JSONObject JSONMainObj = new JSONObject();
      JSONArray jsonArray = null;
      StringEntity se;
      HttpResponse response = null;
      String resultString = null;
      String temptoken = GSAPI_getRequestToken("getSearchResultsEx");
      try {
         JSONCountry.put("CC1", "0");
         JSONCountry.put("CC2", "0");
         JSONCountry.put("CC3", "0");
         JSONCountry.put("CC4", "0");
         JSONCountry.put("ID", "1");
         JSONHeaders.put("session", SessionID);
         JSONHeaders.put("uuid", UserID);
         JSONHeaders.put("client", "gslite");
         JSONHeaders.put("clientRevision", clientRev);
         JSONHeaders.put("token", temptoken);
         JSONHeaders.put("privacy", "1");
         JSONHeaders.put("country", JSONCountry);
         JSONParameters.put("query", SongSearch.toLowerCase());
         JSONParameters.put("type", "Songs");
         JSONMainObj.put("method", "getSearchResultsEx");
         JSONMainObj.put("parameters", JSONParameters);
         JSONMainObj.put("header", JSONHeaders);
         DefaultHttpClient httpclient = new DefaultHttpClient();
         HttpPost httpPostRequest = new HttpPost(url);
         se = new StringEntity(JSONMainObj.toString());
         httpPostRequest.setHeader("content-type", header_content_json);
         response = (HttpResponse) httpclient.execute(httpPostRequest);
            HttpEntity entity = response.getEntity();
            if (entity != null) {
               // Read the content stream
               InputStream instream = entity.getContent();
               // convert content stream to a String
               resultString = convertStreamToString(instream);
                  JSONObject jsonObjRecv = new JSONObject(resultString);
                  JSONObject tempObj =jsonObjRecv.getJSONObject("result");
                  CharSequence cs = "[{";
                     ret_string="Search broken in zeros";
                     JSONObject tempObj2=tempObj.getJSONObject("result");
                     jsonArray=new JSONArray();
                     for(int i=0;i<(tempObj2.length()-2);i++){
                     ret_string="Search broken in array";
                     jsonArray = tempObj.getJSONArray("result");
            ret_string = "Error code: " + String.valueOf(response.getStatusLine().getStatusCode())+ " " + response.getStatusLine().getReasonPhrase();
      } catch (JSONException e) {
         // TODO Auto-generated catch block
      } catch (UnsupportedEncodingException e) {
         // TODO Auto-generated catch block
      } catch (ClientProtocolException e) {
         // TODO Auto-generated catch block
      } catch (IOException e) {
         // TODO Auto-generated catch block
         return jsonArray;
         return ret_string;

With these headers:
   static String clientRev = "20100412.29";
   static String weirdString = ":quitStealinMahShit:";
   static String header_user_agent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/ Safari/532.5";
   static String header_content_json="application/json";
   static String header_content_url="application/x-www-form-urlencoded";
   static String header_accept_1="*/*";
   static String header_accept_language="en-US";

Thanks again for your help!!

Author:  SciLor [ Tue Jun 15, 2010 6:30 pm ]
Post subject:  Re: Wrong/Fake SongIDs

I would suggest you to get the JSONCountry from the main page('<object'), the cowbell also and I would also put a referer from the main page(including the cowbell) on your request.

I do not know if this will help, but I hope so :)

Author:  tornadochaser [ Wed Jun 16, 2010 12:43 am ]
Post subject:  Re: Wrong/Fake SongIDs

Thanks for your help!! I didn't even notice that they had the country data there but I have it up and running now! I'm not quite sure what you mean by getting the cowbell from the main page as well, though (are you saying set hte "Host" header?)... Also, when you set the "Referer" header are you doing what the website would do and have something like "" (claiming to be flash-based)?

Thanks again for your help! :)

Author:  SciLor [ Wed Jun 16, 2010 9:28 am ]
Post subject:  Re: Wrong/Fake SongIDs

I mean exactly "", where the cowbell can change, so just get it from the main page and use that as Referer, then it will be fine :)

I hope you will take a look in my forums from time to time. If something at grooveshark(tm) changes, just write me again and I will try to help you :). If not we will try to solve it together.

Author:  tornadochaser [ Wed Jun 16, 2010 8:10 pm ]
Post subject:  Re: Wrong/Fake SongIDs

Thanks! I will definitely visit the forum from time to time and for sure anytime something changes we should figure the stuff out together. I have a ton of people running Android app I wrote so I flooded with emails and negative ratings anytime something isn't working lol. The app is called Song Storm if you want to check it out. Thanks for the help!!


Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group