Skip to content

Commit

Permalink
fix(all/animexin): Fix YoutubeExtractor (#2360)
Browse files Browse the repository at this point in the history
Co-authored-by: folke <[email protected]>
  • Loading branch information
Claudemirovsky and Secozzi authored Oct 13, 2023
1 parent d0fea7d commit 9c8799b
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 212 deletions.
1 change: 1 addition & 0 deletions multisrc/overrides/animestream/animexin/additional.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ dependencies {
implementation(project(':lib-dailymotion-extractor'))
implementation(project(':lib-okru-extractor'))
implementation(project(':lib-gdriveplayer-extractor'))
implementation(project(':lib-dood-extractor'))
implementation "dev.datlag.jsunpacker:jsunpacker:1.0.1"
}
40 changes: 17 additions & 23 deletions multisrc/overrides/animestream/animexin/src/AnimeXin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package eu.kanade.tachiyomi.animeextension.all.animexin

import androidx.preference.ListPreference
import androidx.preference.PreferenceScreen
import eu.kanade.tachiyomi.animeextension.all.animexin.extractors.DoodExtractor
import eu.kanade.tachiyomi.animeextension.all.animexin.extractors.VidstreamingExtractor
import eu.kanade.tachiyomi.animeextension.all.animexin.extractors.YouTubeExtractor
import eu.kanade.tachiyomi.animesource.model.Video
import eu.kanade.tachiyomi.lib.dailymotionextractor.DailymotionExtractor
import eu.kanade.tachiyomi.lib.doodextractor.DoodExtractor
import eu.kanade.tachiyomi.lib.gdriveplayerextractor.GdrivePlayerExtractor
import eu.kanade.tachiyomi.lib.okruextractor.OkruExtractor
import eu.kanade.tachiyomi.multisrc.animestream.AnimeStream
Expand All @@ -19,41 +19,37 @@ class AnimeXin : AnimeStream(
override val id = 4620219025406449669

// ============================ Video Links =============================
private val dailymotionExtractor by lazy { DailymotionExtractor(client, headers) }
private val doodExtractor by lazy { DoodExtractor(client) }
private val gdrivePlayerExtractor by lazy { GdrivePlayerExtractor(client) }
private val okruExtractor by lazy { OkruExtractor(client) }
private val vidstreamingExtractor by lazy { VidstreamingExtractor(client) }
private val youTubeExtractor by lazy { YouTubeExtractor(client) }

override fun getVideoList(url: String, name: String): List<Video> {
val prefix = "$name - "
return when {
url.contains("ok.ru") -> {
OkruExtractor(client).videosFromUrl(url, prefix = prefix)
}

url.contains("dailymotion") -> {
DailymotionExtractor(client, headers).videosFromUrl(url, prefix)
}
url.contains("https://dood") -> {
DoodExtractor(client).videosFromUrl(url, quality = name)
}
url.contains("ok.ru") -> okruExtractor.videosFromUrl(url, prefix)
url.contains("dailymotion") -> dailymotionExtractor.videosFromUrl(url, prefix)
url.contains("https://dood") -> doodExtractor.videosFromUrl(url, name)
url.contains("gdriveplayer") -> {
val gdriveHeaders = headersBuilder()
.add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8")
.add("Host", "gdriveplayer.to")
.add("Referer", "$baseUrl/")
.build()
GdrivePlayerExtractor(client).videosFromUrl(url, name = name, headers = gdriveHeaders)
}
url.contains("youtube.com") -> {
YouTubeExtractor(client).videosFromUrl(url, prefix = prefix)
}
url.contains("vidstreaming") -> {
VidstreamingExtractor(client).videosFromUrl(url, prefix = prefix)
gdrivePlayerExtractor.videosFromUrl(url, name, gdriveHeaders)
}
url.contains("youtube.com") -> youTubeExtractor.videosFromUrl(url, prefix)
url.contains("vidstreaming") -> vidstreamingExtractor.videosFromUrl(url, prefix)
else -> emptyList()
}
}

// ============================== Settings ==============================
override fun setupPreferenceScreen(screen: PreferenceScreen) {
super.setupPreferenceScreen(screen) // Quality preferences
val videoLangPref = ListPreference(screen.context).apply {

ListPreference(screen.context).apply {
key = PREF_LANG_KEY
title = PREF_LANG_TITLE
entries = PREF_LANG_VALUES
Expand All @@ -67,9 +63,7 @@ class AnimeXin : AnimeStream(
val entry = entryValues[index] as String
preferences.edit().putString(key, entry).commit()
}
}

screen.addPreference(videoLangPref)
}.also(screen::addPreference)
}

// ============================= Utilities ==============================
Expand Down

This file was deleted.

Loading

0 comments on commit 9c8799b

Please sign in to comment.