@@ -77,12 +77,11 @@ public abstract class YouTubeExtractor extends AsyncTask<String, Void, SparseArr
77
77
private static final Pattern patUrl = Pattern .compile ("\" url\" \\ s*:\\ s*\" (.+?)\" " );
78
78
private static final Pattern patCipher = Pattern .compile ("\" cipher\" \\ s*:\\ s*\" (.+?)\" " );
79
79
private static final Pattern patCipherUrl = Pattern .compile ("url=(.+?)(\\ \\ \\ \\ u0026|\\ z)" );
80
- private static final Pattern patYtPlayer = Pattern .compile ("<\\ s*script\\ s*>((.+?)jsbin\\ \\ /(player(_ias)?-(.+?).js)(.+?))</\\ s*script\\ s*>" );
81
80
82
81
private static final Pattern patVariableFunction = Pattern .compile ("([{; =])([a-zA-Z$][a-zA-Z0-9$]{0,2})\\ .([a-zA-Z$][a-zA-Z0-9$]{0,2})\\ (" );
83
82
private static final Pattern patFunction = Pattern .compile ("([{; =])([a-zA-Z$_][a-zA-Z0-9$]{0,2})\\ (" );
84
-
85
- private static final Pattern patDecryptionJsFile = Pattern .compile ("jsbin \\ \\ /( player(_ias)?-(. +?).js) " );
83
+
84
+ private static final Pattern patDecryptionJsFile = Pattern .compile ("\\ \\ /s \\ \\ / player\\ \\ /([^ \" ] +?)\\ .js" );
86
85
private static final Pattern patSignatureDecFunction = Pattern .compile ("\\ b([\\ w$]{2})\\ s*=\\ s*function\\ ((\\ w+)\\ )\\ {\\ s*\\ 2=\\ s*\\ 2\\ .split\\ (\" \" \\ )\\ s*;" );
87
86
88
87
private static final SparseArray <Format > FORMAT_MAP = new SparseArray <>();
@@ -298,14 +297,12 @@ private SparseArray<YtFile> getStreamUrls() throws IOException, InterruptedExcep
298
297
try {
299
298
reader = new BufferedReader (new InputStreamReader (urlConnection .getInputStream ()));
300
299
String line ;
300
+ StringBuilder sbStreamMap = new StringBuilder ();
301
301
while ((line = reader .readLine ()) != null ) {
302
302
// Log.d("line", line);
303
- mat = patYtPlayer .matcher (line );
304
- if (mat .find ()) {
305
- streamMap = line .replace ("\\ \" " , "\" " );
306
- break ;
307
- }
303
+ sbStreamMap .append (line .replace ("\\ \" " , "\" " ));
308
304
}
305
+ streamMap = sbStreamMap .toString ();
309
306
} finally {
310
307
reader .close ();
311
308
urlConnection .disconnect ();
@@ -314,9 +311,7 @@ private SparseArray<YtFile> getStreamUrls() throws IOException, InterruptedExcep
314
311
315
312
mat = patDecryptionJsFile .matcher (streamMap );
316
313
if (mat .find ()) {
317
- curJsFileName = mat .group (1 ).replace ("\\ /" , "/" );
318
- if (mat .group (2 ) != null )
319
- curJsFileName .replace (mat .group (2 ), "" );
314
+ curJsFileName = mat .group (0 ).replace ("\\ /" , "/" );
320
315
if (decipherJsFileName == null || !decipherJsFileName .equals (curJsFileName )) {
321
316
decipherFunctions = null ;
322
317
decipherFunctionName = null ;
@@ -425,7 +420,7 @@ private SparseArray<YtFile> getStreamUrls() throws IOException, InterruptedExcep
425
420
private boolean decipherSignature (final SparseArray <String > encSignatures ) throws IOException {
426
421
// Assume the functions don't change that much
427
422
if (decipherFunctionName == null || decipherFunctions == null ) {
428
- String decipherFunctUrl = "https://s.ytimg. com/yts/jsbin/ " + decipherJsFileName ;
423
+ String decipherFunctUrl = "https://youtube. com" + decipherJsFileName ;
429
424
430
425
BufferedReader reader = null ;
431
426
String javascriptFile ;
0 commit comments