add german extension: Anifreakz (#931)
2
src/de/anifreakz/AndroidManifest.xml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest package="eu.kanade.tachiyomi.animeextension" />
|
13
src/de/anifreakz/build.gradle
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
apply plugin: 'com.android.application'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
apply plugin: 'kotlinx-serialization'
|
||||||
|
|
||||||
|
ext {
|
||||||
|
extName = 'Anifreakz'
|
||||||
|
pkgNameSuffix = 'de.anifreakz'
|
||||||
|
extClass = '.Anifreakz'
|
||||||
|
extVersionCode = 1
|
||||||
|
libVersion = '13'
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: "$rootDir/common.gradle"
|
BIN
src/de/anifreakz/res/mipmap-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
src/de/anifreakz/res/mipmap-hdpi/ic_launcher_adaptive_back.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
src/de/anifreakz/res/mipmap-hdpi/ic_launcher_adaptive_fore.png
Normal file
After Width: | Height: | Size: 4.4 KiB |
BIN
src/de/anifreakz/res/mipmap-mdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 1.8 KiB |
BIN
src/de/anifreakz/res/mipmap-mdpi/ic_launcher_adaptive_back.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
BIN
src/de/anifreakz/res/mipmap-mdpi/ic_launcher_adaptive_fore.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
src/de/anifreakz/res/mipmap-xhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
src/de/anifreakz/res/mipmap-xhdpi/ic_launcher_adaptive_back.png
Normal file
After Width: | Height: | Size: 5.6 KiB |
BIN
src/de/anifreakz/res/mipmap-xhdpi/ic_launcher_adaptive_fore.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
src/de/anifreakz/res/mipmap-xxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
src/de/anifreakz/res/mipmap-xxhdpi/ic_launcher_adaptive_back.png
Normal file
After Width: | Height: | Size: 8.9 KiB |
BIN
src/de/anifreakz/res/mipmap-xxhdpi/ic_launcher_adaptive_fore.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
src/de/anifreakz/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 22 KiB |
@ -0,0 +1,264 @@
|
|||||||
|
package eu.kanade.tachiyomi.animeextension.de.anifreakz
|
||||||
|
|
||||||
|
import android.app.Application
|
||||||
|
import android.content.SharedPreferences
|
||||||
|
import androidx.preference.ListPreference
|
||||||
|
import androidx.preference.PreferenceScreen
|
||||||
|
import eu.kanade.tachiyomi.animeextension.de.anifreakz.extractors.AnimefreakzExtractor
|
||||||
|
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
||||||
|
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||||
|
import eu.kanade.tachiyomi.animesource.model.SAnime
|
||||||
|
import eu.kanade.tachiyomi.animesource.model.SEpisode
|
||||||
|
import eu.kanade.tachiyomi.animesource.model.Video
|
||||||
|
import eu.kanade.tachiyomi.animesource.online.ParsedAnimeHttpSource
|
||||||
|
import eu.kanade.tachiyomi.network.GET
|
||||||
|
import eu.kanade.tachiyomi.network.POST
|
||||||
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
|
import okhttp3.Headers
|
||||||
|
import okhttp3.MediaType.Companion.toMediaType
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
import okhttp3.Request
|
||||||
|
import okhttp3.RequestBody.Companion.toRequestBody
|
||||||
|
import okhttp3.Response
|
||||||
|
import org.jsoup.nodes.Document
|
||||||
|
import org.jsoup.nodes.Element
|
||||||
|
import uy.kohesive.injekt.Injekt
|
||||||
|
import uy.kohesive.injekt.api.get
|
||||||
|
import kotlin.Exception
|
||||||
|
|
||||||
|
class Anifreakz : ConfigurableAnimeSource, ParsedAnimeHttpSource() {
|
||||||
|
|
||||||
|
override val name = "Anifreakz"
|
||||||
|
|
||||||
|
override val baseUrl = "https://anifreakz.com"
|
||||||
|
|
||||||
|
override val lang = "de"
|
||||||
|
|
||||||
|
override val supportsLatest = false
|
||||||
|
|
||||||
|
override val client: OkHttpClient = network.cloudflareClient
|
||||||
|
|
||||||
|
private val preferences: SharedPreferences by lazy {
|
||||||
|
Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun popularAnimeSelector(): String = "div.row.row-cols-md-5 div.col div.list-movie"
|
||||||
|
|
||||||
|
override fun popularAnimeRequest(page: Int): Request = GET("$baseUrl/series?filter={\"sorting\":\"popular\"}&page=$page")
|
||||||
|
|
||||||
|
override fun popularAnimeFromElement(element: Element): SAnime {
|
||||||
|
val anime = SAnime.create()
|
||||||
|
anime.setUrlWithoutDomain(element.select("a.list-media").attr("href"))
|
||||||
|
anime.thumbnail_url = element.select("a.list-media div.media.media-cover").attr("data-src")
|
||||||
|
anime.title = element.select("div.list-caption a.list-title").text()
|
||||||
|
return anime
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun popularAnimeNextPageSelector(): String = "li.page-item:last-child a"
|
||||||
|
|
||||||
|
// episodes
|
||||||
|
|
||||||
|
override fun episodeListRequest(anime: SAnime): Request {
|
||||||
|
return GET("$baseUrl${anime.url}", headers = Headers.headersOf("if-modified-since", ""))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun episodeListSelector() = throw Exception("not used")
|
||||||
|
|
||||||
|
override fun episodeListParse(response: Response): List<SEpisode> {
|
||||||
|
val document = response.asJsoup()
|
||||||
|
val url = document.select("meta[property=\"og:url\"]").attr("content")
|
||||||
|
val episodeList = mutableListOf<SEpisode>()
|
||||||
|
if (url.contains("/serie/")) {
|
||||||
|
val seasonElements = document.select("div.episodes.tab-content div.tab-pane")
|
||||||
|
seasonElements.forEach {
|
||||||
|
val episode = parseEpisodesFromSeries(it)
|
||||||
|
episodeList.addAll(episode)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val episode = SEpisode.create()
|
||||||
|
episode.name = document.select("div.caption-content h1").text()
|
||||||
|
episode.episode_number = 1F
|
||||||
|
episode.setUrlWithoutDomain(document.select("link[rel=canonical]").attr("href"))
|
||||||
|
episodeList.add(episode)
|
||||||
|
}
|
||||||
|
return episodeList.reversed()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun parseEpisodesFromSeries(element: Element): List<SEpisode> {
|
||||||
|
val season = element.attr("id")
|
||||||
|
.substringAfter("season-")
|
||||||
|
val episodeElements = element.select("a")
|
||||||
|
return episodeElements.map { episodeFromElement(it, season) }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun episodeFromElement(element: Element): SEpisode = throw Exception("not Used")
|
||||||
|
|
||||||
|
private fun episodeFromElement(element: Element, season: String): SEpisode {
|
||||||
|
val episode = SEpisode.create()
|
||||||
|
episode.setUrlWithoutDomain(element.attr("href"))
|
||||||
|
episode.episode_number = element.select("div.episode").text()
|
||||||
|
.substringBefore(".Episode").toFloat()
|
||||||
|
val folge = element.select("div.episode").text()
|
||||||
|
.substringBefore(".Episode")
|
||||||
|
episode.name = "Staffel $season Folge $folge : " + element.select("div.name").text()
|
||||||
|
return episode
|
||||||
|
}
|
||||||
|
|
||||||
|
// Video Extractor
|
||||||
|
|
||||||
|
override fun videoListParse(response: Response): List<Video> {
|
||||||
|
val document = response.asJsoup()
|
||||||
|
return videosFromElement(document)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun videosFromElement(document: Document): List<Video> {
|
||||||
|
val videoList = mutableListOf<Video>()
|
||||||
|
if (!document.select("div.dropdown-menu[aria-labelledby=\"videoSource\"] button").isNullOrEmpty()) {
|
||||||
|
val langs = document.select("div.dropdown-menu[aria-labelledby=\"videoSource\"] button")
|
||||||
|
langs.forEach {
|
||||||
|
val id = it.attr("data-embed")
|
||||||
|
val hoster = it.select("span.language").text()
|
||||||
|
val hostdoc = client.newCall(POST("$baseUrl/ajax/embed", body = "id=$id&captcha=".toRequestBody("application/x-www-form-urlencoded".toMediaType()))).execute().asJsoup()
|
||||||
|
if (it.select("span.name").text().contains("GerSub")) {
|
||||||
|
val quality = "$hoster SUB"
|
||||||
|
val url = hostdoc.select("iframe").attr("src")
|
||||||
|
val video = AnimefreakzExtractor(client).videoFromUrl(url, quality)
|
||||||
|
if (video != null) {
|
||||||
|
videoList.addAll(video)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val quality = "$hoster DUB"
|
||||||
|
val url = hostdoc.select("iframe").attr("src")
|
||||||
|
val video = AnimefreakzExtractor(client).videoFromUrl(url, quality)
|
||||||
|
if (video != null) {
|
||||||
|
videoList.addAll(video)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val id = document.select("div.nav-player-select a.dropdown-toggle").attr("data-embed")
|
||||||
|
val hostdoc = client.newCall(POST("$baseUrl/ajax/embed", body = "id=$id&captcha=".toRequestBody("application/x-www-form-urlencoded".toMediaType()))).execute().asJsoup()
|
||||||
|
val hoster = hostdoc.select("iframe").attr("src")
|
||||||
|
.substringAfter("https://").substringBefore(".")
|
||||||
|
if (document.select("div.nav-player-select a.dropdown-toggle span").text().contains("GerSub")) {
|
||||||
|
val quality = "$hoster SUB"
|
||||||
|
val url = hostdoc.select("iframe").attr("src")
|
||||||
|
val video = AnimefreakzExtractor(client).videoFromUrl(url, quality)
|
||||||
|
if (video != null) {
|
||||||
|
videoList.addAll(video)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val quality = "$hoster DUB"
|
||||||
|
val url = hostdoc.select("iframe").attr("src")
|
||||||
|
val video = AnimefreakzExtractor(client).videoFromUrl(url, quality)
|
||||||
|
if (video != null) {
|
||||||
|
videoList.addAll(video)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return videoList.reversed()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun List<Video>.sort(): List<Video> {
|
||||||
|
val subPreference = preferences.getString("preferred_sub", null)
|
||||||
|
if (subPreference != null) {
|
||||||
|
val newList = mutableListOf<Video>()
|
||||||
|
var preferred = 0
|
||||||
|
for (video in this) {
|
||||||
|
if (video.quality.contains(subPreference)) {
|
||||||
|
newList.add(preferred, video)
|
||||||
|
preferred++
|
||||||
|
} else {
|
||||||
|
newList.add(video)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newList
|
||||||
|
}
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun videoListSelector() = throw Exception("not used")
|
||||||
|
|
||||||
|
override fun videoFromElement(element: Element) = throw Exception("not used")
|
||||||
|
|
||||||
|
override fun videoUrlParse(document: Document) = throw Exception("not used")
|
||||||
|
|
||||||
|
// Search
|
||||||
|
|
||||||
|
override fun searchAnimeFromElement(element: Element): SAnime {
|
||||||
|
val anime = SAnime.create()
|
||||||
|
anime.setUrlWithoutDomain(element.select("a.list-media").attr("href"))
|
||||||
|
anime.thumbnail_url = element.select("a.list-media div.media.media-cover").attr("data-src")
|
||||||
|
// .substringAfter("url(\"").substringBefore("\");")
|
||||||
|
anime.title = element.select("div.list-caption a.list-title").text()
|
||||||
|
return anime
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun searchAnimeNextPageSelector(): String? = null
|
||||||
|
|
||||||
|
override fun searchAnimeSelector(): String = "div.row.row-cols-5 div.col div.list-movie"
|
||||||
|
|
||||||
|
override fun searchAnimeRequest(page: Int, query: String, filters: AnimeFilterList): Request = GET("$baseUrl/search/$query")
|
||||||
|
|
||||||
|
// Details
|
||||||
|
|
||||||
|
override fun animeDetailsParse(document: Document): SAnime {
|
||||||
|
val anime = SAnime.create()
|
||||||
|
val url = document.select("meta[property=\"og:url\"]").attr("content")
|
||||||
|
if (url.contains("/serie/")) {
|
||||||
|
anime.thumbnail_url = document.select("div.media.media-cover").attr("data-src")
|
||||||
|
anime.title = document.select("div.col-md-9 div.pl-md-4 h1").text()
|
||||||
|
anime.genre = document.select("div.col-md-9 div.pl-md-4 div.categories a").joinToString(", ") { it.text() }
|
||||||
|
anime.description = document.select("div.text div.text-content").text()
|
||||||
|
anime.author = document.select("div.featured-attr div.text a").joinToString(", ") { it.text() }
|
||||||
|
anime.status = parseStatus(document.select("span.stato").text())
|
||||||
|
return anime
|
||||||
|
} else {
|
||||||
|
anime.thumbnail_url = document.select("div.media.media-cover").attr("data-src")
|
||||||
|
anime.title = document.select("div.caption-content h1").text()
|
||||||
|
anime.genre = document.select("div.col-md-9 div.pl-md-4 div.categories a").joinToString(", ") { it.text() }
|
||||||
|
anime.description = document.select("script[type=\"application/ld+json\"]").toString()
|
||||||
|
.substringAfter("\"reviewBody\": \"").substringBefore("\"")
|
||||||
|
anime.author = document.select("div.text[data-more] a").joinToString(", ") { it.text() }
|
||||||
|
anime.status = parseStatus(document.select("span.stato").text())
|
||||||
|
return anime
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun parseStatus(status: String?) = when {
|
||||||
|
status == null -> SAnime.UNKNOWN
|
||||||
|
status.contains("Returning Series", ignoreCase = true) -> SAnime.ONGOING
|
||||||
|
else -> SAnime.COMPLETED
|
||||||
|
}
|
||||||
|
|
||||||
|
// Latest
|
||||||
|
|
||||||
|
override fun latestUpdatesNextPageSelector(): String = throw Exception("Not used")
|
||||||
|
|
||||||
|
override fun latestUpdatesFromElement(element: Element): SAnime = throw Exception("Not used")
|
||||||
|
|
||||||
|
override fun latestUpdatesRequest(page: Int): Request = throw Exception("Not used")
|
||||||
|
|
||||||
|
override fun latestUpdatesSelector(): String = throw Exception("Not used")
|
||||||
|
|
||||||
|
// Preferences
|
||||||
|
|
||||||
|
override fun setupPreferenceScreen(screen: PreferenceScreen) {
|
||||||
|
val subPref = ListPreference(screen.context).apply {
|
||||||
|
key = "preferred_sub"
|
||||||
|
title = "Standardmäßig Sub oder Dub?"
|
||||||
|
entries = arrayOf("Sub", "Dub")
|
||||||
|
entryValues = arrayOf("SUB", "DUB")
|
||||||
|
setDefaultValue("SUB")
|
||||||
|
summary = "%s"
|
||||||
|
|
||||||
|
setOnPreferenceChangeListener { _, newValue ->
|
||||||
|
val selected = newValue as String
|
||||||
|
val index = findIndexOfValue(selected)
|
||||||
|
val entry = entryValues[index] as String
|
||||||
|
preferences.edit().putString(key, entry).commit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
screen.addPreference(subPref)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package eu.kanade.tachiyomi.animeextension.de.anifreakz.extractors
|
||||||
|
|
||||||
|
import eu.kanade.tachiyomi.animesource.model.Video
|
||||||
|
import eu.kanade.tachiyomi.network.GET
|
||||||
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
|
import okhttp3.OkHttpClient
|
||||||
|
|
||||||
|
class AnimefreakzExtractor(private val client: OkHttpClient) {
|
||||||
|
|
||||||
|
fun videoFromUrl(url: String, prequality: String): MutableList<Video>? {
|
||||||
|
try {
|
||||||
|
|
||||||
|
val jsE = client.newCall(GET(url)).execute().asJsoup().selectFirst("script:containsData(eval)").data()
|
||||||
|
val masterUrl = JsUnpacker(jsE).unpack().toString()
|
||||||
|
.substringAfter("{file:\"").substringBefore("\"}")
|
||||||
|
val masterPlaylist = client.newCall(GET(masterUrl)).execute().body!!.string()
|
||||||
|
val videoList = mutableListOf<Video>()
|
||||||
|
masterPlaylist.substringAfter("#EXT-X-STREAM-INF:").split("#EXT-X-STREAM-INF:")
|
||||||
|
.forEach {
|
||||||
|
val quality = "$prequality : " + it.substringAfter("RESOLUTION=").substringAfter("x").substringBefore(",") + "p "
|
||||||
|
val videoUrl = it.substringAfter("\n").substringBefore("\n")
|
||||||
|
videoList.add(Video(videoUrl, quality, videoUrl))
|
||||||
|
}
|
||||||
|
return videoList
|
||||||
|
} catch (e: Exception) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,214 @@
|
|||||||
|
package eu.kanade.tachiyomi.animeextension.de.anifreakz.extractors
|
||||||
|
|
||||||
|
import java.util.regex.Pattern
|
||||||
|
import kotlin.math.pow
|
||||||
|
|
||||||
|
// https://github.com/cylonu87/JsUnpacker
|
||||||
|
class JsUnpacker(packedJS: String?) {
|
||||||
|
private var packedJS: String? = null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Detects whether the javascript is P.A.C.K.E.R. coded.
|
||||||
|
*
|
||||||
|
* @return true if it's P.A.C.K.E.R. coded.
|
||||||
|
*/
|
||||||
|
fun detect(): Boolean {
|
||||||
|
val js = packedJS!!.replace(" ", "")
|
||||||
|
val p = Pattern.compile("eval\\(function\\(p,a,c,k,e,[rd]")
|
||||||
|
val m = p.matcher(js)
|
||||||
|
return m.find()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unpack the javascript
|
||||||
|
*
|
||||||
|
* @return the javascript unpacked or null.
|
||||||
|
*/
|
||||||
|
fun unpack(): String? {
|
||||||
|
val js = packedJS
|
||||||
|
try {
|
||||||
|
var p =
|
||||||
|
Pattern.compile("""\}\s*\('(.*)',\s*(.*?),\s*(\d+),\s*'(.*?)'\.split\('\|'\)""", Pattern.DOTALL)
|
||||||
|
var m = p.matcher(js)
|
||||||
|
if (m.find() && m.groupCount() == 4) {
|
||||||
|
val payload = m.group(1).replace("\\'", "'")
|
||||||
|
val radixStr = m.group(2)
|
||||||
|
val countStr = m.group(3)
|
||||||
|
val symtab = m.group(4).split("\\|".toRegex()).toTypedArray()
|
||||||
|
var radix = 36
|
||||||
|
var count = 0
|
||||||
|
try {
|
||||||
|
radix = radixStr.toInt()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
count = countStr.toInt()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
}
|
||||||
|
if (symtab.size != count) {
|
||||||
|
throw Exception("Unknown p.a.c.k.e.r. encoding")
|
||||||
|
}
|
||||||
|
val unbase = Unbase(radix)
|
||||||
|
p = Pattern.compile("\\b\\w+\\b")
|
||||||
|
m = p.matcher(payload)
|
||||||
|
val decoded = StringBuilder(payload)
|
||||||
|
var replaceOffset = 0
|
||||||
|
while (m.find()) {
|
||||||
|
val word = m.group(0)
|
||||||
|
val x = unbase.unbase(word)
|
||||||
|
var value: String? = null
|
||||||
|
if (x < symtab.size && x >= 0) {
|
||||||
|
value = symtab[x]
|
||||||
|
}
|
||||||
|
if (value != null && value.isNotEmpty()) {
|
||||||
|
decoded.replace(m.start() + replaceOffset, m.end() + replaceOffset, value)
|
||||||
|
replaceOffset += value.length - word.length
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return decoded.toString()
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
private inner class Unbase(private val radix: Int) {
|
||||||
|
private val ALPHABET_62 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
|
private val ALPHABET_95 =
|
||||||
|
" !\"#$%&\\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
|
||||||
|
private var alphabet: String? = null
|
||||||
|
private var dictionary: HashMap<String, Int>? = null
|
||||||
|
fun unbase(str: String): Int {
|
||||||
|
var ret = 0
|
||||||
|
if (alphabet == null) {
|
||||||
|
ret = str.toInt(radix)
|
||||||
|
} else {
|
||||||
|
val tmp = StringBuilder(str).reverse().toString()
|
||||||
|
for (i in tmp.indices) {
|
||||||
|
ret += (radix.toDouble().pow(i.toDouble()) * dictionary!![tmp.substring(i, i + 1)]!!).toInt()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (radix > 36) {
|
||||||
|
when {
|
||||||
|
radix < 62 -> {
|
||||||
|
alphabet = ALPHABET_62.substring(0, radix)
|
||||||
|
}
|
||||||
|
radix in 63..94 -> {
|
||||||
|
alphabet = ALPHABET_95.substring(0, radix)
|
||||||
|
}
|
||||||
|
radix == 62 -> {
|
||||||
|
alphabet = ALPHABET_62
|
||||||
|
}
|
||||||
|
radix == 95 -> {
|
||||||
|
alphabet = ALPHABET_95
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dictionary = HashMap(95)
|
||||||
|
for (i in 0 until alphabet!!.length) {
|
||||||
|
dictionary!![alphabet!!.substring(i, i + 1)] = i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param packedJS javascript P.A.C.K.E.R. coded.
|
||||||
|
*/
|
||||||
|
init {
|
||||||
|
this.packedJS = packedJS
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val c =
|
||||||
|
listOf(
|
||||||
|
0x63,
|
||||||
|
0x6f,
|
||||||
|
0x6d,
|
||||||
|
0x2e,
|
||||||
|
0x67,
|
||||||
|
0x6f,
|
||||||
|
0x6f,
|
||||||
|
0x67,
|
||||||
|
0x6c,
|
||||||
|
0x65,
|
||||||
|
0x2e,
|
||||||
|
0x61,
|
||||||
|
0x6e,
|
||||||
|
0x64,
|
||||||
|
0x72,
|
||||||
|
0x6f,
|
||||||
|
0x69,
|
||||||
|
0x64,
|
||||||
|
0x2e,
|
||||||
|
0x67,
|
||||||
|
0x6d,
|
||||||
|
0x73,
|
||||||
|
0x2e,
|
||||||
|
0x61,
|
||||||
|
0x64,
|
||||||
|
0x73,
|
||||||
|
0x2e,
|
||||||
|
0x4d,
|
||||||
|
0x6f,
|
||||||
|
0x62,
|
||||||
|
0x69,
|
||||||
|
0x6c,
|
||||||
|
0x65,
|
||||||
|
0x41,
|
||||||
|
0x64,
|
||||||
|
0x73
|
||||||
|
)
|
||||||
|
val z =
|
||||||
|
listOf(
|
||||||
|
0x63,
|
||||||
|
0x6f,
|
||||||
|
0x6d,
|
||||||
|
0x2e,
|
||||||
|
0x66,
|
||||||
|
0x61,
|
||||||
|
0x63,
|
||||||
|
0x65,
|
||||||
|
0x62,
|
||||||
|
0x6f,
|
||||||
|
0x6f,
|
||||||
|
0x6b,
|
||||||
|
0x2e,
|
||||||
|
0x61,
|
||||||
|
0x64,
|
||||||
|
0x73,
|
||||||
|
0x2e,
|
||||||
|
0x41,
|
||||||
|
0x64
|
||||||
|
)
|
||||||
|
|
||||||
|
fun String.load(): String? {
|
||||||
|
return try {
|
||||||
|
var load = this
|
||||||
|
|
||||||
|
for (q in c.indices) {
|
||||||
|
if (c[q % 4] > 270) {
|
||||||
|
load += c[q % 3]
|
||||||
|
} else {
|
||||||
|
load += c[q].toChar()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Class.forName(load.substring(load.length - c.size, load.length)).name
|
||||||
|
} catch (_: Exception) {
|
||||||
|
try {
|
||||||
|
var f = c[2].toChar().toString()
|
||||||
|
for (w in z.indices) {
|
||||||
|
f += z[w].toChar()
|
||||||
|
}
|
||||||
|
return Class.forName(f.substring(0b001, f.length)).name
|
||||||
|
} catch (_: Exception) {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|