fix /releases playlists not downloading

This commit is contained in:
deniscerri 2025-09-17 23:05:20 +02:00
parent 5c09a5e18a
commit adec4485de
No known key found for this signature in database
GPG key ID: 95C43D517D830350
3 changed files with 16 additions and 16 deletions

View file

@ -217,7 +217,7 @@ class HomeFragment : Fragment(), HomeAdapter.OnItemClickListener, SearchSuggesti
resultViewModel.items.observe(requireActivity()) { resultViewModel.items.observe(requireActivity()) {
updateMultiplePlaylistResults(it updateMultiplePlaylistResults(it
.filter { it2 -> it2.playlistTitle != "" && it2.playlistTitle != "YTDLNIS_SEARCH" } .filter { it2 -> it2.playlistTitle != "" && it2.playlistTitle != "YTDLNIS_SEARCH" }
.map { it.playlistTitle } .map { it2 -> it2.playlistTitle }
.distinct() .distinct()
) )
} }

View file

@ -596,20 +596,15 @@ object Extensions {
} }
} }
fun String.getIDFromYoutubeURL() : String { fun String.getIDFromYoutubeURL() : String? {
var el: Array<String?> = val regex = Regex(
this.split("/".toRegex()).dropLastWhile { it.isEmpty() } "(?:youtube\\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*?[?&]v=)|youtu\\.be/)([^\"&?/\\s]{11})"
.toTypedArray() )
var query = el[el.size - 1] val match = regex.find(this)
if (query!!.contains("watch?v=")) { return if (match != null){
query = query.substring(8) match.groupValues[1]
}else {
null
} }
el = query.split("&".toRegex()).dropLastWhile { it.isEmpty() }
.toTypedArray()
query = el[0]
el = query!!.split("\\?".toRegex()).dropLastWhile { it.isEmpty() }
.toTypedArray()
query = el[0]
return query!!
} }
} }

View file

@ -714,7 +714,12 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
@SuppressLint("RestrictedApi") @SuppressLint("RestrictedApi")
fun buildYoutubeDLRequest(downloadItem: DownloadItem) : YoutubeDLRequest { fun buildYoutubeDLRequest(downloadItem: DownloadItem) : YoutubeDLRequest {
val useItemURL = sharedPreferences.getBoolean("use_itemurl_instead_playlisturl", false) var useItemURL = sharedPreferences.getBoolean("use_itemurl_instead_playlisturl", false)
// for /releases youtube channel playlists that have playlists inside of them, cant use indexing or match filter id, so download on its own
if (downloadItem.url.isYoutubeURL() && downloadItem.url.getIDFromYoutubeURL() == null) {
useItemURL = true
}
var isPlaylistItem = false var isPlaylistItem = false
val request = StringJoiner(" ") val request = StringJoiner(" ")