youtube extractor is not working with mobile data
SahinSafi opened this issue · 1 comments
SahinSafi commented
it is working fine with wifi, but when I try to extract with mobile data it is not extract.
some time returen null value and some time return this format of url ->
https://www.youtube.com/watch?v=oK7YxPzqO_E&list=PLfSUFKdFlttn1MWrG5Q0-a9Cbm9y3uulX&index=3
fun extract(url: String) {
onProgress.postValue(true)
val vUrl = "example-youtubeUrl=${getYouTubeId(url)}"
@SuppressLint("StaticFieldLeak") val youTubeExtractor = object : YouTubeExtractor(context) {
override fun onExtractionComplete(
ytFiles: SparseArray<YtFile>?,
videoMeta: VideoMeta?
) {
onProgress.postValue(false)
val vdoUrl = url.split("/")
try {
if (vdoUrl[2] == "www.youtube.com" || vdoUrl[2] == "youtube.com" || vdoUrl[2] == "youtu.be") {
if (ytFiles != null) {
val iTags = arrayListOf<Int>()
iTags.add(22)
iTags.add(137)
iTags.add(18)
for (i in iTags) {
val file = ytFiles.get(i)
if (file != null) {
val encodedUrl = file.url
if (!encodedUrl.isNullOrEmpty()) {
val youTubeUrl = Uri.parse(encodedUrl)
onExtractComplete.postValue(youTubeUrl.toString())
return
}
}
}
} else {
onExtractComplete.postValue(url)
}
} else {
onExtractComplete.postValue(url)
}
} catch (e: Exception) {
onExtractComplete.postValue(url)
}
}
}
youTubeExtractor.extract(vUrl, true, true)
}
bunnybs commented
I have the solution .. you can contact me @bkjohns720@gmail.com