Skip to content

Commit b7aa047

Browse files
Fix signature deciphering
1 parent 7255ee5 commit b7aa047

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
jcenter()
77
}
88
dependencies {
9-
classpath 'com.android.tools.build:gradle:3.5.3'
9+
classpath 'com.android.tools.build:gradle:3.6.2'
1010

1111
// NOTE: Do not place your application dependencies here; they belong
1212
// in the individual module build.gradle files
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sat Jan 18 23:01:49 CET 2020
1+
#Sat Apr 18 21:27:46 CEST 2020
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

sampleApp/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ android {
66
defaultConfig {
77
applicationId "at.huber.sampleDownload"
88
minSdkVersion 14
9+
//noinspection ExpiredTargetSdkVersion
910
targetSdkVersion 22
1011
versionCode 1
1112
versionName "1.0"

youtubeExtractor/src/main/java/at/huber/youtubeExtractor/YouTubeExtractor.java

+7-12
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)