Skip to content

Commit 0e278af

Browse files
fix a bug and change a screenshot
1 parent c5ab106 commit 0e278af

File tree

6 files changed

+10
-15
lines changed

6 files changed

+10
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ app to download Youtube videos. It doesn't have a launcher entry though so don't
3535

3636
To try the app have a look at: [youtubeDownloader.apk](https://github.com/HaarigerHarald/android-youtubeExtractor/raw/master/bin/youtubeDownloader.apk)
3737

38-
<img src='https://github.com/HaarigerHarald/android-youtubeExtractor/raw/master/Screenshot_2014-09-30-21-12-16.png' width='250' alt='youtubeDownloader Screenshot 1'>
38+
<img src='https://github.com/HaarigerHarald/android-youtubeExtractor/raw/master/Screenshot_2014-10-02-02-10-48.png' width='250' alt='youtubeDownloader Screenshot 1'>
3939

4040
<img src='https://github.com/HaarigerHarald/android-youtubeExtractor/raw/master/Screenshot_2014-09-30-21-12-34.png' width='250' alt='youtubeDownloader Screenshot 2'>
4141

Screenshot_2014-09-30-21-12-16.png

-75.8 KB
Binary file not shown.

Screenshot_2014-10-02-02-10-48.png

85.5 KB
Loading

bin/youtubeDownloader.apk

-12 Bytes
Binary file not shown.

bin/youtubeExtractor.jar

-642 Bytes
Binary file not shown.

src/at/huber/youtubeExtractor/YouTubeUriExtractor.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ public abstract class YouTubeUriExtractor extends AsyncTask<String, String, Spar
3131
private Activity calledActivity;
3232
private String videoTitle="youtube";
3333
private String youtubeID="";
34+
private JsEvaluator js;
3435

3536
private volatile String decipheredSignature;
3637
private static String decipherFunctions;
3738
private static String decipherFunctionName;
3839

3940
private final static Lock lock=new ReentrantLock();
4041
private final static Condition jsExecuting=lock.newCondition();
41-
private static JsEvaluator js;
4242

4343
private static final Pattern patItag=Pattern.compile("itag=([0-9]+?)[&]");
4444
private static final Pattern patSig=Pattern.compile("signature=(.+?)[&|,|\\\\]");
@@ -116,7 +116,7 @@ protected SparseArray<YtFile> doInBackground(String... params) {
116116
try{
117117
return getStreamUrls(ytUrl);
118118
}catch (Exception e){
119-
Log.d(getClass().getSimpleName(), e.getMessage());
119+
e.printStackTrace();
120120
}
121121
return null;
122122
}
@@ -144,17 +144,6 @@ private SparseArray<YtFile> getStreamUrls(String ytUrl) throws IOException, Inte
144144
if (streamMap == null || !streamMap.contains("use_cipher_signature=False")){
145145
// Get the video directly from the youtubepage
146146

147-
// We'll start the Chromium jsEvaluator right away cause it needs
148-
// some time.
149-
if (js == null){
150-
calledActivity.runOnUiThread(new Runnable() {
151-
152-
@Override
153-
public void run() {
154-
js=new JsEvaluator(calledActivity);
155-
}
156-
});
157-
}
158147
request=new HttpGet(ytUrl);
159148
response=client.execute(request);
160149
in=response.getEntity().getContent();
@@ -195,7 +184,12 @@ public void run() {
195184
SparseArray<YtFile> ytFiles=new SparseArray<YtFile>();
196185
for(String encStream : streams){
197186
encStream=encStream + ",";
198-
String stream=URLDecoder.decode(encStream, "UTF-8");
187+
String stream;
188+
try{
189+
stream=URLDecoder.decode(encStream, "UTF-8");
190+
}catch(IllegalArgumentException iae){
191+
continue;
192+
}
199193

200194
mat=patItag.matcher(stream);
201195
int itag=-1;
@@ -356,6 +350,7 @@ private void decipherViaWebView(final String sig) {
356350

357351
@Override
358352
public void run() {
353+
js=new JsEvaluator(calledActivity);
359354
js.evaluate(decipherFunctions + " " + decipherFunctionName + "('" + sig + "');",
360355
new JsCallback() {
361356
@Override

0 commit comments

Comments
 (0)