fix /releases playlists not downloading

pull/924/head
deniscerri 10 months ago
parent 5c09a5e18a
commit adec4485de
No known key found for this signature in database
GPG Key ID: 95C43D517D830350

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

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

@ -714,7 +714,12 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
@SuppressLint("RestrictedApi")
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
val request = StringJoiner(" ")

Loading…
Cancel
Save