diff --git a/app/build.gradle b/app/build.gradle index 71dfe50c..2333c2b0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -91,9 +91,9 @@ dependencies { // implementation project(":library") // implementation project(":ffmpeg") - implementation "com.github.yausername.youtubedl-android:library:$youtubedlAndroidVer" - implementation "com.github.yausername.youtubedl-android:ffmpeg:$youtubedlAndroidVer" - implementation "com.github.yausername.youtubedl-android:aria2c:$youtubedlAndroidVer" + implementation "com.github.JunkFood02.youtubedl-android:library:$youtubedlAndroidVer" + implementation "com.github.JunkFood02.youtubedl-android:ffmpeg:$youtubedlAndroidVer" + implementation "com.github.JunkFood02.youtubedl-android:aria2c:$youtubedlAndroidVer" implementation "androidx.appcompat:appcompat:$appCompatVer" implementation "androidx.constraintlayout:constraintlayout:2.1.4" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2942d53f..2c5f8958 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -22,6 +22,7 @@ android:theme="@style/AppTheme" > @@ -51,11 +52,17 @@ android:name=".page.CustomCommandActivity" android:theme="@style/AppDefaultTheme" android:parentActivityName=".MainActivity" + android:label="@string/run_command" android:exported="true"> + + + + + + + private val callback: (Float, Long?, String?) -> Unit = + { progress: Float, _: Long?, line: String? -> downloadInfo.progress = progress.toInt() downloadInfo.outputLine = line downloadInfo.downloadQueue = downloadQueue @@ -77,6 +74,13 @@ class DownloaderService : Service() { } catch (ignored: Exception) { } } +// private val callback = object : DownloadProgressCallback { +// override fun onProgressUpdate(progress: Float, etaInSeconds: Long, line: String?) { +// override fun onProgressUpdate(progress: Float, etaInSeconds: Long, line: String?) { +// +// } +// } +// } override fun onCreate() { super.onCreate() @@ -318,23 +322,23 @@ class DownloaderService : Service() { if (format == null) format = sharedPreferences.getString("audio_format", "") request.addOption("--audio-format", format!!) request.addOption("--embed-metadata") - if (format == "mp3" || format == "m4a" || format == "flac") { - val embedThumb = sharedPreferences.getBoolean("embed_thumbnail", false) - if (embedThumb) { - request.addOption("--embed-thumbnail") - request.addOption("--convert-thumbnails", "png") - try { - val config = File(cacheDir, "config.txt") - val config_data = - "--ppa \"ffmpeg: -c:v png -vf crop=\\\"'if(gt(ih,iw),iw,ih)':'if(gt(iw,ih),ih,iw)'\\\"\"" - val stream = FileOutputStream(config) - stream.write(config_data.toByteArray()) - stream.close() - request.addOption("--config", config.absolutePath) - } catch (ignored: Exception) { - } + + val embedThumb = sharedPreferences.getBoolean("embed_thumbnail", false) + if (embedThumb) { + request.addOption("--embed-thumbnail") + request.addOption("--convert-thumbnails", "png") + try { + val config = File(cacheDir, "config.txt") + val config_data = + "--ppa \"ffmpeg: -c:v png -vf crop=\\\"'if(gt(ih,iw),iw,ih)':'if(gt(iw,ih),ih,iw)'\\\"\"" + val stream = FileOutputStream(config) + stream.write(config_data.toByteArray()) + stream.close() + request.addOption("--config", config.absolutePath) + } catch (ignored: Exception) { } } + request.addCommands(Arrays.asList("--replace-in-metadata", "title", ".*.", video.title)) request.addCommands( Arrays.asList( @@ -441,12 +445,9 @@ class DownloaderService : Service() { private fun startCommandDownload(text: String?) { var text = text - if (!text!!.startsWith("yt-dlp ")) { - Toast.makeText(context, "Wrong input! Try Again!", Toast.LENGTH_SHORT).show() - finishService() - return + if (text!!.startsWith("yt-dlp")) { + text = text.substring(5).trim { it <= ' ' } } - text = text.substring(6).trim { it <= ' ' } val request = YoutubeDLRequest(emptyList()) val commandRegex = "\"([^\"]*)\"|(\\S+)" val m = Pattern.compile(commandRegex).matcher(text) diff --git a/app/src/main/java/com/deniscerri/ytdlnis/page/CustomCommandActivity.java b/app/src/main/java/com/deniscerri/ytdlnis/page/CustomCommandActivity.java index f09d6463..2da2e870 100644 --- a/app/src/main/java/com/deniscerri/ytdlnis/page/CustomCommandActivity.java +++ b/app/src/main/java/com/deniscerri/ytdlnis/page/CustomCommandActivity.java @@ -138,6 +138,25 @@ public class CustomCommandActivity extends AppCompatActivity { swapFabs(); input.setEnabled(true); }); + handleIntent(getIntent()); + } + + + @Override + protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + handleIntent(intent); + } + + private void handleIntent(Intent intent){ + String action = intent.getAction(); + String type = intent.getType(); + Log.e(TAG, action + " " + type); + if (action.equals(Intent.ACTION_SEND) && type != null) { + Log.e(TAG, action); + String txt = "yt-dlp " + intent.getStringExtra(Intent.EXTRA_TEXT); + input.setText(txt); + } } private void swapFabs(){ diff --git a/app/src/main/java/com/deniscerri/ytdlnis/util/UpdateUtil.kt b/app/src/main/java/com/deniscerri/ytdlnis/util/UpdateUtil.kt index 64e35e13..bc195d27 100644 --- a/app/src/main/java/com/deniscerri/ytdlnis/util/UpdateUtil.kt +++ b/app/src/main/java/com/deniscerri/ytdlnis/util/UpdateUtil.kt @@ -176,7 +176,7 @@ class UpdateUtil(var context: Context) { else -> Toast.makeText(context, status.toString(), Toast.LENGTH_LONG).show() } updatingYTDL = false - }) { e: Throwable? -> + } as ((UpdateStatus?) -> Unit)?) { e: Throwable? -> if (BuildConfig.DEBUG) Log.e(tag, context.getString(R.string.ytdl_update_failed), e) Toast.makeText( context, diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index c5278db1..e77c48bf 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -6,7 +6,6 @@ alac flac opus - vorbis wav diff --git a/build.gradle b/build.gradle index 37475d53..214dac6f 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ buildscript { commonsIoVer = '2.5' // supports java 1.6 commonsCompressVer = '1.12' - youtubedlAndroidVer = "master-SNAPSHOT" + youtubedlAndroidVer = "a3b971724d" workVer = "2.7.1" composeVer = "1.3.2" kotlinVer = "1.7.20"