fixed some warnings

This commit is contained in:
LagradOst 2021-10-03 02:09:13 +02:00
parent 509a0a6b90
commit bf18e657f6
29 changed files with 235 additions and 283 deletions

View file

@ -9,7 +9,6 @@ import com.lagradost.cloudstream3.utils.extractorApis
import org.jsoup.Jsoup import org.jsoup.Jsoup
import java.util.* import java.util.*
class AnimeFlickProvider : MainAPI() { class AnimeFlickProvider : MainAPI() {
companion object { companion object {
fun getType(t: String): TvType { fun getType(t: String): TvType {

View file

@ -10,7 +10,6 @@ import com.lagradost.cloudstream3.utils.getQualityFromName
import org.jsoup.Jsoup import org.jsoup.Jsoup
import java.util.* import java.util.*
class GogoanimeProvider : MainAPI() { class GogoanimeProvider : MainAPI() {
companion object { companion object {
fun getType(t: String): TvType { fun getType(t: String): TvType {

View file

@ -4,7 +4,6 @@ import android.annotation.SuppressLint
import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.module.kotlin.readValue import com.fasterxml.jackson.module.kotlin.readValue
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.network.cookies
import com.lagradost.cloudstream3.network.get import com.lagradost.cloudstream3.network.get
import com.lagradost.cloudstream3.network.text import com.lagradost.cloudstream3.network.text
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
@ -16,8 +15,8 @@ import java.util.*
class TenshiProvider : MainAPI() { class TenshiProvider : MainAPI() {
companion object { companion object {
var token: String? = null //var token: String? = null
var cookie: Map<String, String> = mapOf() //var cookie: Map<String, String> = mapOf()
fun getType(t: String): TvType { fun getType(t: String): TvType {
return if (t.contains("OVA") || t.contains("Special")) TvType.ONA return if (t.contains("OVA") || t.contains("Special")) TvType.ONA
@ -39,7 +38,7 @@ class TenshiProvider : MainAPI() {
override val supportedTypes: Set<TvType> override val supportedTypes: Set<TvType>
get() = setOf(TvType.Anime, TvType.AnimeMovie, TvType.ONA) get() = setOf(TvType.Anime, TvType.AnimeMovie, TvType.ONA)
private fun loadToken(): Boolean { /*private fun loadToken(): Boolean {
return try { return try {
val response = get(mainUrl) val response = get(mainUrl)
cookie = response.cookies cookie = response.cookies
@ -49,7 +48,7 @@ class TenshiProvider : MainAPI() {
} catch (e: Exception) { } catch (e: Exception) {
false false
} }
} }*/
override fun getMainPage(): HomePageResponse { override fun getMainPage(): HomePageResponse {
val items = ArrayList<HomePageList>() val items = ArrayList<HomePageList>()
@ -259,8 +258,7 @@ class TenshiProvider : MainAPI() {
null, null,
it.attr("data-content").trim(), it.attr("data-content").trim(),
) )
} })
?: ArrayList<AnimeEpisode>())
val status = when (document.selectFirst("li.status > .value")?.text()?.trim()) { val status = when (document.selectFirst("li.status > .value")?.text()?.trim()) {
"Ongoing" -> ShowStatus.Ongoing "Ongoing" -> ShowStatus.Ongoing
"Completed" -> ShowStatus.Completed "Completed" -> ShowStatus.Completed
@ -322,7 +320,7 @@ class TenshiProvider : MainAPI() {
headers = mapOf("Referer" to data) headers = mapOf("Referer" to data)
).text ).text
val match = Regex("""sources: (\[(?:.|\s)+?type: ['\"]video\/.*?['\"](?:.|\s)+?\])""").find(sourceHTML) val match = Regex("""sources: (\[(?:.|\s)+?type: ['"]video/.*?['"](?:.|\s)+?])""").find(sourceHTML)
if (match != null) { if (match != null) {
val qualities = mapper.readValue<List<Quality>>( val qualities = mapper.readValue<List<Quality>>(
match.destructured.component1() match.destructured.component1()

View file

@ -80,16 +80,16 @@ class WatchCartoonOnlineProvider : MainAPI() {
data = mapOf("catara" to query, "konuara" to "episodes") data = mapOf("catara" to query, "konuara" to "episodes")
).text ).text
document = Jsoup.parse(response) document = Jsoup.parse(response)
items = document.select("#catlist-listview2 > ul > li").filter { it?.text() != null && !it?.text().toString().contains("Episode") } items = document.select("#catlist-listview2 > ul > li").filter { it?.text() != null && !it.text().toString().contains("Episode") }
for (item in items) { for (item in items) {
val titleHeader = item.selectFirst("a") val titleHeader = item.selectFirst("a")
val title = titleHeader.text() val title = titleHeader.text()
val href = fixUrl(titleHeader.attr("href")) val href = fixUrl(titleHeader.attr("href"))
val isDubbed = title.contains("dubbed") //val isDubbed = title.contains("dubbed")
val set: EnumSet<DubStatus> = //val set: EnumSet<DubStatus> =
EnumSet.of(if (isDubbed) DubStatus.Dubbed else DubStatus.Subbed) // EnumSet.of(if (isDubbed) DubStatus.Dubbed else DubStatus.Subbed)
returnValue.add( returnValue.add(
TvSeriesSearchResponse( TvSeriesSearchResponse(
title, title,

View file

@ -16,7 +16,7 @@ class MixDrop : ExtractorApi() {
override fun getUrl(url: String, referer: String?): List<ExtractorLink>? { override fun getUrl(url: String, referer: String?): List<ExtractorLink>? {
with(get(url)) { with(get(url)) {
getAndUnpack(this.text)?.let { unpackedText -> getAndUnpack(this.text).let { unpackedText ->
srcRegex.find(unpackedText)?.groupValues?.get(1)?.let { link -> srcRegex.find(unpackedText)?.groupValues?.get(1)?.let { link ->
return listOf( return listOf(
ExtractorLink( ExtractorLink(

View file

@ -12,7 +12,7 @@ class Mp4Upload : ExtractorApi() {
override fun getUrl(url: String, referer: String?): List<ExtractorLink>? { override fun getUrl(url: String, referer: String?): List<ExtractorLink>? {
with(get(url)) { with(get(url)) {
getAndUnpack(this.text)?.let { unpackedText -> getAndUnpack(this.text).let { unpackedText ->
srcRegex.find(unpackedText)?.groupValues?.get(1)?.let { link -> srcRegex.find(unpackedText)?.groupValues?.get(1)?.let { link ->
return listOf( return listOf(
ExtractorLink( ExtractorLink(

View file

@ -29,7 +29,7 @@ class MultiQuality : ExtractorApi() {
} }
} }
override fun getUrl(url: String, referer: String?): List<ExtractorLink>? { override fun getUrl(url: String, referer: String?): List<ExtractorLink> {
val extractedLinksList: MutableList<ExtractorLink> = mutableListOf() val extractedLinksList: MutableList<ExtractorLink> = mutableListOf()
with(get(url)) { with(get(url)) {
sourceRegex.findAll(this.text).forEach { sourceMatch -> sourceRegex.findAll(this.text).forEach { sourceMatch ->
@ -65,6 +65,5 @@ class MultiQuality : ExtractorApi() {
} }
return extractedLinksList return extractedLinksList
} }
return null
} }
} }

View file

@ -23,7 +23,7 @@ class SBPlay : ExtractorApi() {
val response = get(url, referer = referer).text val response = get(url, referer = referer).text
val document = Jsoup.parse(response) val document = Jsoup.parse(response)
val links = ArrayList<ExtractorLink>(); val links = ArrayList<ExtractorLink>()
val tree = document.select("table > tbody > tr > td > a") val tree = document.select("table > tbody > tr > td > a")
for (item in tree) { for (item in tree) {

View file

@ -24,7 +24,7 @@ class StreamSB : ExtractorApi() {
val extractedLinksList: MutableList<ExtractorLink> = mutableListOf() val extractedLinksList: MutableList<ExtractorLink> = mutableListOf()
val newUrl = url.replace("sbplay.org/embed-", "sbplay.org/play/").removeSuffix(".html") val newUrl = url.replace("sbplay.org/embed-", "sbplay.org/play/").removeSuffix(".html")
with(get(newUrl, timeout = 10)) { with(get(newUrl, timeout = 10)) {
getAndUnpack(this.text)?.let { getAndUnpack(this.text).let {
sourceRegex.findAll(it).forEach { sourceMatch -> sourceRegex.findAll(it).forEach { sourceMatch ->
val extractedUrl = sourceMatch.groupValues[1] val extractedUrl = sourceMatch.groupValues[1]
if (extractedUrl.contains(".m3u8")) { if (extractedUrl.contains(".m3u8")) {

View file

@ -293,7 +293,7 @@ class TrailersToProvider : MainAPI() {
Pair( Pair(
subUrl, subUrl,
fixUrl( fixUrl(
document?.selectFirst("content")?.attr("data-url") document.selectFirst("content")?.attr("data-url")
?: throw ErrorLoadingException("Link not found") ?: throw ErrorLoadingException("Link not found")
) )
) )

View file

@ -77,10 +77,10 @@ class VfFilmProvider : MainAPI() {
private fun getDirect(original: String): String { // original data, https://vf-film.org/?trembed=1&trid=55313&trtype=1 for example private fun getDirect(original: String): String { // original data, https://vf-film.org/?trembed=1&trid=55313&trtype=1 for example
val response = get(original).text val response = get(original).text
val url = "iframe .*src=\\\"(.*?)\\\"".toRegex().find(response)?.groupValues?.get(1).toString() // https://vudeo.net/embed-uweno86lzx8f.html for example val url = "iframe .*src=\"(.*?)\"".toRegex().find(response)?.groupValues?.get(1).toString() // https://vudeo.net/embed-uweno86lzx8f.html for example
val vudoResponse = get(url).text val vudoResponse = get(url).text
val document = Jsoup.parse(vudoResponse) val document = Jsoup.parse(vudoResponse)
val vudoUrl = Regex("sources: \\[\\\"(.*?)\\\"\\]").find(document.html())?.groupValues?.get(1).toString() // direct mp4 link, https://m11.vudeo.net/2vp3ukyw2avjdohilpebtzuct42q5jwvpmpsez3xjs6d7fbs65dpuey2rbra/v.mp4 for exemple val vudoUrl = Regex("sources: \\[\"(.*?)\"]").find(document.html())?.groupValues?.get(1).toString() // direct mp4 link, https://m11.vudeo.net/2vp3ukyw2avjdohilpebtzuct42q5jwvpmpsez3xjs6d7fbs65dpuey2rbra/v.mp4 for exemple
return vudoUrl return vudoUrl
} }

View file

@ -95,7 +95,7 @@ class VidEmbedProvider : MainAPI() {
val description = soup.selectFirst(".post-entry")?.text()?.trim() val description = soup.selectFirst(".post-entry")?.text()?.trim()
var poster: String? = null var poster: String? = null
val episodes = soup.select(".listing.items.lists > .video-block").withIndex().map { (index, li) -> val episodes = soup.select(".listing.items.lists > .video-block").withIndex().map { (_, li) ->
val epTitle = if (li.selectFirst(".name") != null) val epTitle = if (li.selectFirst(".name") != null)
if (li.selectFirst(".name").text().contains("Episode")) if (li.selectFirst(".name").text().contains("Episode"))
"Episode " + li.selectFirst(".name").text().split("Episode")[1].trim() "Episode " + li.selectFirst(".name").text().split("Episode")[1].trim()
@ -162,7 +162,7 @@ class VidEmbedProvider : MainAPI() {
// This loads the homepage, which is basically a collection of search results with labels. // This loads the homepage, which is basically a collection of search results with labels.
// Optional function, but make sure to enable hasMainPage if you program this. // Optional function, but make sure to enable hasMainPage if you program this.
override fun getMainPage(): HomePageResponse? { override fun getMainPage(): HomePageResponse {
val urls = listOf( val urls = listOf(
mainUrl, mainUrl,
"$mainUrl/movies", "$mainUrl/movies",
@ -262,8 +262,8 @@ class VidEmbedProvider : MainAPI() {
// Having a referer is often required. It's a basic security check most providers have. // Having a referer is often required. It's a basic security check most providers have.
// Try to replicate what your browser does. // Try to replicate what your browser does.
val html = get(it.second, headers = mapOf("referer" to iframeLink)).text val serverHtml = get(it.second, headers = mapOf("referer" to iframeLink)).text
sourceRegex.findAll(html).forEach { match -> sourceRegex.findAll(serverHtml).forEach { match ->
callback.invoke( callback.invoke(
ExtractorLink( ExtractorLink(
this.name, this.name,
@ -279,7 +279,7 @@ class VidEmbedProvider : MainAPI() {
) )
) )
} }
trackRegex.findAll(html).forEach { match -> trackRegex.findAll(serverHtml).forEach { match ->
subtitleCallback.invoke( subtitleCallback.invoke(
SubtitleFile( SubtitleFile(
match.groupValues.getOrNull(2) ?: "Unknown", match.groupValues.getOrNull(2) ?: "Unknown",

View file

@ -5,7 +5,6 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.util.Log import android.util.Log
class VideoDownloadRestartReceiver : BroadcastReceiver() { class VideoDownloadRestartReceiver : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) { override fun onReceive(context: Context?, intent: Intent?) {
Log.i("Broadcast Listened", "Service tried to stop") Log.i("Broadcast Listened", "Service tried to stop")

View file

@ -28,15 +28,12 @@ import com.lagradost.cloudstream3.sortUrls
import com.lagradost.cloudstream3.ui.result.ResultEpisode import com.lagradost.cloudstream3.ui.result.ResultEpisode
import com.lagradost.cloudstream3.utils.CastHelper.awaitLinks import com.lagradost.cloudstream3.utils.CastHelper.awaitLinks
import com.lagradost.cloudstream3.utils.CastHelper.getMediaInfo import com.lagradost.cloudstream3.utils.CastHelper.getMediaInfo
import com.lagradost.cloudstream3.utils.Coroutines.main
import com.lagradost.cloudstream3.utils.DataStore.toKotlinObject import com.lagradost.cloudstream3.utils.DataStore.toKotlinObject
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.json.JSONObject import org.json.JSONObject
import kotlin.concurrent.thread import kotlin.concurrent.thread
class SkipOpController(val view: ImageView) : UIController() { /*class SkipOpController(val view: ImageView) : UIController() {
init { init {
view.setImageResource(R.drawable.exo_controls_fastforward) view.setImageResource(R.drawable.exo_controls_fastforward)
view.setOnClickListener { view.setOnClickListener {
@ -47,12 +44,12 @@ class SkipOpController(val view: ImageView) : UIController() {
} }
} }
} }
} }*/
private fun RemoteMediaClient.getItemIndex(): Int? { private fun RemoteMediaClient.getItemIndex(): Int? {
return try { return try {
val index = this.mediaQueue?.itemIds?.indexOf(this.currentItem?.itemId ?: 0) val index = this.mediaQueue.itemIds.indexOf(this.currentItem?.itemId ?: 0)
if (index == null || index < 0) null else index if (index < 0) null else index
} catch (e: Exception) { } catch (e: Exception) {
null null
} }
@ -136,7 +133,7 @@ class SelectSourceController(val view: ImageView, val activity: ControllerActivi
subtitleList.setOnItemClickListener { _, _, which, _ -> subtitleList.setOnItemClickListener { _, _, which, _ ->
if (which == 0) { if (which == 0) {
remoteMediaClient.setActiveMediaTracks(longArrayOf()) // NO SUBS remoteMediaClient?.setActiveMediaTracks(longArrayOf()) // NO SUBS
} else { } else {
val font = TextTrackStyle() val font = TextTrackStyle()
font.fontFamily = "Google Sans" //TODO FONT SETTINGS font.fontFamily = "Google Sans" //TODO FONT SETTINGS
@ -147,10 +144,10 @@ class SelectSourceController(val view: ImageView, val activity: ControllerActivi
font.foregroundColor = Color.WHITE font.foregroundColor = Color.WHITE
font.fontScale = 1.05f font.fontScale = 1.05f
remoteMediaClient.setTextTrackStyle(font) remoteMediaClient?.setTextTrackStyle(font)
remoteMediaClient.setActiveMediaTracks(longArrayOf(subTracks[which - 1].id)) remoteMediaClient?.setActiveMediaTracks(longArrayOf(subTracks[which - 1].id))
.setResultCallback { ?.setResultCallback {
if (!it.status.isSuccess) { if (!it.status.isSuccess) {
Log.e( Log.e(
"CHROMECAST", "Failed with status code:" + "CHROMECAST", "Failed with status code:" +
@ -332,7 +329,9 @@ class SelectSourceController(val view: ImageView, val activity: ControllerActivi
} }
override fun onSessionConnected(castSession: CastSession?) { override fun onSessionConnected(castSession: CastSession?) {
super.onSessionConnected(castSession) castSession?.let {
super.onSessionConnected(it)
}
remoteMediaClient?.queueSetRepeatMode(REPEAT_MODE_REPEAT_OFF, JSONObject()) remoteMediaClient?.queueSetRepeatMode(REPEAT_MODE_REPEAT_OFF, JSONObject())
} }
} }

View file

@ -54,7 +54,7 @@ class DownloadChildFragment : Fragment() {
?: return@mapNotNull null ?: return@mapNotNull null
VisualDownloadChildCached(info.fileLength, info.totalBytes, it) VisualDownloadChildCached(info.fileLength, info.totalBytes, it)
} }
} }.sortedBy { it.data.episode + (it.data.season?: 0)*100000 }
if (eps.isEmpty()) { if (eps.isEmpty()) {
activity?.onBackPressed() activity?.onBackPressed()
return@main return@main

View file

@ -102,10 +102,7 @@ class DownloadFragment : Fragment() {
} else { } else {
val folder = getFolderName(DOWNLOAD_EPISODE_CACHE, click.data.id.toString()) val folder = getFolderName(DOWNLOAD_EPISODE_CACHE, click.data.id.toString())
val navController = activity?.findNavController(R.id.nav_host_fragment) val navController = activity?.findNavController(R.id.nav_host_fragment)
navController?.navigate(R.id.navigation_download_child, Bundle().apply { navController?.navigate(R.id.navigation_download_child, DownloadChildFragment.newInstance(click.data.name,folder))
putString("folder", folder)
putString("name", click.data.name)
})
} }
}, },
{ downloadClickEvent -> { downloadClickEvent ->

View file

@ -1,6 +1,5 @@
package com.lagradost.cloudstream3.ui.download package com.lagradost.cloudstream3.ui.download
import android.annotation.SuppressLint
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup

View file

@ -13,7 +13,6 @@ import com.lagradost.cloudstream3.SearchResponse
import com.lagradost.cloudstream3.mvvm.Resource import com.lagradost.cloudstream3.mvvm.Resource
import com.lagradost.cloudstream3.ui.APIRepository import com.lagradost.cloudstream3.ui.APIRepository
import com.lagradost.cloudstream3.ui.APIRepository.Companion.noneApi import com.lagradost.cloudstream3.ui.APIRepository.Companion.noneApi
import com.lagradost.cloudstream3.ui.APIRepository.Companion.noneRepo
import com.lagradost.cloudstream3.ui.APIRepository.Companion.randomApi import com.lagradost.cloudstream3.ui.APIRepository.Companion.randomApi
import com.lagradost.cloudstream3.ui.WatchType import com.lagradost.cloudstream3.ui.WatchType
import com.lagradost.cloudstream3.utils.DOWNLOAD_HEADER_CACHE import com.lagradost.cloudstream3.utils.DOWNLOAD_HEADER_CACHE

View file

@ -33,7 +33,6 @@ import android.widget.*
import android.widget.Toast.LENGTH_SHORT import android.widget.Toast.LENGTH_SHORT
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.net.toUri
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
@ -47,7 +46,6 @@ import com.fasterxml.jackson.module.kotlin.KotlinModule
import com.fasterxml.jackson.module.kotlin.readValue import com.fasterxml.jackson.module.kotlin.readValue
import com.google.android.exoplayer2.* import com.google.android.exoplayer2.*
import com.google.android.exoplayer2.C.TIME_UNSET import com.google.android.exoplayer2.C.TIME_UNSET
import com.google.android.exoplayer2.PlaybackException.ERROR_CODE_AUDIO_TRACK_INIT_FAILED
import com.google.android.exoplayer2.database.ExoDatabaseProvider import com.google.android.exoplayer2.database.ExoDatabaseProvider
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory import com.google.android.exoplayer2.source.DefaultMediaSourceFactory
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
@ -247,8 +245,6 @@ class PlayerFragment : Fragment() {
private lateinit var playerData: PlayerData private lateinit var playerData: PlayerData
private lateinit var uriData: UriData private lateinit var uriData: UriData
private var isDownloadedFile = false private var isDownloadedFile = false
private var downloadId = 0
private var isLoading = true
private var isShowing = true private var isShowing = true
private lateinit var exoPlayer: SimpleExoPlayer private lateinit var exoPlayer: SimpleExoPlayer
@ -748,8 +744,6 @@ class PlayerFragment : Fragment() {
} }
} }
private var volumeObserver: SettingsContentObserver? = null
companion object { companion object {
fun String.toSubtitleMimeType(): String { fun String.toSubtitleMimeType(): String {
return when { return when {
@ -764,7 +758,6 @@ class PlayerFragment : Fragment() {
return Bundle().apply { return Bundle().apply {
//println(data) //println(data)
putString("data", mapper.writeValueAsString(data)) putString("data", mapper.writeValueAsString(data))
println("PUT START: " + startPos)
if (startPos != null) { if (startPos != null) {
putLong(STATE_RESUME_POSITION, startPos) putLong(STATE_RESUME_POSITION, startPos)
} }
@ -1042,13 +1035,14 @@ class PlayerFragment : Fragment() {
exoPlayer.play() exoPlayer.play()
} }
}*/ }*/
activity?.let { act ->
if (activity?.isCastApiAvailable() == true && !isDownloadedFile) { if (act.isCastApiAvailable() && !isDownloadedFile) {
try { try {
CastButtonFactory.setUpMediaRouteButton(activity, player_media_route_button) CastButtonFactory.setUpMediaRouteButton(act, player_media_route_button)
val castContext = CastContext.getSharedInstance(requireContext()) val castContext = CastContext.getSharedInstance(requireContext())
if (castContext.castState != CastState.NO_DEVICES_AVAILABLE) player_media_route_button.visibility = VISIBLE if (castContext.castState != CastState.NO_DEVICES_AVAILABLE) player_media_route_button.visibility =
VISIBLE
castContext.addCastStateListener { state -> castContext.addCastStateListener { state ->
if (player_media_route_button != null) { if (player_media_route_button != null) {
player_media_route_button.isVisible = state != CastState.NO_DEVICES_AVAILABLE player_media_route_button.isVisible = state != CastState.NO_DEVICES_AVAILABLE
@ -1119,11 +1113,11 @@ class PlayerFragment : Fragment() {
} }
} }
} }
} catch (e : Exception) { } catch (e: Exception) {
logError(e) logError(e)
} }
} }
}
isDownloadedFile = false isDownloadedFile = false
arguments?.getString("uriData")?.let { arguments?.getString("uriData")?.let {
uriData = mapper.readValue(it) uriData = mapper.readValue(it)
@ -1159,7 +1153,7 @@ class PlayerFragment : Fragment() {
activity?.let { activity?.let {
it.contentResolver?.registerContentObserver( it.contentResolver?.registerContentObserver(
android.provider.Settings.System.CONTENT_URI, true, SettingsContentObserver( Settings.System.CONTENT_URI, true, SettingsContentObserver(
Handler( Handler(
Looper.getMainLooper() Looper.getMainLooper()
), it ), it
@ -1172,13 +1166,13 @@ class PlayerFragment : Fragment() {
observeDirectly(viewModel.episodes) { _episodes -> observeDirectly(viewModel.episodes) { _episodes ->
episodes = _episodes episodes = _episodes
if (isLoading) { /*if (isLoading) {
/*if (playerData.episodeIndex > 0 && playerData.episodeIndex < episodes.size) { if (playerData.episodeIndex > 0 && playerData.episodeIndex < episodes.size) {
} else { } else {
// WHAT THE FUCK DID YOU DO // WHAT THE FUCK DID YOU DO
}*/
} }
}*/
} }
observe(viewModel.apiName) { observe(viewModel.apiName) {
@ -1485,7 +1479,7 @@ class PlayerFragment : Fragment() {
requireContext().setKey(RESIZE_MODE_KEY, resizeMode) requireContext().setKey(RESIZE_MODE_KEY, resizeMode)
player_view.resizeMode = resizeModes[resizeMode].first player_view.resizeMode = resizeModes[resizeMode].first
activity?.let { act -> activity?.let { act ->
showToast(act, resizeModes[resizeMode].second, Toast.LENGTH_SHORT); showToast(act, resizeModes[resizeMode].second, LENGTH_SHORT)
} }
//exoPlayer.videoScalingMode = C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING //exoPlayer.videoScalingMode = C.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING
} }
@ -1508,18 +1502,6 @@ class PlayerFragment : Fragment() {
// initPlayer() // initPlayer()
} }
private fun getRendererIndex(trackIndex: Int): Int? {
if (!this::exoPlayer.isInitialized) return null
for (renderIndex in 0 until exoPlayer.rendererCount) {
if (exoPlayer.getRendererType(renderIndex) == renderIndex) {
return renderIndex
}
}
return null
}
private fun getCurrentUrl(): ExtractorLink? { private fun getCurrentUrl(): ExtractorLink? {
val urls = getUrls() ?: return null val urls = getUrls() ?: return null
for (i in urls) { for (i in urls) {
@ -2067,7 +2049,11 @@ class PlayerFragment : Fragment() {
} }
} }
PlaybackException.ERROR_CODE_REMOTE_ERROR, PlaybackException.ERROR_CODE_IO_BAD_HTTP_STATUS, PlaybackException.ERROR_CODE_TIMEOUT, PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED, PlaybackException.ERROR_CODE_IO_INVALID_HTTP_CONTENT_TYPE -> { PlaybackException.ERROR_CODE_REMOTE_ERROR, PlaybackException.ERROR_CODE_IO_BAD_HTTP_STATUS, PlaybackException.ERROR_CODE_TIMEOUT, PlaybackException.ERROR_CODE_IO_NETWORK_CONNECTION_FAILED, PlaybackException.ERROR_CODE_IO_INVALID_HTTP_CONTENT_TYPE -> {
showToast(activity, "${getString(R.string.remote_error)}\n$errorName ($code)\n$msg", LENGTH_SHORT) showToast(
activity,
"${getString(R.string.remote_error)}\n$errorName ($code)\n$msg",
LENGTH_SHORT
)
} }
PlaybackException.ERROR_CODE_DECODING_FAILED, PlaybackErrorEvent.ERROR_AUDIO_TRACK_INIT_FAILED, PlaybackErrorEvent.ERROR_AUDIO_TRACK_OTHER, PlaybackException.ERROR_CODE_AUDIO_TRACK_WRITE_FAILED, PlaybackException.ERROR_CODE_DECODER_INIT_FAILED, PlaybackException.ERROR_CODE_DECODER_QUERY_FAILED -> { PlaybackException.ERROR_CODE_DECODING_FAILED, PlaybackErrorEvent.ERROR_AUDIO_TRACK_INIT_FAILED, PlaybackErrorEvent.ERROR_AUDIO_TRACK_OTHER, PlaybackException.ERROR_CODE_AUDIO_TRACK_WRITE_FAILED, PlaybackException.ERROR_CODE_DECODER_INIT_FAILED, PlaybackException.ERROR_CODE_DECODER_QUERY_FAILED -> {
showToast( showToast(

View file

@ -280,7 +280,7 @@ class ResultViewModel : ViewModel() {
if (dataList != null) { // TODO dub and sub at the same time if (dataList != null) { // TODO dub and sub at the same time
val episodes = ArrayList<ResultEpisode>() val episodes = ArrayList<ResultEpisode>()
for ((index, i) in dataList.withIndex()) { for ((index, i) in dataList.withIndex()) {
val episode = i.episode ?: (index + 1); val episode = i.episode ?: (index + 1)
episodes.add( episodes.add(
context.buildResultEpisode( context.buildResultEpisode(
filterName(i.name), filterName(i.name),

View file

@ -72,7 +72,7 @@ object CastHelper {
if (pending == null) return if (pending == null) return
main { main {
val res = withContext(Dispatchers.IO) { pending.await() } val res = withContext(Dispatchers.IO) { pending.await() }
when (res.status?.statusCode) { when (res.status.statusCode) {
CastStatusCodes.FAILED -> { CastStatusCodes.FAILED -> {
callback.invoke(true) callback.invoke(true)
println("FAILED AND LOAD NEXT") println("FAILED AND LOAD NEXT")

View file

@ -10,7 +10,6 @@ import com.lagradost.cloudstream3.utils.DataStore.getKey
import com.lagradost.cloudstream3.utils.DataStore.removeKey import com.lagradost.cloudstream3.utils.DataStore.removeKey
import com.lagradost.cloudstream3.utils.VideoDownloadManager.WORK_KEY_INFO import com.lagradost.cloudstream3.utils.VideoDownloadManager.WORK_KEY_INFO
import com.lagradost.cloudstream3.utils.VideoDownloadManager.WORK_KEY_PACKAGE import com.lagradost.cloudstream3.utils.VideoDownloadManager.WORK_KEY_PACKAGE
import com.lagradost.cloudstream3.utils.VideoDownloadManager.createNotification
import com.lagradost.cloudstream3.utils.VideoDownloadManager.downloadCheck import com.lagradost.cloudstream3.utils.VideoDownloadManager.downloadCheck
import com.lagradost.cloudstream3.utils.VideoDownloadManager.downloadEpisode import com.lagradost.cloudstream3.utils.VideoDownloadManager.downloadEpisode
import com.lagradost.cloudstream3.utils.VideoDownloadManager.downloadFromResume import com.lagradost.cloudstream3.utils.VideoDownloadManager.downloadFromResume

View file

@ -1,9 +1,5 @@
package com.lagradost.cloudstream3.utils package com.lagradost.cloudstream3.utils
import com.lagradost.cloudstream3.mvvm.logError
import java.lang.Exception
import java.lang.StringBuilder
import java.util.HashMap
import java.util.regex.Pattern import java.util.regex.Pattern
import kotlin.math.pow import kotlin.math.pow

View file

@ -85,7 +85,7 @@ class M3u8Helper {
for (match in QUALITY_REGEX.findAll(response)) { for (match in QUALITY_REGEX.findAll(response)) {
var (quality, m3u8Link, m3u8Link2) = match.destructured var (quality, m3u8Link, m3u8Link2) = match.destructured
if (m3u8Link.isNullOrEmpty()) m3u8Link = m3u8Link2 if (m3u8Link.isEmpty()) m3u8Link = m3u8Link2
if (absoluteExtensionDetermination(m3u8Link) == "m3u8") { if (absoluteExtensionDetermination(m3u8Link) == "m3u8") {
if (isNotCompleteUrl(m3u8Link)) { if (isNotCompleteUrl(m3u8Link)) {
m3u8Link = "$m3u8Parent/$m3u8Link" m3u8Link = "$m3u8Parent/$m3u8Link"
@ -138,7 +138,7 @@ class M3u8Helper {
if (secondSelection != null) { if (secondSelection != null) {
val m3u8Response = get(secondSelection.streamUrl, headers = headers).text val m3u8Response = get(secondSelection.streamUrl, headers = headers).text
var encryptionUri: String? = null var encryptionUri: String?
var encryptionIv = byteArrayOf() var encryptionIv = byteArrayOf()
var encryptionData = byteArrayOf() var encryptionData = byteArrayOf()

View file

@ -2,7 +2,6 @@ package com.lagradost.cloudstream3.utils
import android.app.Dialog import android.app.Dialog
import android.content.Context import android.content.Context
import android.view.View
import android.widget.* import android.widget.*
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.core.view.isVisible import androidx.core.view.isVisible
@ -10,9 +9,7 @@ import androidx.core.view.marginLeft
import androidx.core.view.marginRight import androidx.core.view.marginRight
import androidx.core.view.marginTop import androidx.core.view.marginTop
import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialog
import com.lagradost.cloudstream3.MainActivity.Companion.updateLocale
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog
object SingleSelectionHelper { object SingleSelectionHelper {
fun Context.showDialog( fun Context.showDialog(

View file

@ -16,7 +16,7 @@ object SubtitleHelper {
val ISO_639_6: String, val ISO_639_6: String,
) )
fun createISO() { /*fun createISO() {
val url = "https://infogalactic.com/info/List_of_ISO_639-1_codes" val url = "https://infogalactic.com/info/List_of_ISO_639-1_codes"
val response = get(url).text val response = get(url).text
val document = Jsoup.parse(response) val document = Jsoup.parse(response)
@ -40,7 +40,7 @@ object SubtitleHelper {
} }
text += ")" text += ")"
println("ISO CREATED:\n$text") println("ISO CREATED:\n$text")
} }*/
/** lang -> ISO_639_1*/ /** lang -> ISO_639_1*/
fun fromLanguageToTwoLetters(input: String): String? { fun fromLanguageToTwoLetters(input: String): String? {

View file

@ -661,10 +661,9 @@ object VideoDownloadManager {
val contentLength = try { val contentLength = try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { // fuck android if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { // fuck android
connection.contentLengthLong ?: 0L connection.contentLengthLong
} else { } else {
connection.getHeaderField("content-length").toLongOrNull() ?: connection.contentLength?.toLong() connection.getHeaderField("content-length").toLongOrNull() ?: connection.contentLength.toLong()
?: 0L
} }
} catch (e: Exception) { } catch (e: Exception) {
logError(e) logError(e)

View file

@ -1,17 +0,0 @@
package com.lagradost.cloudstream3
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}

View file

@ -13,50 +13,6 @@ class ProviderTests {
return allApis return allApis
} }
@Test
fun providers_exist() {
Assert.assertTrue(getAllProviders().isNotEmpty())
}
@Test
fun provider_correct_data() {
val isoNames = SubtitleHelper.languages.map { it.ISO_639_1 }
Assert.assertFalse("ISO does not contain any languages", isoNames.isNullOrEmpty())
for (api in getAllProviders()) {
Assert.assertTrue("Api does not contain a mainurl", api.mainUrl != "NONE")
Assert.assertTrue("Api does not contain a name", api.name != "NONE")
Assert.assertTrue("Api ${api.name} does not contain a valid language code", isoNames.contains(api.lang))
Assert.assertTrue("Api ${api.name} does not contain any supported types", api.supportedTypes.isNotEmpty())
}
}
@Test
fun provider_correct_homepage() {
for (api in getAllProviders()) {
if (api.hasMainPage) {
try {
val homepage = api.getMainPage()
when {
homepage == null -> {
Assert.fail("Homepage provider ${api.name} did not correctly load homepage!")
}
homepage.items.isEmpty() -> {
Assert.fail("Homepage provider ${api.name} does not contain any items!")
}
homepage.items.any { it.list.isEmpty() } -> {
Assert.fail("Homepage provider ${api.name} does not have any items on result!")
}
}
} catch (e: Exception) {
if (e.cause is NotImplementedError) {
Assert.fail("Provider marked as hasMainPage, while in reality is has not been implemented")
}
logError(e)
}
}
}
}
private fun loadLinks(api: MainAPI, url: String?): Boolean { private fun loadLinks(api: MainAPI, url: String?): Boolean {
Assert.assertNotNull("Api ${api.name} has invalid url on episode", url) Assert.assertNotNull("Api ${api.name} has invalid url on episode", url)
if (url == null) return true if (url == null) return true
@ -83,13 +39,8 @@ class ProviderTests {
return true return true
} }
@Test private fun test_single_provider(api: MainAPI) {
fun provider_correct() {
val searchQueries = listOf("over", "iron", "guy") val searchQueries = listOf("over", "iron", "guy")
val providers = getAllProviders()
for ((index, api) in providers.withIndex()) {
try {
println("Trying $api (${index + 1}/${providers.size})")
var correctResponses = 0 var correctResponses = 0
var searchResult: List<SearchResponse>? = null var searchResult: List<SearchResponse>? = null
for (query in searchQueries) { for (query in searchQueries) {
@ -112,7 +63,7 @@ class ProviderTests {
if (correctResponses == 0 || searchResult == null) { if (correctResponses == 0 || searchResult == null) {
println("Api ${api.name} did not return any valid search responses") println("Api ${api.name} did not return any valid search responses")
continue return
} }
try { try {
@ -169,6 +120,59 @@ class ProviderTests {
} }
logError(e) logError(e)
} }
}
@Test
fun providers_exist() {
Assert.assertTrue(getAllProviders().isNotEmpty())
}
@Test
fun provider_correct_data() {
val isoNames = SubtitleHelper.languages.map { it.ISO_639_1 }
Assert.assertFalse("ISO does not contain any languages", isoNames.isNullOrEmpty())
for (api in getAllProviders()) {
Assert.assertTrue("Api does not contain a mainUrl", api.mainUrl != "NONE")
Assert.assertTrue("Api does not contain a name", api.name != "NONE")
Assert.assertTrue("Api ${api.name} does not contain a valid language code", isoNames.contains(api.lang))
Assert.assertTrue("Api ${api.name} does not contain any supported types", api.supportedTypes.isNotEmpty())
}
}
@Test
fun provider_correct_homepage() {
for (api in getAllProviders()) {
if (api.hasMainPage) {
try {
val homepage = api.getMainPage()
when {
homepage == null -> {
Assert.fail("Homepage provider ${api.name} did not correctly load homepage!")
}
homepage.items.isEmpty() -> {
Assert.fail("Homepage provider ${api.name} does not contain any items!")
}
homepage.items.any { it.list.isEmpty() } -> {
Assert.fail("Homepage provider ${api.name} does not have any items on result!")
}
}
} catch (e: Exception) {
if (e.cause is NotImplementedError) {
Assert.fail("Provider marked as hasMainPage, while in reality is has not been implemented")
}
logError(e)
}
}
}
}
@Test
fun provider_correct() {
val providers = getAllProviders()
for ((index, api) in providers.withIndex()) {
try {
println("Trying $api (${index + 1}/${providers.size})")
test_single_provider(api)
} catch (e: Exception) { } catch (e: Exception) {
logError(e) logError(e)
} }