Skip to content
This repository was archived by the owner on Oct 28, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sampleApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

public class SampleDownloadActivity extends Activity {

private static String youtubeLink;
private static String youtubeLink = "https://www.youtube.com/watch?v=DZrTFdUcWHY";

private LinearLayout mainLayout;
private ProgressBar mainProgressBar;
Expand Down Expand Up @@ -52,8 +52,9 @@ && getIntent().getType() != null && "text/plain".equals(getIntent().getType()))
} else if (savedInstanceState != null && youtubeLink != null) {
getYoutubeDownloadUrl(youtubeLink);
} else {
finish();
//finish();
}
getYoutubeDownloadUrl(youtubeLink);
}

private void getYoutubeDownloadUrl(String youtubeLink) {
Expand Down
1 change: 1 addition & 0 deletions youtubeExtractor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies {
exclude module: 'appcompat-v7'
}
implementation 'com.android.support:support-annotations:28.0.0'
implementation("com.squareup.okhttp3:okhttp:3.10.0")

androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package at.huber.youtubeExtractor;

import android.support.annotation.NonNull;

import java.io.IOException;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;

public abstract class OkHttpHelper {

public static String makeRequest(@NonNull OkHttpClient client, @NonNull String url) throws IOException {
Response response = null;
try {
final Request request;
try {
request = new Request.Builder()
.url(url)
.get()
.build();
} catch (Exception e) {
throw new IOException("Can't create request: " + e.getMessage());
}
response = client.newCall(request).execute();
if (!response.isSuccessful())
throw new IOException("Response is not successful: " + response);
final ResponseBody body = response.body();
if (body == null)
throw new IOException("Response body is null: " + response);
return body.string();
} finally {
if (response != null)
response.close();
}
}
}
Loading