@@ -77,12 +77,11 @@ public abstract class YouTubeExtractor extends AsyncTask<String, Void, SparseArr
7777 private static final Pattern patUrl = Pattern .compile ("\" url\" \\ s*:\\ s*\" (.+?)\" " );
7878 private static final Pattern patCipher = Pattern .compile ("\" cipher\" \\ s*:\\ s*\" (.+?)\" " );
7979 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*>" );
8180
8281 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})\\ (" );
8382 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" );
8685 private static final Pattern patSignatureDecFunction = Pattern .compile ("\\ b([\\ w$]{2})\\ s*=\\ s*function\\ ((\\ w+)\\ )\\ {\\ s*\\ 2=\\ s*\\ 2\\ .split\\ (\" \" \\ )\\ s*;" );
8786
8887 private static final SparseArray <Format > FORMAT_MAP = new SparseArray <>();
@@ -298,14 +297,12 @@ private SparseArray<YtFile> getStreamUrls() throws IOException, InterruptedExcep
298297 try {
299298 reader = new BufferedReader (new InputStreamReader (urlConnection .getInputStream ()));
300299 String line ;
300+ StringBuilder sbStreamMap = new StringBuilder ();
301301 while ((line = reader .readLine ()) != null ) {
302302 // 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 ("\\ \" " , "\" " ));
308304 }
305+ streamMap = sbStreamMap .toString ();
309306 } finally {
310307 reader .close ();
311308 urlConnection .disconnect ();
@@ -314,9 +311,7 @@ private SparseArray<YtFile> getStreamUrls() throws IOException, InterruptedExcep
314311
315312 mat = patDecryptionJsFile .matcher (streamMap );
316313 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 ("\\ /" , "/" );
320315 if (decipherJsFileName == null || !decipherJsFileName .equals (curJsFileName )) {
321316 decipherFunctions = null ;
322317 decipherFunctionName = null ;
@@ -425,7 +420,7 @@ private SparseArray<YtFile> getStreamUrls() throws IOException, InterruptedExcep
425420 private boolean decipherSignature (final SparseArray <String > encSignatures ) throws IOException {
426421 // Assume the functions don't change that much
427422 if (decipherFunctionName == null || decipherFunctions == null ) {
428- String decipherFunctUrl = "https://s.ytimg. com/yts/jsbin/ " + decipherJsFileName ;
423+ String decipherFunctUrl = "https://youtube. com" + decipherJsFileName ;
429424
430425 BufferedReader reader = null ;
431426 String javascriptFile ;
0 commit comments