diff --git a/.idea/misc.xml b/.idea/misc.xml index 75dac50..3963879 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -24,7 +24,7 @@ - + diff --git a/app/build.gradle b/app/build.gradle index 09cd1c2..faf404a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,6 +10,10 @@ android { versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + +// ndk { +// abiFilters 'x86', 'armeabi-v7a' +// } } buildTypes { release { @@ -17,7 +21,14 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } - buildToolsVersion '27.0.1' + buildToolsVersion '27.0.3' +// externalNativeBuild { +// cmake { +// path '../cpp/CMakeLists.txt' +// } +// } + + } dependencies { @@ -31,7 +42,7 @@ dependencies { testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' - compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" } repositories { mavenCentral() diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index efaa839..2556fcb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,6 +3,7 @@ package="me.harshithgoka.youtubedl"> + 0) { + s = s.substring(0, index); + } + + s = s.replaceFirst("m.youtube.com", "www.youtube.com"); + + return s; + } public void startPoint(View button) { String url = urlEdit.getText().toString(); + url = preprocess(url); + println("Url: " + url); AsyncTask> asyncTask = new GetInfoAsyncTask(getApplicationContext(), webView); @@ -203,44 +218,8 @@ public JSInterpreter parseSigJs(String response) { // (r'(["\'])signature\1\s*,\s*(?P[a-zA-Z0-9$]+)\(', // r'\.sig\|\|(?P[a-zA-Z0-9$]+)\('), - - // TODO: extract actual js function from script using some JS interpretor library -// webView.loadUrl("javascript:" + response); -// webView.evaluateJavascript(func_name, new ValueCallback() { -// @Override -// public void onReceiveValue(String s) { -// Log.d("Result", s); -// } -// }); - - JSInterpreter jsInterpreter = new JSInterpreter(response); return jsInterpreter; - -// org.mozilla.javascript.Context rhino = org.mozilla.javascript.Context.enter(); -// //disabling the optimizer to better support Android. -// rhino.setOptimizationLevel(-1); -// -// try { -// -// Scriptable scope = rhino.initStandardObjects(); -// -// /** -// * evaluateString(Scriptable scope, java.lang.String source, java.lang.String sourceName, -// * int lineno, java.lang.Object securityDomain) -// * -// */ -// rhino.evaluateString(scope, response, "JavaScript", 1, null); -// -// -// Function function = (Function) scope.get("evaluate", scope); -// -// } -// catch (Exception e) { -// -// e.printStackTrace(); -// } - } String signatureCacheId (String sig) { @@ -352,12 +331,12 @@ protected List doInBackground(String... strings) { ret.put("status", true); String fmts = ytconfig.getJSONObject("args").getString("url_encoded_fmt_stream_map") + "," + ytconfig.getJSONObject("args").getString("adaptive_fmts"); - + String title = ytconfig.getJSONObject("args").optString("title", "videoplayback"); String[] fmts_enc = fmts.split(","); List formats = new ArrayList<>(); for (String fmt : fmts_enc) { - Format f = new Format(); + Format f = new Format(title); Map query_pairs = new LinkedHashMap(); String[] pairs = fmt.split("&"); @@ -438,6 +417,16 @@ else if (params.contains("s")) { return null; } + public void download (String url, String name) { + DownloadManager.Request req = new DownloadManager.Request(Uri.parse(url)); + req.setTitle(name); + req.allowScanningByMediaScanner(); + req.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); + + DownloadManager dm = context.getSystemService(DownloadManager.class); + dm.enqueue(req); + } + @Override protected void onPostExecute(List formats) { if (formats != null) { @@ -454,6 +443,9 @@ protected void onPostExecute(List formats) { clipboard.setPrimaryClip(clip); Toast.makeText(getApplicationContext(), String.format("Best quality link (%s) copied to Clipboard", formats.get(0).quality), Toast.LENGTH_SHORT).show(); + + download(finalurl, formats.get(0).title); + } else { println("No. of formats: 0"); diff --git a/build.gradle b/build.gradle index ee49086..39c4d88 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.1' + classpath 'com.android.tools.build:gradle:3.1.3' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7aeb809..5b46143 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Dec 05 21:04:56 IST 2017 +#Tue Jul 17 18:10:43 IST 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip