From 6b9c1125e361ce3af1b1884265777690878df703 Mon Sep 17 00:00:00 2001 From: Harshith Goka Date: Fri, 1 Feb 2019 21:11:15 +0530 Subject: [PATCH] Add another JS signature function name regex; --- app/build.gradle | 4 ++-- .../youtubedl/Activities/MainActivity.java | 12 ------------ .../youtubedl/YoutubeDL/Extractor.java | 8 +++----- app/src/main/res/layout/activity_main.xml | 15 --------------- app/src/main/res/layout/formats_layout.xml | 1 + 5 files changed, 6 insertions(+), 34 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 41c0d8e..cb9d36f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "me.harshithgoka.youtubedl" minSdkVersion 19 targetSdkVersion 28 - versionCode 13 - versionName "0.13" + versionCode 15 + versionName "0.15" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { diff --git a/app/src/main/java/me/harshithgoka/youtubedl/Activities/MainActivity.java b/app/src/main/java/me/harshithgoka/youtubedl/Activities/MainActivity.java index 043ae3b..0db06bf 100644 --- a/app/src/main/java/me/harshithgoka/youtubedl/Activities/MainActivity.java +++ b/app/src/main/java/me/harshithgoka/youtubedl/Activities/MainActivity.java @@ -32,7 +32,6 @@ import android.view.inputmethod.EditorInfo; import android.webkit.ValueCallback; import android.webkit.WebSettings; -import android.webkit.WebView; import android.widget.Button; import android.widget.EditText; import android.widget.ProgressBar; @@ -96,9 +95,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ArrayList history; TextView videoTitle; - - WebView webview; - Gson gson; HashMap inProgressDownloads; ArrayList> mixingDownloads; @@ -134,14 +130,6 @@ protected void onCreate(Bundle savedInstanceState) { } - webview = (WebView) findViewById(R.id.web_view); - - WebSettings webSettings = webview.getSettings(); - webSettings.setJavaScriptEnabled(true); - - webview.loadUrl("http://google.com/"); - - String appLogoText = "YouTubeDL"; TextView appLogo = findViewById(R.id.app_logo); appLogo.setText(Html.fromHtml(appLogoText)); diff --git a/app/src/main/java/me/harshithgoka/youtubedl/YoutubeDL/Extractor.java b/app/src/main/java/me/harshithgoka/youtubedl/YoutubeDL/Extractor.java index 175fdd9..6d9205f 100644 --- a/app/src/main/java/me/harshithgoka/youtubedl/YoutubeDL/Extractor.java +++ b/app/src/main/java/me/harshithgoka/youtubedl/YoutubeDL/Extractor.java @@ -82,8 +82,6 @@ public Extractor() { public JSInterpreter parseSigJs(String response) { - // (r'(["\'])signature\1\s*,\s*(?P[a-zA-Z0-9$]+)\(', - // r'\.sig\|\|(?P[a-zA-Z0-9$]+)\('), JSInterpreter jsInterpreter = new JSInterpreter(response); if(jsInterpreter != null) { js_code = response; @@ -105,7 +103,7 @@ public String extractSignatureFunction(String video_id, String player_url, Strin Pair playerID = new Pair<>(player_url, signatureCacheId(s)); if (!player_cache.containsKey(playerID)) { - Pattern playerUrl = Pattern.compile(".*?-(?[a-zA-Z0-9_-]+)(?:/watch_as3|/html5player(?:-new)?|(?:/[a-z]{2}_[A-Z]{2})?/base)?\\.(?[a-z]+)$"); + Pattern playerUrl = Pattern.compile(".*?-(?[a-zA-Z0-9_-]+)(?:/watch_as3|/html5player(?:-new)?|(?:/[a-z]{2,3}_[A-Z]{2})?/base)?\\.(?[a-z]+)$"); Matcher matcher = playerUrl.matcher(player_url); if (!matcher.find()) @@ -132,12 +130,12 @@ public String extractSignatureFunction(String video_id, String player_url, Strin if (m.find()) func_name = m.group(2); else { - funcNamePattern = Pattern.compile("yt\\.akamaized\\.net/\\)\\s*\\|\\|\\s*.*?\\s*c\\s*&&\\s*d\\.set\\([^,]+\\s*,\\s*([a-zA-Z0-9$]+)\\("); + funcNamePattern = Pattern.compile("yt\\.akamaized\\.net/\\)\\s*\\|\\|\\s*.*?\\s*c\\s*&&\\s*d\\.set\\([^,]+\\s*,\\s*(?:encodeURIComponent\\s*\\()?(?[a-zA-Z0-9$]+)\\("); m = funcNamePattern.matcher(response) ; if (m.find()){ func_name = m.group(1) ; } else { - funcNamePattern = Pattern.compile("\\bc\\s*&&\\s*d\\.set\\([^,]+\\s*,\\s*([a-zA-Z0-9$]+)\\(") ; + funcNamePattern = Pattern.compile("\\bc\\s*&&\\s*d\\.set\\([^,]+\\s*,\\s*(?:encodeURIComponent\\s*\\()?\\s*(?[a-zA-Z0-9$]+)\\(") ; m = funcNamePattern.matcher(response) ; if (m.find()){ func_name = m.group(1) ; diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 8eddf8c..8bfa47f 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -121,21 +121,6 @@ app:layout_constraintTop_toBottomOf="@+id/textView"> - - - diff --git a/app/src/main/res/layout/formats_layout.xml b/app/src/main/res/layout/formats_layout.xml index a6e6b13..62f4431 100644 --- a/app/src/main/res/layout/formats_layout.xml +++ b/app/src/main/res/layout/formats_layout.xml @@ -87,6 +87,7 @@ android:layout_marginBottom="8dp" android:text="Best" android:textAllCaps="false" + android:visibility="gone" android:backgroundTint="@color/colorPrimaryDark" app:layout_constraintBottom_toBottomOf="@+id/formats_heading" app:layout_constraintEnd_toEndOf="parent"