SciLor's Open Source Forums

Also visit my Website!
It is currently Fri Oct 20, 2017 12:46 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Wrong/Fake SongIDs
PostPosted: Mon Jun 14, 2010 11:57 pm 
SciLor,

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...


Last edited by SciLor on Tue Jun 15, 2010 12:01 pm, edited 1 time in total.
Killed Email


Top
  
 
 
Online
The Adswinger

Joined: Wed Jan 13, 2010 11:56 pm
Posts: Too many!
Donated: Ad Posts


 Post subject: Re: Wrong/Fake SongIDs
PostPosted: Tue Jun 15, 2010 12:03 pm 
Offline
The Developer

Joined: Wed Jan 13, 2010 11:56 pm
Posts: 1467
Donated: free software
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!

_________________
My Windows Mobile and Windows Open Source Website:
www.scilor.com

Like my work? Donate!
Donation Website

My Programs:
grooveshark™.com Downloader, GrooveMobile, Fuel Blaster, Chameleon TicTacToe, QuickTap, WiMoBlue, Driving Licence Trainer, CodeSnippetViewer, Gesture Launcher, Fahrplanauskunft, GSensor Control


Top
 Profile  
 
 Post subject: Re: Wrong/Fake SongIDs
PostPosted: Tue Jun 15, 2010 6:05 pm 
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...
Code:
   static Object GSAPI_songSearch(String SongSearch) {
      String url = "http://cowbell.grooveshark.com/more.php?getSearchResultsEx";
      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.setEntity(se);
         httpPostRequest.setHeader("User-Agent",header_user_agent);
         httpPostRequest.setHeader("content-type", header_content_json);
         httpPostRequest.setHeader("Accept",header_accept_1);
         httpPostRequest.setHeader("Accept-Language",header_accept_language);
         httpPostRequest.removeHeaders("Expect");
         response = (HttpResponse) httpclient.execute(httpPostRequest);
         if(response.getStatusLine().getStatusCode()==200){
            HttpEntity entity = response.getEntity();
            if (entity != null) {
               // Read the content stream
               InputStream instream = entity.getContent();
               // convert content stream to a String
               resultString = convertStreamToString(instream);
               instream.close();
               if(resultString.charAt(0)=='{'){
                  JSONObject jsonObjRecv = new JSONObject(resultString);
                  JSONObject tempObj =jsonObjRecv.getJSONObject("result");
                  CharSequence cs = "[{";
                  if(!tempObj.toString().contains(cs)){
                     ret_string="Search broken in zeros";
                     JSONObject tempObj2=tempObj.getJSONObject("result");
                     jsonArray=new JSONArray();
                     for(int i=0;i<(tempObj2.length()-2);i++){
                        jsonArray.put(tempObj2.get(String.valueOf(i)));
                     }
                  }else{
                     ret_string="Search broken in array";
                     jsonArray = tempObj.getJSONArray("result");
                  }
               }else{
                  ret_string=resultString;
               }
            }
         }else{
            ret_string = "Error code: " + String.valueOf(response.getStatusLine().getStatusCode())+ " " + response.getStatusLine().getReasonPhrase();
         }
      } catch (JSONException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      } catch (UnsupportedEncodingException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      } catch (ClientProtocolException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      } catch (IOException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      }
      if(!(jsonArray==null)){
         return jsonArray;
      }else{
         return ret_string;
      }
   }


With these headers:
Code:
   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/4.1.249.1064 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!!


Top
  
 
 Post subject: Re: Wrong/Fake SongIDs
PostPosted: Tue Jun 15, 2010 6:30 pm 
Offline
The Developer

Joined: Wed Jan 13, 2010 11:56 pm
Posts: 1467
Donated: free software
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 :)

_________________
My Windows Mobile and Windows Open Source Website:
www.scilor.com

Like my work? Donate!
Donation Website

My Programs:
grooveshark™.com Downloader, GrooveMobile, Fuel Blaster, Chameleon TicTacToe, QuickTap, WiMoBlue, Driving Licence Trainer, CodeSnippetViewer, Gesture Launcher, Fahrplanauskunft, GSensor Control


Top
 Profile  
 
 Post subject: Re: Wrong/Fake SongIDs
PostPosted: Wed Jun 16, 2010 12:43 am 
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 "http://listen.grooveshark.com/main.swf?cowbell=e5d68c32fed86baa8ee29c60d3e3227d" (claiming to be flash-based)?

Thanks again for your help! :)


Top
  
 
 Post subject: Re: Wrong/Fake SongIDs
PostPosted: Wed Jun 16, 2010 9:28 am 
Offline
The Developer

Joined: Wed Jan 13, 2010 11:56 pm
Posts: 1467
Donated: free software
I mean exactly "http://listen.grooveshark.com/main.swf?cowbell=e5d68c32fed86baa8ee29c60d3e3227d", 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.

_________________
My Windows Mobile and Windows Open Source Website:
www.scilor.com

Like my work? Donate!
Donation Website

My Programs:
grooveshark™.com Downloader, GrooveMobile, Fuel Blaster, Chameleon TicTacToe, QuickTap, WiMoBlue, Driving Licence Trainer, CodeSnippetViewer, Gesture Launcher, Fahrplanauskunft, GSensor Control


Top
 Profile  
 
 Post subject: Re: Wrong/Fake SongIDs
PostPosted: Wed Jun 16, 2010 8:10 pm 
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!!

Matt


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
template->_php_include(): File ./counter/foruminclude.php does not exist or is empty Powered by phpBB® Forum Software © phpBB Group