Note that there are some explanatory texts on larger screens.

plurals
  1. PO404 with youtube-mp3.org api
    text
    copied!<p>I'm trying to make an app that can download mp3 files by a youtube url.</p> <p>I did some research on the youtube-mp3.org api and this is the way I think it should be done:</p> <ol> <li>Get <code>http://www.youtube-mp3.org/api/pushItem/?item=http://www.youtube.com/watch?v=xo9EV3A4oaA&amp;xy=yx</code></li> <li>Step 1 returns an ID, which you have to use in the following request: <code>"http://www.youtube-mp3.org/api/itemInfo/?video_id=" + ID</code></li> <li>Step 2 returns another code, which you have to use in this request: <code>"http://www.youtube-mp3.org/get?video_id=xo9EV3A4oaA&amp;h=" + &lt;code from step 2&gt;</code></li> <li>Step 3 retruns the mp3.</li> </ol> <p>Unfortunately, my code already fails at step 1: I'm getting a 404, page not found.</p> <p>Here's my code (only for step 1):</p> <pre><code>private DefaultHttpClient createHttpClient() { HttpParams my_httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(my_httpParams, 3000); HttpConnectionParams.setSoTimeout(my_httpParams, 15000); SchemeRegistry registry = new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); ThreadSafeClientConnManager multiThreadedConnectionManager = new ThreadSafeClientConnManager(my_httpParams, registry); DefaultHttpClient httpclient = new DefaultHttpClient(multiThreadedConnectionManager, my_httpParams); return httpclient; } private class DownloadVid extends AsyncTask&lt;Void, Void, Void&gt; { int mStatusCode = 0; String content = ""; @Override protected Void doInBackground(Void... args) { String url = "http://www.youtube-mp3.org/api/pushItem/?item=http://www.youtube.com/watch?v=xo9EV3A4oaA&amp;xy=yx"; DefaultHttpClient httpclient = createHttpClient(); HttpGet httpget = new HttpGet(url); httpget.addHeader("Accept-Location", "*"); try { HttpResponse response = httpclient.execute(httpget); StatusLine statusLine = response.getStatusLine(); mStatusCode = statusLine.getStatusCode(); if (mStatusCode == 200){ content = EntityUtils.toString(response.getEntity()); } } catch (ClientProtocolException e) { e.printStackTrace(); mStatusCode = 0; } catch (IOException e) { e.printStackTrace(); mStatusCode = 0; } catch (IllegalStateException e){ e.printStackTrace(); mStatusCode = 0; } return null; } @Override protected void onPostExecute(Void arg) { mProgressDialog.dismiss(); Toast.makeText(MainActivity.this, "Result=" + content + " StatusCode=" + mStatusCode, Toast.LENGTH_LONG).show(); } } </code></pre> <p>I'm not sure why it isn't working. Any ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload