small fixes

pull/1087/head
deniscerri 6 months ago
parent abae9e8b2a
commit e48f2c5704
No known key found for this signature in database
GPG Key ID: 95C43D517D830350

@ -229,7 +229,7 @@ class FormatViewModel(private val application: Application) : AndroidViewModel(a
} }
fun getFormatsForItemsBasedOnFormat(item: Format, audioFormats: List<Format>? = null) : MutableList<MultipleItemFormatTuple> { fun getFormatsForItemsBasedOnFormat(item: Format?, audioFormats: List<Format>? = null) : MutableList<MultipleItemFormatTuple> {
val formatsToReturn = mutableListOf<MultipleItemFormatTuple>() val formatsToReturn = mutableListOf<MultipleItemFormatTuple>()
val f = if (genericAudioFormats.contains(item) || genericVideoFormats.contains(item)) item else null val f = if (genericAudioFormats.contains(item) || genericVideoFormats.contains(item)) item else null
@ -238,7 +238,7 @@ class FormatViewModel(private val application: Application) : AndroidViewModel(a
MultipleItemFormatTuple( MultipleItemFormatTuple(
it.url, it.url,
FormatTuple( FormatTuple(
f ?: it.allFormats.firstOrNull { af -> af.format_id == item.format_id }, f ?: it.allFormats.firstOrNull { af -> af.format_id == item?.format_id },
audioFormats?.map { sa -> audioFormats?.map { sa ->
it.allFormats.first { a -> a.format_id == sa.format_id } it.allFormats.first { a -> a.format_id == sa.format_id }
}?.ifEmpty { null } }?.ifEmpty { null }

@ -411,7 +411,7 @@ class FormatSelectionBottomSheetDialog(
listOf(downloadViewModel.getFormat(formats.filter { it.label == null }.map { it.format!! }, DownloadType.audio)) listOf(downloadViewModel.getFormat(formats.filter { it.label == null }.map { it.format!! }, DownloadType.audio))
})) }))
}else{ }else{
val res = formatViewModel.getFormatsForItemsBasedOnFormat(adapter.selectedVideoFormat!!, adapter.selectedAudioFormats) val res = formatViewModel.getFormatsForItemsBasedOnFormat(adapter.selectedVideoFormat, adapter.selectedAudioFormats)
multipleFormatsListener.onFormatClick(res) multipleFormatsListener.onFormatClick(res)
} }

@ -216,7 +216,7 @@ class GenerateYoutubePoTokensFragment : Fragment() {
regenerateBtn.isEnabled = false regenerateBtn.isEnabled = false
editText.doOnTextChanged { text, start, before, count -> editText.doOnTextChanged { text, start, before, count ->
regenerateBtn.isEnabled = editText.text.toString().isYoutubeURL() regenerateBtn.isEnabled = editText.text.toString().getIDFromYoutubeURL() != null
} }
regenerateBtn.setOnClickListener { regenerateBtn.setOnClickListener {

@ -307,7 +307,7 @@ object FileUtil {
return if (preference.isNullOrBlank() || !File(formatPath(preference)).canWrite()) { return if (preference.isNullOrBlank() || !File(formatPath(preference)).canWrite()) {
getDefaultApplicationPath() + "/Backups" getDefaultApplicationPath() + "/Backups"
}else { }else {
formatPath(preference) preference
} }
} }

@ -69,7 +69,7 @@ class ObserveSourceWorker(
resultRepository.getResultsFromSource(item.url, resetResults = false, addToResults = false, singleItem = false) resultRepository.getResultsFromSource(item.url, resetResults = false, addToResults = false, singleItem = false)
}.onFailure { }.onFailure {
Log.e("observe", it.toString()) Log.e("observe", it.toString())
}.getOrElse { listOf() } }.getOrElse { listOf() }.reversed()
//delete downloaded items not present in source if sync is enabled //delete downloaded items not present in source if sync is enabled
if (item.syncWithSource && item.alreadyProcessedLinks.isNotEmpty()){ if (item.syncWithSource && item.alreadyProcessedLinks.isNotEmpty()){
@ -88,31 +88,30 @@ class ObserveSourceWorker(
val toProcess = mutableListOf<ResultItem>() val toProcess = mutableListOf<ResultItem>()
//filter what results need to be downloaded, ignored //filter what results need to be downloaded, ignored
for (result in list) { for (result in list) {
val url = result.url
if (item.ignoredLinks.contains(result.url)) { if (item.ignoredLinks.contains(result.url)) {
continue continue
} }
// if first run and get only new items, ignore val history = historyRepo.getAllByURLAndType(result.url, item.downloadItemTemplate.type)
if (item.getOnlyNewUploads && item.runCount == 0) { val hasHistory = history.isNotEmpty()
val hasExistingFile = history.any { h -> h.downloadPath.any { path -> FileUtil.exists(path) }}
// First-run "only new uploads" — ONLY if truly new (no history exists)
if (item.getOnlyNewUploads && item.runCount == 0 && !hasHistory) {
item.ignoredLinks.add(result.url) item.ignoredLinks.add(result.url)
continue continue
} }
val history = historyRepo.getAllByURLAndType(result.url, item.downloadItemTemplate.type)
//if history is empty or all history items are deleted, add for retry
if (item.retryMissingDownloads && (history.isEmpty() || history.none { hi -> hi.downloadPath.any { path -> FileUtil.exists(path) } })) {
toProcess.add(result)
continue
}
if (item.alreadyProcessedLinks.isEmpty()) { // Retry missing downloads overrides everything except ignoredLinks
if (history.isEmpty()) { if (item.retryMissingDownloads && (!hasHistory || !hasExistingFile)) {
toProcess.add(result) toProcess.add(result)
continue continue
} }
}
if (item.alreadyProcessedLinks.contains(result.url)) { if (item.alreadyProcessedLinks.contains(url)) {
continue continue
} }

Loading…
Cancel
Save