Skip to content

Commit

Permalink
Add another JS signature function name regex;
Browse files Browse the repository at this point in the history
  • Loading branch information
tastelessjolt committed Feb 1, 2019
1 parent 8d86a85 commit 6b9c112
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 34 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -96,9 +95,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
ArrayList<VideoInfo> history;

TextView videoTitle;

WebView webview;

Gson gson;
HashMap<Long, Format> inProgressDownloads;
ArrayList<Pair<Format, Format>> mixingDownloads;
Expand Down Expand Up @@ -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 = "<font color=#c62828>Y</font>ou<font color=#e15827>T</font>ube<font color=#33745f>DL</font>";
TextView appLogo = findViewById(R.id.app_logo);
appLogo.setText(Html.fromHtml(appLogoText));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ public Extractor() {


public JSInterpreter parseSigJs(String response) {
// (r'(["\'])signature\1\s*,\s*(?P<sig>[a-zA-Z0-9$]+)\(',
// r'\.sig\|\|(?P<sig>[a-zA-Z0-9$]+)\('),
JSInterpreter jsInterpreter = new JSInterpreter(response);
if(jsInterpreter != null) {
js_code = response;
Expand All @@ -105,7 +103,7 @@ public String extractSignatureFunction(String video_id, String player_url, Strin
Pair<String, String> playerID = new Pair<>(player_url, signatureCacheId(s));

if (!player_cache.containsKey(playerID)) {
Pattern playerUrl = Pattern.compile(".*?-(?<id>[a-zA-Z0-9_-]+)(?:/watch_as3|/html5player(?:-new)?|(?:/[a-z]{2}_[A-Z]{2})?/base)?\\.(?<ext>[a-z]+)$");
Pattern playerUrl = Pattern.compile(".*?-(?<id>[a-zA-Z0-9_-]+)(?:/watch_as3|/html5player(?:-new)?|(?:/[a-z]{2,3}_[A-Z]{2})?/base)?\\.(?<ext>[a-z]+)$");

Matcher matcher = playerUrl.matcher(player_url);
if (!matcher.find())
Expand All @@ -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*\\()?(?<sig>[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*(?<sig>[a-zA-Z0-9$]+)\\(") ;
m = funcNamePattern.matcher(response) ;
if (m.find()){
func_name = m.group(1) ;
Expand Down
15 changes: 0 additions & 15 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,6 @@
app:layout_constraintTop_toBottomOf="@+id/textView">

</me.harshithgoka.youtubedl.CustomUI.RecyclerViewEmptySupport>

<WebView
android:id="@+id/web_view"
android:layout_width="368dp"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/empty_history" />

</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/formats_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 6b9c112

Please sign in to comment.