fixed opus not saving with thumbnail & added share intent for custom command

pull/18/head
Denis Çerri 4 years ago
parent f4d3ff5c25
commit 427b96957c
No known key found for this signature in database
GPG Key ID: 96B3554AF5B193EE

@ -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"

@ -22,6 +22,7 @@
android:theme="@style/AppTheme" >
<activity android:name=".MainActivity"
android:windowSoftInputMode="adjustResize"
android:label="@string/download"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@ -51,11 +52,17 @@
android:name=".page.CustomCommandActivity"
android:theme="@style/AppDefaultTheme"
android:parentActivityName=".MainActivity"
android:label="@string/run_command"
android:exported="true">
<intent-filter>
<action android:name="ytdlnis.page.CustomCommandActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
<service
android:name=".DownloaderService"

@ -7,14 +7,10 @@ import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Binder
import android.os.Environment
import android.os.IBinder
import android.provider.DocumentsContract
import android.util.Log
import android.webkit.MimeTypeMap
import android.widget.Toast
import androidx.core.content.FileProvider
import androidx.core.net.toUri
import com.deniscerri.ytdlnis.database.Video
import com.deniscerri.ytdlnis.page.CustomCommandActivity
import com.deniscerri.ytdlnis.service.DownloadInfo
@ -31,12 +27,12 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.schedulers.Schedulers
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.InputStream
import java.util.*
import java.util.concurrent.ConcurrentHashMap
import java.util.regex.Pattern
import kotlin.jvm.functions.Function3
class DownloaderService : Service() {
private val binder = LocalBinder()
@ -50,8 +46,9 @@ class DownloaderService : Service() {
private var context: Context? = null
var downloadProcessID = "processID"
private var downloadNotificationID = 0
private val callback =
DownloadProgressCallback { progress: Float, etaInSeconds: Long, line: String? ->
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,7 +322,7 @@ 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")
@ -334,7 +338,7 @@ class DownloaderService : Service() {
} 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)

@ -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(){

@ -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,

@ -6,7 +6,6 @@
<item>alac</item>
<item>flac</item>
<item>opus</item>
<item>vorbis</item>
<item>wav</item>
</string-array>

@ -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"

Loading…
Cancel
Save