Changed search suggestions provider & more

Replaced invidious dependency with googles
added ability to toggle thumbnail embedding for audio on the download card
This commit is contained in:
Denis Çerri 2023-02-18 14:19:46 +01:00
parent 5ea0c4654f
commit 48cc4f3f75
No known key found for this signature in database
GPG key ID: 95C43D517D830350
20 changed files with 165 additions and 62 deletions

View file

@ -320,7 +320,7 @@
<PersistentState> <PersistentState>
<option name="values"> <option name="values">
<map> <map>
<entry key="url" value="file:/$USER_HOME$/AppData/Local/Android/Sdk/icons/material/materialicons/nights_stay/baseline_nights_stay_24.xml" /> <entry key="url" value="file:/$USER_HOME$/AppData/Local/Android/Sdk/icons/material/materialicons/text_format/baseline_text_format_24.xml" />
</map> </map>
</option> </option>
</PersistentState> </PersistentState>
@ -330,7 +330,7 @@
</option> </option>
<option name="values"> <option name="values">
<map> <map>
<entry key="outputName" value="ic_nightly" /> <entry key="outputName" value="ic_textformat" />
<entry key="sourceFile" value="C:\Users\denis\Desktop\adaptiveproduct_youtube_foreground_color_108 (1).svg" /> <entry key="sourceFile" value="C:\Users\denis\Desktop\adaptiveproduct_youtube_foreground_color_108 (1).svg" />
</map> </map>
</option> </option>

View file

@ -120,7 +120,7 @@ dependencies {
implementation "androidx.appcompat:appcompat:$appCompatVer" implementation "androidx.appcompat:appcompat:$appCompatVer"
implementation "androidx.constraintlayout:constraintlayout:2.1.4" implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation 'com.google.android.material:material:1.8.0' implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.core:core:1.9.0' implementation 'androidx.core:core:1.9.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1' implementation 'androidx.recyclerview:recyclerview:1.2.1'

View file

@ -2,7 +2,7 @@
"formatVersion": 1, "formatVersion": 1,
"database": { "database": {
"version": 1, "version": 1,
"identityHash": "9197d2ce894417365b9012ace8bcf284", "identityHash": "ae6989cdbd101bb25c22cc38d8ec456d",
"entities": [ "entities": [
{ {
"tableName": "results", "tableName": "results",
@ -160,7 +160,7 @@
}, },
{ {
"tableName": "downloads", "tableName": "downloads",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `url` TEXT NOT NULL, `title` TEXT NOT NULL, `author` TEXT NOT NULL, `thumb` TEXT NOT NULL, `duration` TEXT NOT NULL, `type` TEXT NOT NULL, `format` TEXT NOT NULL, `downloadPath` TEXT NOT NULL, `website` TEXT NOT NULL, `downloadSize` TEXT NOT NULL, `playlistTitle` TEXT NOT NULL, `embedSubs` INTEGER NOT NULL, `addChapters` INTEGER NOT NULL, `SaveThumb` INTEGER NOT NULL, `status` TEXT NOT NULL DEFAULT 'Queued', `downloadStartTime` INTEGER NOT NULL DEFAULT 0)", "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `url` TEXT NOT NULL, `title` TEXT NOT NULL, `author` TEXT NOT NULL, `thumb` TEXT NOT NULL, `duration` TEXT NOT NULL, `type` TEXT NOT NULL, `format` TEXT NOT NULL, `downloadPath` TEXT NOT NULL, `website` TEXT NOT NULL, `downloadSize` TEXT NOT NULL, `playlistTitle` TEXT NOT NULL, `audioPreferences` TEXT NOT NULL, `videoPreferences` TEXT NOT NULL, `customFileNameTemplate` TEXT NOT NULL, `SaveThumb` INTEGER NOT NULL, `status` TEXT NOT NULL DEFAULT 'Queued', `downloadStartTime` INTEGER NOT NULL DEFAULT 0)",
"fields": [ "fields": [
{ {
"fieldPath": "id", "fieldPath": "id",
@ -235,15 +235,21 @@
"notNull": true "notNull": true
}, },
{ {
"fieldPath": "embedSubs", "fieldPath": "audioPreferences",
"columnName": "embedSubs", "columnName": "audioPreferences",
"affinity": "INTEGER", "affinity": "TEXT",
"notNull": true "notNull": true
}, },
{ {
"fieldPath": "addChapters", "fieldPath": "videoPreferences",
"columnName": "addChapters", "columnName": "videoPreferences",
"affinity": "INTEGER", "affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "customFileNameTemplate",
"columnName": "customFileNameTemplate",
"affinity": "TEXT",
"notNull": true "notNull": true
}, },
{ {
@ -312,7 +318,7 @@
"views": [], "views": [],
"setupQueries": [ "setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)", "CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '9197d2ce894417365b9012ace8bcf284')" "INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'ae6989cdbd101bb25c22cc38d8ec456d')"
] ]
} }
} }

View file

@ -1,7 +1,9 @@
package com.deniscerri.ytdlnis.database package com.deniscerri.ytdlnis.database
import androidx.room.TypeConverter import androidx.room.TypeConverter
import com.deniscerri.ytdlnis.database.models.AudioPreferences
import com.deniscerri.ytdlnis.database.models.Format import com.deniscerri.ytdlnis.database.models.Format
import com.deniscerri.ytdlnis.database.models.VideoPreferences
import com.deniscerri.ytdlnis.database.viewmodel.DownloadViewModel import com.deniscerri.ytdlnis.database.viewmodel.DownloadViewModel
import com.google.gson.Gson import com.google.gson.Gson
import com.google.gson.reflect.TypeToken import com.google.gson.reflect.TypeToken
@ -39,4 +41,14 @@ class Converters {
else -> DownloadViewModel.Type.command else -> DownloadViewModel.Type.command
} }
} }
@TypeConverter
fun audioPreferencesToString(audioPreferences: AudioPreferences): String = Gson().toJson(audioPreferences)
@TypeConverter
fun stringToAudioPreferences(string: String): AudioPreferences = Gson().fromJson(string, AudioPreferences::class.java)
@TypeConverter
fun videoPreferencesToString(videoPreferences: VideoPreferences): String = Gson().toJson(videoPreferences)
@TypeConverter
fun stringToVideoPreferences(string: String): VideoPreferences = Gson().fromJson(string, VideoPreferences::class.java)
} }

View file

@ -16,6 +16,9 @@ interface CommandTemplateDao {
@Query("SELECT * FROM commandTemplates WHERE id=:id LIMIT 1") @Query("SELECT * FROM commandTemplates WHERE id=:id LIMIT 1")
fun getTemplate(id: Long) : CommandTemplate fun getTemplate(id: Long) : CommandTemplate
@Query("SELECT * FROM commandTemplates LIMIT 1")
fun getFirst() : CommandTemplate
@Insert(onConflict = OnConflictStrategy.IGNORE) @Insert(onConflict = OnConflictStrategy.IGNORE)
suspend fun insert(item: CommandTemplate) suspend fun insert(item: CommandTemplate)

View file

@ -0,0 +1,5 @@
package com.deniscerri.ytdlnis.database.models
data class AudioPreferences(
var embedThumb: Boolean = true,
)

View file

@ -21,8 +21,9 @@ data class DownloadItem(
val website: String, val website: String,
val downloadSize: String, val downloadSize: String,
val playlistTitle: String, val playlistTitle: String,
var embedSubs: Boolean, val audioPreferences : AudioPreferences,
var addChapters: Boolean, val videoPreferences: VideoPreferences,
var customFileNameTemplate: String,
var SaveThumb: Boolean, var SaveThumb: Boolean,
@ColumnInfo(defaultValue = "Queued") @ColumnInfo(defaultValue = "Queued")
var status: String, var status: String,

View file

@ -0,0 +1,6 @@
package com.deniscerri.ytdlnis.database.models
data class VideoPreferences (
var embedSubs: Boolean = true,
var addChapters: Boolean = true,
)

View file

@ -15,9 +15,8 @@ import androidx.work.WorkManager
import com.deniscerri.ytdlnis.App import com.deniscerri.ytdlnis.App
import com.deniscerri.ytdlnis.R import com.deniscerri.ytdlnis.R
import com.deniscerri.ytdlnis.database.DBManager import com.deniscerri.ytdlnis.database.DBManager
import com.deniscerri.ytdlnis.database.models.DownloadItem import com.deniscerri.ytdlnis.database.dao.CommandTemplateDao
import com.deniscerri.ytdlnis.database.models.Format import com.deniscerri.ytdlnis.database.models.*
import com.deniscerri.ytdlnis.database.models.ResultItem
import com.deniscerri.ytdlnis.database.repository.DownloadRepository import com.deniscerri.ytdlnis.database.repository.DownloadRepository
import com.deniscerri.ytdlnis.work.DownloadWorker import com.deniscerri.ytdlnis.work.DownloadWorker
import com.google.gson.Gson import com.google.gson.Gson
@ -29,6 +28,7 @@ import java.util.concurrent.TimeUnit
class DownloadViewModel(application: Application) : AndroidViewModel(application) { class DownloadViewModel(application: Application) : AndroidViewModel(application) {
private val repository : DownloadRepository private val repository : DownloadRepository
private val sharedPreferences: SharedPreferences private val sharedPreferences: SharedPreferences
private val commandTemplateDao: CommandTemplateDao
val allDownloads : LiveData<List<DownloadItem>> val allDownloads : LiveData<List<DownloadItem>>
val queuedDownloads : LiveData<List<DownloadItem>> val queuedDownloads : LiveData<List<DownloadItem>>
val activeDownloads : LiveData<List<DownloadItem>> val activeDownloads : LiveData<List<DownloadItem>>
@ -45,6 +45,7 @@ class DownloadViewModel(application: Application) : AndroidViewModel(application
repository = DownloadRepository(dao) repository = DownloadRepository(dao)
sharedPreferences = sharedPreferences =
getApplication<App>().getSharedPreferences("root_preferences", Activity.MODE_PRIVATE) getApplication<App>().getSharedPreferences("root_preferences", Activity.MODE_PRIVATE)
commandTemplateDao = DBManager.getInstance(application).commandTemplateDao
allDownloads = repository.allDownloads allDownloads = repository.allDownloads
queuedDownloads = repository.queuedDownloads queuedDownloads = repository.queuedDownloads
@ -82,9 +83,14 @@ class DownloadViewModel(application: Application) : AndroidViewModel(application
} }
fun createDownloadItemFromResult(resultItem: ResultItem, type: Type) : DownloadItem { fun createDownloadItemFromResult(resultItem: ResultItem, type: Type) : DownloadItem {
val embedSubs = sharedPreferences.getBoolean("embed_subtitles", false) val embedSubs = sharedPreferences.getBoolean("embed_subtitles", false)
val addChapters = sharedPreferences.getBoolean("add_chapters", false) val addChapters = sharedPreferences.getBoolean("add_chapters", false)
val saveThumb = sharedPreferences.getBoolean("write_thumbnail", false) val saveThumb = sharedPreferences.getBoolean("write_thumbnail", false)
val embedThumb = sharedPreferences.getBoolean("embed_thumbnail", false)
val customFileNameTemplate = sharedPreferences.getString("file_name_template", "%(uploader)s - %(title)s")
val audioPreferences = AudioPreferences(embedThumb)
val videoPreferences = VideoPreferences(embedSubs, addChapters)
return DownloadItem(0, return DownloadItem(0,
resultItem.url, resultItem.url,
@ -94,7 +100,7 @@ class DownloadViewModel(application: Application) : AndroidViewModel(application
resultItem.duration, resultItem.duration,
type, type,
getFormat(resultItem, type), getFormat(resultItem, type),
"", resultItem.website, "", resultItem.playlistTitle, embedSubs, addChapters, saveThumb, DownloadRepository.Status.Processing.toString(), 0 "", resultItem.website, "", resultItem.playlistTitle, audioPreferences, videoPreferences,customFileNameTemplate!!, saveThumb, DownloadRepository.Status.Processing.toString(), 0
) )
} }

View file

@ -25,6 +25,7 @@ import com.deniscerri.ytdlnis.database.viewmodel.DownloadViewModel
import com.deniscerri.ytdlnis.database.viewmodel.DownloadViewModel.Type import com.deniscerri.ytdlnis.database.viewmodel.DownloadViewModel.Type
import com.deniscerri.ytdlnis.databinding.FragmentHomeBinding import com.deniscerri.ytdlnis.databinding.FragmentHomeBinding
import com.deniscerri.ytdlnis.util.FileUtil import com.deniscerri.ytdlnis.util.FileUtil
import com.google.android.material.chip.Chip
import com.google.android.material.textfield.TextInputLayout import com.google.android.material.textfield.TextInputLayout
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -190,6 +191,12 @@ class DownloadAudioFragment(private var resultItem: ResultItem) : Fragment() {
downloadItem.format.container = containers[index] downloadItem.format.container = containers[index]
} }
val embedThumb = view.findViewById<Chip>(R.id.embed_thumb)
embedThumb!!.isChecked = downloadItem.audioPreferences.embedThumb
embedThumb.setOnClickListener {
downloadItem.audioPreferences.embedThumb = embedThumb.isChecked
}
}catch (e : Exception){ }catch (e : Exception){
e.printStackTrace() e.printStackTrace()
} }

View file

@ -121,24 +121,24 @@ class DownloadCommandFragment(private val resultItem: ResultItem) : Fragment() {
commandPathResultLauncher.launch(intent) commandPathResultLauncher.launch(intent)
} }
//
val embedSubs = view.findViewById<Chip>(R.id.embed_subtitles) // val embedSubs = view.findViewById<Chip>(R.id.embed_subtitles)
embedSubs!!.isChecked = embedSubs.isChecked // embedSubs!!.isChecked = embedSubs.isChecked
embedSubs.setOnClickListener { // embedSubs.setOnClickListener {
downloadItem.embedSubs = embedSubs.isChecked // downloadItem.embedSubs = embedSubs.isChecked
} // }
//
val addChapters = view.findViewById<Chip>(R.id.add_chapters) // val addChapters = view.findViewById<Chip>(R.id.add_chapters)
addChapters!!.isChecked = addChapters.isChecked // addChapters!!.isChecked = addChapters.isChecked
addChapters.setOnClickListener{ // addChapters.setOnClickListener{
downloadItem.addChapters = addChapters.isChecked // downloadItem.addChapters = addChapters.isChecked
} // }
//
val saveThumbnail = view.findViewById<Chip>(R.id.save_thumbnail) // val saveThumbnail = view.findViewById<Chip>(R.id.save_thumbnail)
saveThumbnail!!.isChecked = saveThumbnail.isChecked // saveThumbnail!!.isChecked = saveThumbnail.isChecked
saveThumbnail.setOnClickListener { // saveThumbnail.setOnClickListener {
downloadItem.SaveThumb = saveThumbnail.isChecked // downloadItem.SaveThumb = saveThumbnail.isChecked
} // }
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()

View file

@ -174,15 +174,15 @@ class DownloadVideoFragment(private val resultItem: ResultItem) : Fragment() {
val embedSubs = view.findViewById<Chip>(R.id.embed_subtitles) val embedSubs = view.findViewById<Chip>(R.id.embed_subtitles)
embedSubs!!.isChecked = downloadItem.embedSubs embedSubs!!.isChecked = downloadItem.videoPreferences.embedSubs
embedSubs.setOnClickListener { embedSubs.setOnClickListener {
downloadItem.embedSubs = embedSubs.isChecked downloadItem.videoPreferences.embedSubs = embedSubs.isChecked
} }
val addChapters = view.findViewById<Chip>(R.id.add_chapters) val addChapters = view.findViewById<Chip>(R.id.add_chapters)
addChapters!!.isChecked = downloadItem.addChapters addChapters!!.isChecked = downloadItem.videoPreferences.addChapters
addChapters.setOnClickListener{ addChapters.setOnClickListener{
downloadItem.addChapters = addChapters.isChecked downloadItem.videoPreferences.addChapters = addChapters.isChecked
} }
val saveThumbnail = view.findViewById<Chip>(R.id.save_thumbnail) val saveThumbnail = view.findViewById<Chip>(R.id.save_thumbnail)

View file

@ -24,6 +24,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
private var limitRate: EditTextPreference? = null private var limitRate: EditTextPreference? = null
private var aria2: SwitchPreferenceCompat? = null private var aria2: SwitchPreferenceCompat? = null
private var sponsorblockFilters: MultiSelectListPreference? = null private var sponsorblockFilters: MultiSelectListPreference? = null
private var filenameTemplate: EditTextPreference? = null
private var embedSubtitles: SwitchPreferenceCompat? = null private var embedSubtitles: SwitchPreferenceCompat? = null
private var embedThumbnail: SwitchPreferenceCompat? = null private var embedThumbnail: SwitchPreferenceCompat? = null
private var addChapters: SwitchPreferenceCompat? = null private var addChapters: SwitchPreferenceCompat? = null
@ -62,6 +63,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
aria2 = findPreference("aria2") aria2 = findPreference("aria2")
sponsorblockFilters = findPreference("sponsorblock_filter") sponsorblockFilters = findPreference("sponsorblock_filter")
embedSubtitles = findPreference("embed_subtitles") embedSubtitles = findPreference("embed_subtitles")
filenameTemplate = findPreference("file_name_template")
embedThumbnail = findPreference("embed_thumbnail") embedThumbnail = findPreference("embed_thumbnail")
addChapters = findPreference("add_chapters") addChapters = findPreference("add_chapters")
writeThumbnail = findPreference("write_thumbnail") writeThumbnail = findPreference("write_thumbnail")
@ -91,6 +93,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
editor.putString("limit_rate", limitRate!!.text) editor.putString("limit_rate", limitRate!!.text)
editor.putBoolean("aria2", aria2!!.isChecked) editor.putBoolean("aria2", aria2!!.isChecked)
editor.putStringSet("sponsorblock_filters", sponsorblockFilters!!.values) editor.putStringSet("sponsorblock_filters", sponsorblockFilters!!.values)
editor.putString("file_name_template", filenameTemplate!!.text)
editor.putBoolean("embed_subtitles", embedSubtitles!!.isChecked) editor.putBoolean("embed_subtitles", embedSubtitles!!.isChecked)
editor.putBoolean("embed_thumbnail", embedThumbnail!!.isChecked) editor.putBoolean("embed_thumbnail", embedThumbnail!!.isChecked)
editor.putBoolean("add_chapters", addChapters!!.isChecked) editor.putBoolean("add_chapters", addChapters!!.isChecked)
@ -192,6 +195,12 @@ class SettingsFragment : PreferenceFragmentCompat() {
editor.apply() editor.apply()
true true
} }
filenameTemplate!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
editor.putString("file_name_template", newValue.toString())
editor.apply()
true
}
embedSubtitles!!.onPreferenceChangeListener = embedSubtitles!!.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any -> Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
val embed = newValue as Boolean val embed = newValue as Boolean

View file

@ -525,16 +525,17 @@ class InfoUtil(context: Context) {
} }
fun getSearchSuggestions(query: String): ArrayList<String> { fun getSearchSuggestions(query: String): ArrayList<String> {
val url = invidousURL + "search/suggestions?q=" + query val url = "https://suggestqueries.google.com/complete/search?client=youtube&ds=yt&client=firefox&q=$query"
val res = genericRequest(url) // invidousURL + "search/suggestions?q=" + query
val res = genericArrayRequest(url)
if (res.length() == 0) return ArrayList() if (res.length() == 0) return ArrayList()
val suggestionList = ArrayList<String>() val suggestionList = ArrayList<String>()
try { try {
val suggestions = res.getJSONArray("suggestions") for (i in 0 until res.getJSONArray(1).length()) {
for (i in 0 until suggestions.length()) { suggestionList.add(res.getJSONArray(1).getString(i))
suggestionList.add(suggestions.getString(i))
} }
} catch (ignored: Exception) { } catch (ignored: Exception) {
ignored.printStackTrace()
} }
return suggestionList return suggestionList
} }

View file

@ -57,7 +57,9 @@ class UpdateUtil(var context: Context) {
} catch (ignored: JSONException) { } catch (ignored: JSONException) {
return false return false
} }
if (version == "v" + BuildConfig.VERSION_NAME) { val versionNameInt = version.split("v")[1].replace(".","").toInt()
val currentVersionNameInt = BuildConfig.VERSION_NAME.replace(".","").toInt()
if (currentVersionNameInt > versionNameInt) {
return false return false
} }
val updateDialog = MaterialAlertDialogBuilder(context) val updateDialog = MaterialAlertDialogBuilder(context)

View file

@ -90,8 +90,7 @@ class DownloadWorker(
} }
val limitRate = sharedPreferences.getString("limit_rate", "") val limitRate = sharedPreferences.getString("limit_rate", "")
if (limitRate != "") request.addOption("-r", limitRate!!) if (limitRate != "") request.addOption("-r", limitRate!!)
val writeThumbnail = sharedPreferences.getBoolean("write_thumbnail", false) if (downloadItem.SaveThumb) {
if (writeThumbnail) {
request.addOption("--write-thumbnail") request.addOption("--write-thumbnail")
request.addOption("--convert-thumbnails", "png") request.addOption("--convert-thumbnails", "png")
} }
@ -108,6 +107,8 @@ class DownloadWorker(
if (downloadItem.author.isNotEmpty()){ if (downloadItem.author.isNotEmpty()){
request.addCommands(listOf("--replace-in-metadata","uploader",".*.",downloadItem.author)); request.addCommands(listOf("--replace-in-metadata","uploader",".*.",downloadItem.author));
} }
if (downloadItem.customFileNameTemplate.isEmpty()) downloadItem.customFileNameTemplate = "%(uploader)s - %(title)s"
when(type){ when(type){
DownloadViewModel.Type.audio -> { DownloadViewModel.Type.audio -> {
@ -124,8 +125,7 @@ class DownloadWorker(
} }
request.addOption("--embed-metadata") request.addOption("--embed-metadata")
val embedThumb = sharedPreferences.getBoolean("embed_thumbnail", false) if (downloadItem.audioPreferences.embedThumb) {
if (embedThumb) {
request.addOption("--embed-thumbnail") request.addOption("--embed-thumbnail")
request.addOption("--convert-thumbnails", "png") request.addOption("--convert-thumbnails", "png")
try { try {
@ -137,8 +137,6 @@ class DownloadWorker(
} catch (ignored: Exception) {} } catch (ignored: Exception) {}
} }
request.addOption("--parse-metadata", "%(release_year,upload_date)s:%(meta_date)s") request.addOption("--parse-metadata", "%(release_year,upload_date)s:%(meta_date)s")
request.addCommands(listOf("--replace-in-metadata", "title", ".*.", downloadItem.title))
request.addCommands(listOf("--replace-in-metadata", "uploader", ".*.", downloadItem.author))
if (downloadItem.playlistTitle.isNotEmpty()) { if (downloadItem.playlistTitle.isNotEmpty()) {
request.addOption("--parse-metadata", "%(album,playlist,title)s:%(meta_album)s") request.addOption("--parse-metadata", "%(album,playlist,title)s:%(meta_album)s")
@ -146,15 +144,13 @@ class DownloadWorker(
} else { } else {
request.addOption("--parse-metadata", "%(album,title)s:%(meta_album)s") request.addOption("--parse-metadata", "%(album,title)s:%(meta_album)s")
} }
request.addOption("-o", tempFileDir.absolutePath + "/%(uploader)s - %(title)s.%(ext)s") request.addOption("-o", tempFileDir.absolutePath + "/${downloadItem.customFileNameTemplate}.%(ext)s")
} }
DownloadViewModel.Type.video -> { DownloadViewModel.Type.video -> {
val addChapters = sharedPreferences.getBoolean("add_chapters", false) if (downloadItem.videoPreferences.addChapters) {
if (addChapters) {
request.addOption("--sponsorblock-mark", "all") request.addOption("--sponsorblock-mark", "all")
} }
val embedSubs = sharedPreferences.getBoolean("embed_subtitles", false) if (downloadItem.videoPreferences.embedSubs) {
if (embedSubs) {
request.addOption("--embed-subs", "") request.addOption("--embed-subs", "")
} }
val defaultFormats = context.resources.getStringArray(R.array.video_formats) val defaultFormats = context.resources.getStringArray(R.array.video_formats)
@ -180,7 +176,7 @@ class DownloadWorker(
request.addOption("--embed-thumbnail") request.addOption("--embed-thumbnail")
} }
} }
request.addOption("-o", tempFileDir.absolutePath + "/%(uploader)s - %(title)s.%(ext)s") request.addOption("-o", tempFileDir.absolutePath + "/${downloadItem.customFileNameTemplate}.%(ext)s")
} }
DownloadViewModel.Type.command -> { DownloadViewModel.Type.command -> {
val commandRegex = "\"([^\"]*)\"|(\\S+)" val commandRegex = "\"([^\"]*)\"|(\\S+)"

View file

@ -0,0 +1,5 @@
<vector android:height="24dp"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="?android:colorAccent" android:pathData="M5,17v2h14v-2L5,17zM9.5,12.8h5l0.9,2.2h2.1L12.75,4h-1.5L6.5,15h2.1l0.9,-2.2zM12,5.98L13.87,11h-3.74L12,5.98z"/>
</vector>

View file

@ -156,7 +156,45 @@
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
<LinearLayout
android:id="@+id/adjust_audio"
android:layout_width="match_parent"
android:padding="10dp"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:layout_width="wrap_content"
android:paddingBottom="5dp"
android:textSize="15sp"
android:layout_height="wrap_content"
android:text="@string/adjust_audio" />
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.google.android.material.chip.ChipGroup
android:id="@+id/chipGroup"
android:layout_width="wrap_content"
app:singleLine="false"
android:layout_height="wrap_content">
<com.google.android.material.chip.Chip
android:id="@+id/embed_thumb"
style="@style/Widget.Material3.Chip.Filter.Elevated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:text="@string/embed_thumb"/>
</com.google.android.material.chip.ChipGroup>
</HorizontalScrollView>
</LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -77,7 +77,6 @@
<string name="remove_non_music">Remove non-music parts</string> <string name="remove_non_music">Remove non-music parts</string>
<string name="remove_non_music_summary">Strips non-music parts of audio files with SponsorBlock</string> <string name="remove_non_music_summary">Strips non-music parts of audio files with SponsorBlock</string>
<string name="processing">Processing</string> <string name="processing">Processing</string>
<string name="embed_subs">Subtitles in Videos</string>
<string name="embed_subs_summary">Adds subtitles in the video</string> <string name="embed_subs_summary">Adds subtitles in the video</string>
<string name="embed_thumb">Thumbnail Covers</string> <string name="embed_thumb">Thumbnail Covers</string>
<string name="embed_thumb_summary">Uses the thumbnail as cover art</string> <string name="embed_thumb_summary">Uses the thumbnail as cover art</string>
@ -167,4 +166,6 @@
<string name="commands">Commands</string> <string name="commands">Commands</string>
<string name="date_added">Date added</string> <string name="date_added">Date added</string>
<string name="update_ytdl_nightly">Download Nightly Version of yt-dlp</string> <string name="update_ytdl_nightly">Download Nightly Version of yt-dlp</string>
<string name="adjust_audio">Adjust Audio</string>
<string name="file_name_template">Filename Template</string>
</resources> </resources>

View file

@ -63,7 +63,6 @@
app:key="concurrent_downloads" app:key="concurrent_downloads"
app:min="1" app:min="1"
app:showSeekBarValue="true" app:showSeekBarValue="true"
android:dependency="aria2"
app:summary="@string/concurrent_downloads_summary" app:summary="@string/concurrent_downloads_summary"
app:title="@string/concurrent_downloads" /> app:title="@string/concurrent_downloads" />
@ -95,12 +94,18 @@
app:summary="@string/select_sponsorblock_filtering" app:summary="@string/select_sponsorblock_filtering"
app:title="SponsorBlock" /> app:title="SponsorBlock" />
<EditTextPreference
android:icon="@drawable/ic_textformat"
app:key="file_name_template"
app:defaultValue="%(uploader)s - %(title)s"
app:title="@string/file_name_template" />
<SwitchPreferenceCompat <SwitchPreferenceCompat
app:defaultValue="true" app:defaultValue="true"
app:icon="@drawable/ic_subtitles" app:icon="@drawable/ic_subtitles"
app:key="embed_subtitles" app:key="embed_subtitles"
app:summary="@string/embed_subs_summary" app:summary="@string/embed_subs_summary"
app:title="@string/embed_subs" /> app:title="@string/embed_subtitles" />
<SwitchPreferenceCompat <SwitchPreferenceCompat
app:defaultValue="true" app:defaultValue="true"