fixed some bugs on terminal mode and download card
This commit is contained in:
parent
e46976e182
commit
24f04ec2ba
14 changed files with 72 additions and 52 deletions
|
|
@ -66,21 +66,24 @@ android {
|
|||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
debuggable false
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
|
||||
dev {
|
||||
initWith buildTypes.release
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
debuggable true
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
|
||||
debug {
|
||||
initWith buildTypes.release
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
debuggable true
|
||||
proguardFiles 'baseline-profiles-rules.pro'
|
||||
signingConfig signingConfigs.debug
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -116,9 +119,9 @@ android {
|
|||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
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 "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"
|
||||
|
|
@ -136,7 +139,7 @@ dependencies {
|
|||
androidTestImplementation "junit:junit:$junitVer"
|
||||
androidTestImplementation "androidx.test.ext:junit:$androidJunitVer"
|
||||
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVer"
|
||||
androidTestImplementation "androidx.benchmark:benchmark-macro-junit4:1.2.0-alpha09"
|
||||
androidTestImplementation "androidx.benchmark:benchmark-macro-junit4:1.2.0-alpha10"
|
||||
androidTestImplementation "androidx.test:runner:1.5.2"
|
||||
androidTestImplementation "androidx.test:core:1.5.0"
|
||||
androidTestImplementation "androidx.test:rules:1.5.0"
|
||||
|
|
|
|||
|
|
@ -5,8 +5,7 @@
|
|||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
|
||||
tools:ignore="ScopedStorage" />
|
||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ import com.yausername.aria2c.Aria2c
|
|||
import com.yausername.ffmpeg.FFmpeg
|
||||
import com.yausername.youtubedl_android.YoutubeDL
|
||||
import com.yausername.youtubedl_android.YoutubeDLException
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.*
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
|
|
@ -30,6 +34,16 @@ class App : Application() {
|
|||
false
|
||||
)
|
||||
|
||||
applicationScope = CoroutineScope(SupervisorJob())
|
||||
applicationScope.launch((Dispatchers.IO)) {
|
||||
try {
|
||||
initLibraries()
|
||||
}catch (e: Exception){
|
||||
Toast.makeText(this@App, e.message, Toast.LENGTH_SHORT).show()
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
WorkManager.initialize(
|
||||
this@App,
|
||||
Configuration.Builder()
|
||||
|
|
@ -38,12 +52,8 @@ class App : Application() {
|
|||
.getInt("concurrent_downloads", 1)))
|
||||
.build())
|
||||
|
||||
try {
|
||||
initLibraries()
|
||||
}catch (e: Exception){
|
||||
Toast.makeText(this@App, e.message, Toast.LENGTH_SHORT).show()
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
|
||||
val locale = getSharedPreferences("root_preferences", MODE_PRIVATE)
|
||||
.getString("app_language", Locale.getDefault().language)!!
|
||||
AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags(locale))
|
||||
|
|
@ -62,5 +72,6 @@ class App : Application() {
|
|||
|
||||
companion object {
|
||||
private const val TAG = "App"
|
||||
private lateinit var applicationScope: CoroutineScope
|
||||
}
|
||||
}
|
||||
|
|
@ -100,6 +100,11 @@ class CustomCommandActivity : AppCompatActivity() {
|
|||
|
||||
|
||||
private fun startDownload(command: String?) {
|
||||
var cmd: String = ""
|
||||
if (command!!.contains("yt-dlp")) cmd = command.replace("yt-dlp", "")
|
||||
else cmd = command
|
||||
cmd = cmd.trim()
|
||||
|
||||
downloadID = System.currentTimeMillis().toInt()
|
||||
|
||||
val theIntent = Intent(this, CustomCommandActivity::class.java)
|
||||
|
|
@ -121,8 +126,7 @@ class CustomCommandActivity : AppCompatActivity() {
|
|||
notify(downloadID, commandNotification)
|
||||
}
|
||||
}
|
||||
|
||||
val commandRegex = "\"([^\"]*)\"|(\\S+)"
|
||||
val commandRegex = "(-\\S+)|(\\S+)"
|
||||
val request = YoutubeDLRequest(emptyList())
|
||||
|
||||
val tempFolder = StringBuilder(context!!.cacheDir.absolutePath + """/${command}##terminal""")
|
||||
|
|
@ -130,8 +134,8 @@ class CustomCommandActivity : AppCompatActivity() {
|
|||
tempFileDir.delete()
|
||||
tempFileDir.mkdir()
|
||||
|
||||
|
||||
val m = Pattern.compile(commandRegex).matcher(command!!)
|
||||
Log.e(TAG, cmd)
|
||||
val m = Pattern.compile(commandRegex).matcher(cmd)
|
||||
while (m.find()) {
|
||||
if (m.group(1) != null) {
|
||||
request.addOption(m.group(1)!!)
|
||||
|
|
@ -140,30 +144,34 @@ class CustomCommandActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
request.addOption("-o", tempFileDir.absolutePath + "/%(uploader)s - %(title)s.%(ext)s")
|
||||
request.addOption("-P", tempFileDir.absolutePath)
|
||||
|
||||
cancelFab!!.visibility = View.VISIBLE
|
||||
fab!!.visibility = View.GONE
|
||||
|
||||
val disposable: Disposable = Observable.fromCallable {
|
||||
try{
|
||||
YoutubeDL.getInstance().execute(request, downloadID.toString()){ progress, _, line ->
|
||||
Log.e(TAG, line)
|
||||
runOnUiThread {
|
||||
output!!.append("\n" + line)
|
||||
output!!.scrollTo(0, output!!.height)
|
||||
scrollView!!.fullScroll(View.FOCUS_DOWN)
|
||||
|
||||
val title: String = getString(R.string.terminal)
|
||||
notificationUtil.updateDownloadNotification(
|
||||
downloadID,
|
||||
line, progress.toInt(), 0, title,
|
||||
NotificationUtil.COMMAND_DOWNLOAD_SERVICE_CHANNEL_ID
|
||||
)
|
||||
}
|
||||
|
||||
val title: String = getString(R.string.terminal)
|
||||
notificationUtil.updateDownloadNotification(
|
||||
downloadID,
|
||||
line, progress.toInt(), 0, title,
|
||||
NotificationUtil.COMMAND_DOWNLOAD_SERVICE_CHANNEL_ID
|
||||
)
|
||||
}
|
||||
}catch (e: Exception){
|
||||
e.printStackTrace()
|
||||
runOnUiThread {
|
||||
output!!.append("\n" + e.message)
|
||||
output!!.scrollTo(0, output!!.height)
|
||||
scrollView!!.fullScroll(View.FOCUS_DOWN)
|
||||
|
||||
input!!.isEnabled = true
|
||||
|
||||
cancelFab!!.visibility = View.GONE
|
||||
|
|
@ -190,6 +198,7 @@ class CustomCommandActivity : AppCompatActivity() {
|
|||
}
|
||||
notificationUtil.cancelDownloadNotification(downloadID)
|
||||
}) { e ->
|
||||
e.printStackTrace()
|
||||
scrollView!!.scrollTo(0, scrollView!!.maxScrollAmount)
|
||||
input!!.setText("yt-dlp ")
|
||||
input!!.isEnabled = true
|
||||
|
|
|
|||
|
|
@ -48,10 +48,6 @@ class DownloadAudioFragment(private var resultItem: ResultItem) : Fragment() {
|
|||
|
||||
lateinit var downloadItem: DownloadItem
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
|
|
|
|||
|
|
@ -76,7 +76,6 @@ class DownloadMultipleBottomSheetDialog(private val items: List<DownloadItem>) :
|
|||
|
||||
recyclerView = view.findViewById(R.id.downloadMultipleRecyclerview)
|
||||
recyclerView.layoutManager = LinearLayoutManager(requireContext())
|
||||
recyclerView.setHasFixedSize(true)
|
||||
recyclerView.adapter = listAdapter
|
||||
|
||||
downloadViewModel.processingDownloads.observe(this) {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@ import com.deniscerri.ytdlnis.util.FileUtil
|
|||
import com.deniscerri.ytdlnis.util.UiUtil
|
||||
import com.google.android.material.chip.Chip
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
|
||||
class DownloadVideoFragment(private val resultItem: ResultItem) : Fragment() {
|
||||
|
|
@ -142,7 +144,6 @@ class DownloadVideoFragment(private val resultItem: ResultItem) : Fragment() {
|
|||
val listener = object : OnFormatClickListener {
|
||||
override fun onFormatClick(allFormats: List<Format>, item: Format) {
|
||||
downloadItem.format = item
|
||||
Log.e("Aa", item.toString())
|
||||
|
||||
if (containers.contains(item.container)){
|
||||
downloadItem.format.container = item.container
|
||||
|
|
@ -150,15 +151,8 @@ class DownloadVideoFragment(private val resultItem: ResultItem) : Fragment() {
|
|||
}else{
|
||||
containerAutoCompleteTextView.setText(containers[0], false)
|
||||
}
|
||||
if (resultItem.formats.isEmpty()){
|
||||
resultItem.formats = ArrayList(allFormats)
|
||||
}else{
|
||||
resultItem.formats = ArrayList(resultItem.formats.filter { it.format_note.contains("audio", ignoreCase = true) })
|
||||
resultItem.formats.addAll(allFormats)
|
||||
}
|
||||
resultViewModel.update(resultItem)
|
||||
|
||||
formats = allFormats.toMutableList()
|
||||
Log.e("Aa", item.toString())
|
||||
uiUtil.populateFormatCard(formatCard, item)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import kotlin.math.max
|
|||
import kotlin.math.pow
|
||||
|
||||
class FileUtil() {
|
||||
|
||||
fun deleteFile(path: String){
|
||||
val file = File(path)
|
||||
if (file.exists()) {
|
||||
|
|
@ -127,6 +126,7 @@ class FileUtil() {
|
|||
bytes = inputStream.read(buffer)
|
||||
}
|
||||
}catch (e : Exception){
|
||||
e.printStackTrace()
|
||||
Toast.makeText(context, e.message, Toast.LENGTH_LONG).show()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ class DownloadWorker(
|
|||
}
|
||||
if (downloadItem.customFileNameTemplate.isEmpty()) downloadItem.customFileNameTemplate = "%(uploader)s - %(title)s"
|
||||
|
||||
request.addOption("--restrict-filenames")
|
||||
|
||||
when(type){
|
||||
DownloadViewModel.Type.audio -> {
|
||||
|
|
@ -183,7 +184,7 @@ class DownloadWorker(
|
|||
request.addOption("-o", tempFileDir.absolutePath + "/${downloadItem.customFileNameTemplate}.%(ext)s")
|
||||
}
|
||||
DownloadViewModel.Type.command -> {
|
||||
val commandRegex = "\"([^\"]*)\"|(\\S+)"
|
||||
val commandRegex = "\"([^\"]*)\"|(-\\S+)"
|
||||
val command = commandTemplateDao.getTemplate(downloadItem.format.format_id.toLong())
|
||||
val m = Pattern.compile(commandRegex).matcher(command.content)
|
||||
while (m.find()) {
|
||||
|
|
@ -193,6 +194,8 @@ class DownloadWorker(
|
|||
request.addOption(m.group(2)!!)
|
||||
}
|
||||
}
|
||||
request.addOption("-P", tempFileDir.absolutePath)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -230,6 +233,7 @@ class DownloadWorker(
|
|||
}
|
||||
}catch (e: Exception){
|
||||
finalPath = context.getString(R.string.unfound_file)
|
||||
e.printStackTrace()
|
||||
handler.postDelayed({
|
||||
Toast.makeText(context, e.message, Toast.LENGTH_SHORT).show()
|
||||
}, 1000)
|
||||
|
|
|
|||
|
|
@ -3,9 +3,12 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/format_card_constraintLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:clickable="true"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingVertical="10dp"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
android:paddingVertical="5dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:focusable="true">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/container"
|
||||
|
|
|
|||
|
|
@ -59,7 +59,8 @@
|
|||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:scrollbars="none"
|
||||
android:padding="20dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingHorizontal="10dp"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/please_wait"
|
||||
android:textSize="20sp"
|
||||
android:textSize="17sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
android:textColor="?attr/colorAccent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/cancel"
|
||||
android:textSize="20sp"
|
||||
android:textSize="17sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@
|
|||
<string name="album">Album</string>
|
||||
<string name="video_quality">Video Quality</string>
|
||||
<string name="embed_subtitles">Embed Subtitles</string>
|
||||
<string name="embed_subs">Embed Subtitles</string>
|
||||
<string name="add_chapter">Add Chapters</string>
|
||||
<string name="show_download_card">Show Options for Downloading</string>
|
||||
<string name="download_card_summary">Settings for how to download items</string>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ buildscript {
|
|||
commonsIoVer = '2.5'
|
||||
// supports java 1.6
|
||||
commonsCompressVer = '1.12'
|
||||
youtubedlAndroidVer = "970b819246"
|
||||
youtubedlAndroidVer = "7222fe9637"
|
||||
workVer = "2.8.0"
|
||||
composeVer = "1.4.0-alpha02"
|
||||
kotlinVer = "1.7.21"
|
||||
|
|
|
|||
Loading…
Reference in a new issue