Skip to content

Commit b1e5c46

Browse files
Detect mobile links and optimizations
1 parent 7f88d88 commit b1e5c46

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

bin/youtubeExtractor.jar

7 Bytes
Binary file not shown.

src/at/huber/youtubeExtractor/YouTubeUriExtractor.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public abstract class YouTubeUriExtractor extends AsyncTask<String, String, Spar
5555

5656
private static final String USER_AGENT="Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36";
5757

58-
private static final Pattern patYouTubePageLink=Pattern.compile("(http|https)://(www\\.|)youtube\\.com/watch\\?v=(.+?)( |\\z|&)");
58+
private static final Pattern patYouTubePageLink=Pattern.compile("(http|https)://(www\\.|m.|)youtube\\.com/watch\\?v=(.+?)( |\\z|&)");
5959
private static final Pattern patYouTubeShortLink=Pattern.compile("(http|https)://(www\\.|)youtu.be/(.+?)( |\\z|&)");
6060

6161
private static final Pattern patItag=Pattern.compile("itag=([0-9]+?)(&|,)");
@@ -131,6 +131,7 @@ protected void onPostExecute(SparseArray<YtFile> ytFiles) {
131131

132132
@Override
133133
protected SparseArray<YtFile> doInBackground(String... params) {
134+
youtubeID=null;
134135
String ytUrl=params[0];
135136
if (ytUrl == null){
136137
return null;
@@ -231,18 +232,17 @@ private SparseArray<YtFile> getStreamUrls() throws IOException, InterruptedExcep
231232
decipherFunctionName=null;
232233
}
233234
decipherJsFileName=curJsFileName;
234-
}
235-
streams=streamMap.split(",|url_encoded_fmt_stream_map|&adaptive_fmts=");
236-
235+
}
237236
}else{
238237
patTitle= Pattern.compile("title=((.*?))(&|\\z)");
239238
mat=patTitle.matcher(streamMap);
240239
if (mat.find()){
241240
videoTitle=URLDecoder.decode(mat.group(2), "UTF-8");
242241
}
243242
streamMap=URLDecoder.decode(streamMap, "UTF-8");
244-
streams=streamMap.split(",|url_encoded_fmt_stream_map|&adaptive_fmts=");
245243
}
244+
245+
streams=streamMap.split(",|url_encoded_fmt_stream_map|&adaptive_fmts=");
246246
SparseArray<YtFile> ytFiles=new SparseArray<YtFile>();
247247
for(String encStream : streams){
248248
encStream=encStream + ",";
@@ -289,10 +289,9 @@ private SparseArray<YtFile> getStreamUrls() throws IOException, InterruptedExcep
289289
lock.unlock();
290290
}
291291
}
292-
if (decipheredSignature == null){
292+
sig=decipheredSignature;
293+
if (sig == null){
293294
return null;
294-
}else{
295-
sig=decipheredSignature;
296295
}
297296
}
298297
}
@@ -418,6 +417,8 @@ else if (javascriptFile.charAt(i) == '}')
418417
if (CACHING){
419418
writeDeciperFunctToChache();
420419
}
420+
}else{
421+
return false;
421422
}
422423
}else{
423424
decipherViaWebView(sig);

0 commit comments

Comments
 (0)