Showing preview only (265K chars total). Download the full file or copy to clipboard to get everything.
Repository: easybangumiorg/CommunityExtension
Branch: main
Commit: 4140b6849f42
Files: 93
Total size: 233.4 KB
Directory structure:
gitextract_yt_82lji/
├── .github/
│ └── workflows/
│ └── release.yml
├── .gitignore
├── LICENSE
├── README.md
├── build.gradle.kts
├── extension-app/
│ ├── .gitignore
│ ├── build.gradle.kts
│ ├── proguard-rules.pro
│ └── src/
│ └── main/
│ ├── AndroidManifest.xml
│ ├── java/
│ │ ├── com/
│ │ │ └── heyanle/
│ │ │ └── easybangumi_extension/
│ │ │ ├── anfun/
│ │ │ │ ├── AnfunDetailedComponent.kt
│ │ │ │ ├── AnfunListComponent.kt
│ │ │ │ ├── AnfunPageComponent.kt
│ │ │ │ ├── AnfunSearchComponent.kt
│ │ │ │ └── AnfunSource.kt
│ │ │ ├── anim/
│ │ │ │ ├── AnimOneInfo.kt
│ │ │ │ ├── AnimOneSource.kt
│ │ │ │ ├── AnimPageComponent.kt
│ │ │ │ └── DataSource.kt
│ │ │ └── ggl/
│ │ │ ├── GGLComponent.kt
│ │ │ ├── GGLDetailedComponent.kt
│ │ │ ├── GGLListComponent.kt
│ │ │ ├── GGLPlayComponent.kt
│ │ │ └── GGLSource.kt
│ │ ├── io/
│ │ │ └── github/
│ │ │ ├── easybangumiorg/
│ │ │ │ └── source/
│ │ │ │ └── aio/
│ │ │ │ ├── AIOHtpHelper.kt
│ │ │ │ ├── OkHttp.kt
│ │ │ │ ├── SourceResult.kt
│ │ │ │ ├── String.kt
│ │ │ │ ├── auete/
│ │ │ │ │ ├── AueteDetail.kt
│ │ │ │ │ ├── AuetePage.kt
│ │ │ │ │ ├── AuetePlay.kt
│ │ │ │ │ ├── AueteSearch.kt
│ │ │ │ │ ├── AueteSource.kt
│ │ │ │ │ └── Common.kt
│ │ │ │ ├── changzhang/
│ │ │ │ │ ├── ChangZhangDetailPage.kt
│ │ │ │ │ ├── ChangZhangPage.kt
│ │ │ │ │ ├── ChangZhangPlayPage.kt
│ │ │ │ │ ├── ChangZhangSearchPage.kt
│ │ │ │ │ └── ChangZhangSource.kt
│ │ │ │ ├── fengche/
│ │ │ │ │ ├── Common.kt
│ │ │ │ │ ├── FengCheDetail.kt
│ │ │ │ │ ├── FengCheHostUrlHelper.kt
│ │ │ │ │ ├── FengChePage.kt
│ │ │ │ │ ├── FengChePlay.kt
│ │ │ │ │ ├── FengChePrefer.kt
│ │ │ │ │ ├── FengCheSearch.kt
│ │ │ │ │ └── FengCheSource.kt
│ │ │ │ ├── libvio/
│ │ │ │ │ ├── LibVioDetail.kt
│ │ │ │ │ ├── LibVioPage.kt
│ │ │ │ │ ├── LibVioPlay.kt
│ │ │ │ │ ├── LibVioSearch.kt
│ │ │ │ │ └── LibVioSource.kt
│ │ │ │ └── xigua/
│ │ │ │ ├── Common.kt
│ │ │ │ ├── XiGuaPage.kt
│ │ │ │ ├── XiguaDetail.kt
│ │ │ │ ├── XiguaPlay.kt
│ │ │ │ ├── XiguaSearch.kt
│ │ │ │ └── XiguaSource.kt
│ │ │ └── peacefulprogram/
│ │ │ ├── easybangumi_mikudm/
│ │ │ │ ├── MikudmApiSource.kt
│ │ │ │ ├── MikudmDetailComponent.kt
│ │ │ │ ├── MikudmPageComponent.kt
│ │ │ │ ├── MikudmPlayComponent.kt
│ │ │ │ ├── MikudmPreferenceComponent.kt
│ │ │ │ ├── MikudmSearchComponent.kt
│ │ │ │ └── MikudmUtil.kt
│ │ │ ├── easybangumi_mxdm/
│ │ │ │ ├── MxdmApiSource.kt
│ │ │ │ ├── MxdmDetailComponent.kt
│ │ │ │ ├── MxdmPageComponent.kt
│ │ │ │ ├── MxdmPlayComponent.kt
│ │ │ │ ├── MxdmPreferenceComponent.kt
│ │ │ │ ├── MxdmSearchComponent.kt
│ │ │ │ └── MxdmUtil.kt
│ │ │ └── easybangumi_nivod/
│ │ │ ├── NivodApiSource.kt
│ │ │ ├── NivodConstants.kt
│ │ │ ├── NivodDetailComponent.kt
│ │ │ ├── NivodPageComponent.kt
│ │ │ ├── NivodPlayComponent.kt
│ │ │ ├── NivodSearchComponent.kt
│ │ │ ├── Util.kt
│ │ │ └── dto/
│ │ │ ├── ChannelRecommendResponse.kt
│ │ │ ├── Common.kt
│ │ │ ├── SearchVideoResponse.kt
│ │ │ ├── VideoDetailResponse.kt
│ │ │ └── VideoStreamUrlResponse.kt
│ │ └── org/
│ │ └── easybangumi/
│ │ └── extension/
│ │ └── EasySourceFactory.kt
│ └── res/
│ ├── values/
│ │ └── strings.xml
│ └── xml/
│ ├── backup_rules.xml
│ └── data_extraction_rules.xml
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
└── settings.gradle.kts
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/workflows/release.yml
================================================
name: release
on:
push:
tags:
- '**'
workflow_dispatch:
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3.5.2
- name: Setup Java JDK
uses: actions/setup-java@v1.4.4
with:
java-version: 17
- name: Build
run: |
chmod +x ./gradlew
./gradlew :extension-app:assemble
- name: Setup build tool version variable
shell: bash
run: |
BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1)
echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV
echo Last build tool version is: $BUILD_TOOL_VERSION
- name: sign-apk
uses: r0adkll/sign-android-release@v1
with:
releaseDirectory: extension-app/build/outputs/apk/release
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: ${{ secrets.KEY_ALIAS }}
keyStorePassword: ${{ secrets.KEY_STORE_PWD }}
keyPassword: ${{ secrets.KEY_PWD }}
env:
# override default build-tools version (29.0.3) -- optional
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }}
- name: rename-apk
run: |
mv extension-app/build/outputs/apk/release/extension-app-release-unsigned-signed.apk extension-app-${{ github.ref_name }}.apk
- name: Release
run: |
gh release create -d ${{ github.ref_name }} extension-app-${{ github.ref_name }}.apk
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
================================================
FILE: .gitignore
================================================
*.iml
.gradle
.idea
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
/publishing
.externalNativeBuild
.cxx
local.properties
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================

<p align="center">
<img alt="release" src="https://img.shields.io/github/v/release/easybangumiorg/CommunityExtension" />
<img alt="license" src="https://img.shields.io/github/license/easybangumiorg/CommunityExtension" />
</p>
本仓库内容均来自互联网投稿,为了代码安全性只收录提交到纯纯看番官方的代码,并由官方编译。
如果使用其他的源,用户需要自己甄别插件安全性,纯纯看番官方无法保证这些插件是否安全。
如果本仓库内容您认为侵犯了你的权益,请提交issue联系我们删除。
纯纯看番本体:[https://github.com/easybangumiorg/EasyBangumi](https://github.com/easybangumiorg/EasyBangumi)
================================================
FILE: build.gradle.kts
================================================
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.1.2" apply false
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
}
tasks.create<Delete>("clean") {
delete {
rootProject.buildDir
}
}
subprojects {
// 定义检查依赖变化的时间间隔,!!配置为0实时刷新
configurations.all {
// check for updates every build
resolutionStrategy.cacheChangingModulesFor(0, java.util.concurrent.TimeUnit.SECONDS)
}
}
================================================
FILE: extension-app/.gitignore
================================================
/build
================================================
FILE: extension-app/build.gradle.kts
================================================
plugins {
id ("com.android.application")
id ("org.jetbrains.kotlin.android")
}
// 包名
val packageName = "org.easybangumi.extension"
// 库版本,目前 5.0.3 支持的库版本为 3 到 5
val extensionLibVersion = 7
android {
namespace = packageName
compileSdk = 34
defaultConfig {
applicationId = packageName
minSdk = 21
targetSdk = 34
versionCode = 7
versionName = "1.6"
manifestPlaceholders.put("extensionLibVersion", extensionLibVersion)
}
buildTypes {
release {
isMinifyEnabled = false
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
dependenciesInfo{
includeInApk = false
includeInBundle = false
}
}
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
compileOnly("io.github.easybangumiorg:extension-api:1.${extensionLibVersion}-SNAPSHOT")
}
================================================
FILE: extension-app/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-keep class com.heyanle.**{*;}
-keep interface com.heyanle.**{*;}
# 协程
-keep class kotlin.** { *; }
-keep class kotlin.Metadata { *; }
-dontwarn kotlin.**
-keepclassmembers class **$WhenMappings {
<fields>;
}
-keepclassmembers class kotlin.Metadata {
public <methods>;
}
-assumenosideeffects class kotlin.jvm.internal.Intrinsics {
static void checkParameterIsNotNull(java.lang.Object, java.lang.String);
}
-keep class kotlinx.coroutines.android.** {*;}
# ServiceLoader support
-keepnames class kotlinx.coroutines.internal.MainDispatcherFactory {}
-keepnames class kotlinx.coroutines.CoroutineExceptionHandler {}
-keepnames class kotlinx.coroutines.android.AndroidExceptionPreHandler {}
-keepnames class kotlinx.coroutines.android.AndroidDispatcherFactory {}
# Most of volatile fields are updated with AFU and should not be mangled
-keepclassmembernames class kotlinx.** {
volatile <fields>;
}
================================================
FILE: extension-app/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-feature android:name="easybangumi.extension" android:required="true" />
<application
android:allowBackup="true"
android:icon="@mipmap/app_logo"
android:label="纯纯看番社区插件"
android:supportsRtl="true">
<!--libVersion-->
<meta-data
android:name="easybangumi.extension.lib.version"
android:value="${extensionLibVersion}" />
<!--source-->
<meta-data
android:name="easybangumi.extension.source"
android:value="org.easybangumi.extension.EasySourceFactory"/>
<!--为了让本体能找到需要加-->
<activity android:name="com.heyanle.extension_api.NoneActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.ANSWER" />
<data android:host="com.heyanle.easybangumi"
android:scheme="source"/>
</intent-filter>
</activity>
</application>
<queries>
<package android:name="com.heyanle.easybangumi" />
</queries>
</manifest>
================================================
FILE: extension-app/src/main/java/com/heyanle/easybangumi_extension/anfun/AnfunDetailedComponent.kt
================================================
package com.heyanle.easybangumi_extension.anfun
import android.util.Log
import com.heyanle.easybangumi4.source_api.ParserException
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.detailed.DetailedComponent
import com.heyanle.easybangumi4.source_api.component.play.PlayComponent
import com.heyanle.easybangumi4.source_api.component.update.UpdateComponent
import com.heyanle.easybangumi4.source_api.entity.Cartoon
import com.heyanle.easybangumi4.source_api.entity.CartoonImpl
import com.heyanle.easybangumi4.source_api.entity.CartoonSummary
import com.heyanle.easybangumi4.source_api.entity.Episode
import com.heyanle.easybangumi4.source_api.entity.PlayLine
import com.heyanle.easybangumi4.source_api.entity.PlayerInfo
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.utils.api.WebViewHelper
import com.heyanle.easybangumi4.source_api.utils.core.SourceUtils
import com.heyanle.easybangumi4.source_api.utils.core.network.GET
import com.heyanle.easybangumi4.source_api.withResult
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withTimeoutOrNull
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
/**
* Created by heyanle on 2024/1/29.
* https://github.com/heyanLE
*/
class AnfunDetailedComponent(
private val okhttpHelper: OkhttpHelper,
private val webViewHelper: WebViewHelper
): ComponentWrapper(), DetailedComponent, UpdateComponent, PlayComponent {
override suspend fun getDetailed(summary: CartoonSummary): SourceResult<Cartoon> {
return withResult(Dispatchers.IO) {
detailed(getDoc(summary), summary)
}
}
override suspend fun getPlayLine(summary: CartoonSummary): SourceResult<List<PlayLine>> {
return withResult(Dispatchers.IO) {
playLine(getDoc(summary), summary)
}
}
override suspend fun getAll(summary: CartoonSummary): SourceResult<Pair<Cartoon, List<PlayLine>>> {
return withResult(Dispatchers.IO) {
detailed(getDoc(summary), summary) to playLine(getDoc(summary), summary)
}
}
override suspend fun update(
cartoon: Cartoon,
oldPlayLine: List<PlayLine>
): SourceResult<Cartoon> {
return withResult(Dispatchers.IO) {
when (val n = getAll(CartoonSummary(cartoon.id, cartoon.source))) {
is SourceResult.Complete -> {
n.data.first.apply {
val newPlayLine = n.data.second
if (oldPlayLine.size != newPlayLine.size) {
isUpdate = true
} else {
isUpdate = false
for (i in oldPlayLine.indices) {
if (oldPlayLine[i].episode.size != newPlayLine[i].episode.size) {
isUpdate = true
break
}
}
}
}
}
is SourceResult.Error -> {
throw n.throwable
}
}
}
}
private fun getDoc(summary: CartoonSummary): Document {
val d = okhttpHelper.cloudflareWebViewClient.newCall(GET(SourceUtils.urlParser(AnfunSource.ROOT_URL, "/anime/${summary.id}.html")))
.execute().body?.string() ?: throw NullPointerException()
return Jsoup.parse(d)
}
private fun playLine(document: Document, summary: CartoonSummary): List<PlayLine> {
Log.e("TAG","------->>>>>>>playLine")
val res = arrayListOf<PlayLine>()
val module = document.select(".hl-play-source").first() ?: return res
val playNameList = module.select(".hl-plays-wrap").first()?.select("a") ?: return res
val playEpisodeList = module.select(".hl-tabs-box")
for (index in 0..playNameList.size) {
val playName = playNameList.getOrNull(index)?.text()
val playEpisode = playEpisodeList.getOrNull(index)
if (playName != null && playEpisode != null) {
val results = playEpisode.select("li").select("a")
val es = arrayListOf<Episode>()
for (i in results.indices) {
es.add(Episode((i+1).toString(), results[i].text(), i)) // title
}
val playLine = PlayLine(
id = (index + 1).toString(),
label = playName,
episode = es
)
res.add(playLine)
}
}
return res
}
override suspend fun getPlayInfo(
summary: CartoonSummary,
playLine: PlayLine,
episode: Episode
): SourceResult<PlayerInfo> {
Log.e("TAG","------->>>>>>>开始播放")
return withResult(Dispatchers.IO) {
// Log.e("TAG","${playUrlTemp[playLine.id.toInt()]}") // [/play/632-1-1.html]
val url = SourceUtils.urlParser(AnfunSource.ROOT_URL, "/play/${summary.id}-${playLine.id}-${episode.id}")
// Log.e("TAG", url) // https://www.anfuns.cc/play/632-1-1.html
var videoUrl = webViewHelper.interceptResource(
url, regex = "https://www.anfuns.cc/vapi/AIRA/mui.php?.*"
)
Log.e("TAG", "地址:$videoUrl")
if (videoUrl.isNotEmpty()) {
when {
videoUrl.contains(".m3u8&") -> videoUrl = videoUrl.substringAfter("url=")
.substringBefore("&")
videoUrl.contains(".mp4") -> videoUrl = videoUrl.substringAfter("url=")
.substringBefore("&next=")
}
Log.e("TAG", "解析后url:$videoUrl")
if (videoUrl.indexOf(".mp4") != -1){
PlayerInfo(
decodeType = PlayerInfo.DECODE_TYPE_OTHER,
uri = SourceUtils.urlParser(AnfunSource.ROOT_URL,videoUrl)
)
}else{
PlayerInfo(
decodeType = PlayerInfo.DECODE_TYPE_HLS,
uri = SourceUtils.urlParser(AnfunSource.ROOT_URL,videoUrl)
)
}
}else{
throw ParserException("Unknown")
}
}
}
private fun detailed(document: Document, summary: CartoonSummary): Cartoon {
Log.e("TAG","------->>>>>>>detailed")
var desc = ""
var update = 0
var status = 0
val cover = document.select(".hl-dc-pic").select("span").attr("data-original")
val title = document.select(".hl-dc-headwrap").select(".hl-dc-title").text()
//document.select(".hl-dc-headwrap").select(".hl-dc-sub").text()
// 更新状况
val upStateItems = document.select(".hl-dc-content")
.select(".hl-vod-data").select(".hl-full-box").select("ul").select("li")
for (upStateEm in upStateItems){
val t = upStateEm.text()
when{
t.contains("状态:") -> {
status =
if (t.startsWith("连载")) Cartoon.STATUS_ONGOING
else if (t.startsWith("全")) Cartoon.STATUS_COMPLETED
else Cartoon.STATUS_UNKNOWN
val isTheater = title.contains("剧场版")
update =
if (isTheater) {
if (status == Cartoon.STATUS_COMPLETED) {
Cartoon.UPDATE_STRATEGY_NEVER
} else {
Cartoon.UPDATE_STRATEGY_ONLY_STRICT
}
} else {
if (status == Cartoon.STATUS_COMPLETED) {
Cartoon.UPDATE_STRATEGY_ONLY_STRICT
} else {
Cartoon.UPDATE_STRATEGY_ALWAYS
}
}
}
t.contains("简介:") -> desc = t
}
}
return CartoonImpl(
id = summary.id,
url = SourceUtils.urlParser(AnfunSource.ROOT_URL, "/anime/${summary.id}.html"),
source = summary.source,
title = title,
coverUrl = cover,
intro = "",
description = desc,
genre = "",
status = status,
updateStrategy = update,
)
}
}
================================================
FILE: extension-app/src/main/java/com/heyanle/easybangumi_extension/anfun/AnfunListComponent.kt
================================================
package com.heyanle.easybangumi_extension.anfun
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.utils.core.SourceUtils
import org.jsoup.select.Elements
/**
* Created by heyanle on 2024/1/28.
* https://github.com/heyanLE
*/
class AnfunListComponent(
private val okhttpHelper: OkhttpHelper,
) : ComponentWrapper() {
companion object {
const val ROOT_URL = "https://www.anfuns.cc"
}
suspend fun listPage(
element: Elements,
): Pair<Int?, List<CartoonCover>> {
val r = arrayListOf<CartoonCover>()
for (video in element) {
video.apply {
val name = select("a").attr("title")
val videoUrl = select("a").attr("href")
val coverUrl = select("a").attr("data-original")
val episode = select(".remarks").text()
val id = videoUrl.subSequence(7, videoUrl.length - 5).toString()
if (!name.isNullOrBlank() && !videoUrl.isNullOrBlank() && !coverUrl.isNullOrBlank()) {
val b = CartoonCoverImpl(
id = id,
source = source.key,
url = videoUrl,
title = name,
intro = episode ?: "",
coverUrl = SourceUtils.urlParser(ROOT_URL, coverUrl)
)
r.add(b)
}
}
}
return Pair(null, r)
}
}
================================================
FILE: extension-app/src/main/java/com/heyanle/easybangumi_extension/anfun/AnfunPageComponent.kt
================================================
package com.heyanle.easybangumi_extension.anfun
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.page.PageComponent
import com.heyanle.easybangumi4.source_api.component.page.SourcePage
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.utils.core.SourceUtils
import com.heyanle.easybangumi4.source_api.utils.core.network.GET
import com.heyanle.easybangumi4.source_api.withResult
import kotlinx.coroutines.Dispatchers
import org.jsoup.Jsoup
/**
* Created by heyanle on 2024/1/28.
* https://github.com/heyanLE
*/
class AnfunPageComponent(
private val anfunListComponent: AnfunListComponent,
private val okhttpHelper: OkhttpHelper,
): ComponentWrapper(), PageComponent {
override fun getPages(): List<SourcePage> {
return listOf(
// 首页
SourcePage.Group(
"首页",
false,
) {
withResult(Dispatchers.IO) {
homeListPages()
}
},
// 新番时刻表
SourcePage.Group(
"每日更新列表",
false,
) {
withResult(Dispatchers.IO) {
homeTimelinePages()
}
},
)
}
// 获取主页所有 ListPage
private suspend fun homeListPages(): List<SourcePage.SingleCartoonPage> {
val res = arrayListOf<SourcePage.SingleCartoonPage>()
val doc = Jsoup.parse(
okhttpHelper.cloudflareWebViewClient.newCall(GET(AnfunSource.ROOT_URL))
.execute().body?.string()!!
)
val modules = doc.select("#conch-content").select("div[class='container']")
for (em in modules){
val moduleHeading = em.select(".hl-rb-head").first()
val type = moduleHeading?.select(".hl-rb-title")
val label = type?.text()?:continue
if (label == "每周更新" || label == "网络资讯" || label == "动漫专题") continue
val lis = em.select(".row").select("ul").select("li")
val page = SourcePage.SingleCartoonPage.WithCover(
label = label,
firstKey = { 0 },
) {
withResult(Dispatchers.IO) {
anfunListComponent.listPage(
lis
)
}
}
res.add(page)
}
return res
}
// 获取新番时刻表 ListPage
private suspend fun homeTimelinePages(): List<SourcePage.SingleCartoonPage> {
val res = arrayListOf<SourcePage.SingleCartoonPage>()
val docmuent = Jsoup.parse(
okhttpHelper.cloudflareWebViewClient.newCall(GET(AnfunSource.ROOT_URL))
.execute().body?.string()!!
)
val doc = docmuent.select("#conch-content").select("div[class='container']")[2]
val days = mutableListOf<String>()
doc.select(".hl-rb-head").select("span").select("a").forEach {
// Log.e("星期", it.text())
days.add(it.text())
}
val updateList = doc.select(".row").select(".hl-list-wrap")
for ((index,ems) in updateList.withIndex()){
val r = arrayListOf<CartoonCover>()
val target = ems.select("ul").select("li")
for (em in target) {
val titleEm = em.select("a")
val cover = titleEm.attr("data-original")
val title = titleEm.attr("title")
val episode = titleEm.select(".remarks").text()
val url = titleEm.attr("href")
val id = url.subSequence(7, url.length - 5).toString()
val desc = em.select(".hl-item-sub").text()
if (!title.isNullOrBlank() && !episode.isNullOrBlank() && !url.isNullOrBlank()) {
val car = CartoonCoverImpl(
id = id,
source = source.key,
url = url,
title = title,
intro = episode,
coverUrl = null,
)
r.add(car)
}
}
res.add(
SourcePage.SingleCartoonPage.WithoutCover(
days[index],
firstKey = { 0 },
load = {
withResult {
null to r
}
}
))
if (index == 6) break
}
return res
}
}
================================================
FILE: extension-app/src/main/java/com/heyanle/easybangumi_extension/anfun/AnfunSearchComponent.kt
================================================
package com.heyanle.easybangumi_extension.anfun
import android.util.Log
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.search.SearchComponent
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.utils.core.SourceUtils
import com.heyanle.easybangumi4.source_api.utils.core.network.GET
import com.heyanle.easybangumi4.source_api.withResult
import kotlinx.coroutines.Dispatchers
import org.jsoup.Jsoup
import org.jsoup.select.Elements
/**
* Created by heyanle on 2024/1/29.
* https://github.com/heyanLE
*/
class AnfunSearchComponent(
private val okhttpHelper: OkhttpHelper
) : ComponentWrapper(), SearchComponent {
override fun getFirstSearchKey(keyword: String): Int {
return 0
}
override suspend fun search(
pageKey: Int,
keyword: String
): SourceResult<Pair<Int?, List<CartoonCover>>> {
return withResult(Dispatchers.IO) {
val url = SourceUtils.urlParser(
AnfunSource.ROOT_URL,
"/search/page/${pageKey + 1}/wd/${keyword}.html"
)
Log.e("TAG", "--->${url}")
val d = okhttpHelper.cloudflareWebViewClient.newCall(
GET(
SourceUtils.urlParser(
AnfunSource.ROOT_URL,
url
)
)
).execute().body?.string()!!
val doc = Jsoup.parse(d)
val r = arrayListOf<CartoonCover>()
val lpic = doc.select("#conch-content").select(".row").select("ul")[0]
val results: Elements = lpic.select("li")
if (results.size == 0) {
Log.e("TAG", "已经加载完毕~")
return@withResult Pair(null, r)
}
for (i in results.indices) {
var cover = results[i].select("a").attr("data-original")
if (cover.startsWith("//")) {
cover = "https:${cover}"
}
val title = results[i].select("a").attr("title")
val itemUrl = results[i].select("a").attr("href")
val id = itemUrl.subSequence(7, itemUrl.length - 5).toString()
val episode = results[i].select(".hl-pic-text").select("span").text()
val describe =
results[i].select("p[class='hl-item-sub hl-text-muted hl-lc-2']").text()
val b = CartoonCoverImpl(
id = id,
title = title,
url = itemUrl,
intro = episode,
coverUrl = SourceUtils.urlParser(AnfunSource.ROOT_URL, cover),
source = source.key,
)
r.add(b)
}
val pages = doc.select(".hl-list-wrap").select(".hl-page-wrap").select("li")
return@withResult if (pages.isEmpty()) {
Pair(null, r)
} else {
var hasNext = false
for (p in pages) {
if (p.text() == (pageKey + 2).toString() || p.text() == "下一页") {
hasNext = true
break
}
}
if (!hasNext) {
Pair(null, r)
} else {
Pair(pageKey + 1, r)
}
}
}
}
}
================================================
FILE: extension-app/src/main/java/com/heyanle/easybangumi_extension/anfun/AnfunSource.kt
================================================
package com.heyanle.easybangumi_extension.anfun
import com.heyanle.extension_api.ExtensionIconSource
import com.heyanle.extension_api.ExtensionSource
import org.easybangumi.extension.R
import kotlin.reflect.KClass
/**
* Created by heyanle on 2024/1/28.
* https://github.com/heyanLE
*/
class AnfunSource : ExtensionSource(), ExtensionIconSource {
companion object {
const val ROOT_URL = "https://www.anfuns.cc"
}
override fun getIconResourcesId(): Int? {
return R.drawable.anfun
}
override val sourceKey: String
get() = "heyanle_Anfun"
override val describe: String?
get() = null
override val label: String
get() = "AnFuns动漫"
override val version: String
get() = "1.2"
override val versionCode: Int
get() = 2
override fun register(): List<KClass<*>> {
return listOf(
AnfunDetailedComponent::class,
AnfunListComponent::class,
AnfunPageComponent::class,
AnfunSearchComponent::class
)
}
}
================================================
FILE: extension-app/src/main/java/com/heyanle/easybangumi_extension/anim/AnimOneInfo.kt
================================================
package com.heyanle.easybangumi_extension.anim
import com.heyanle.easybangumi4.source_api.Source
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import com.heyanle.easybangumi4.source_api.entity.CartoonImpl
/**
* Created by HeYanLe on 2023/7/16 16:56.
* https://github.com/heyanLE
*/
data class AnimOneInfo(
val id: Long,
val name: String,
val intro: String,
val year: String,
val season: String,
val translator: String,
){
fun toCartoon(source: Source) = CartoonImpl(
id = id.toString(),
source = source.key,
url = source.describe?:"",
title = name,
genre = "${year}, ${season}, $translator",
intro = intro,
)
fun toCartoonCover(source: Source) = CartoonCoverImpl(
id = id.toString(),
source = source.key,
url = source.describe?:"",
title = name
)
}
================================================
FILE: extension-app/src/main/java/com/heyanle/easybangumi_extension/anim/AnimOneSource.kt
================================================
package com.heyanle.easybangumi_extension.anim
import com.heyanle.easybangumi4.source_api.Source
import com.heyanle.extension_api.ExtensionIconSource
import com.heyanle.extension_api.ExtensionSource
import org.easybangumi.extension.R
import kotlin.reflect.KClass
/**
* Created by HeYanLe on 2023/6/6 18:25.
* https://github.com/heyanLE
*/
class AnimOneSource : Source, ExtensionIconSource {
override fun getIconResourcesId(): Int? {
return R.drawable.anim1
}
override val key: String
get() = "com.heyanle.easybangumi_extension.animone-anim_one"
override val describe: String?
get() = "https://anime1.me/"
override val label: String
get() = "Anim1"
override val version: String
get() = "2.0"
override val versionCode: Int
get() = 2
override fun register(): List<KClass<*>> {
return listOf(
AnimPageComponent::class
)
}
}
================================================
FILE: extension-app/src/main/java/com/heyanle/easybangumi_extension/anim/AnimPageComponent.kt
================================================
package com.heyanle.easybangumi_extension.anim
import android.util.Log
import com.google.gson.JsonParser
import com.heyanle.easybangumi4.source_api.ParserException
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.detailed.DetailedComponent
import com.heyanle.easybangumi4.source_api.component.page.PageComponent
import com.heyanle.easybangumi4.source_api.component.page.SourcePage
import com.heyanle.easybangumi4.source_api.component.play.PlayComponent
import com.heyanle.easybangumi4.source_api.component.search.SearchComponent
import com.heyanle.easybangumi4.source_api.entity.Cartoon
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonImpl
import com.heyanle.easybangumi4.source_api.entity.CartoonSummary
import com.heyanle.easybangumi4.source_api.entity.Episode
import com.heyanle.easybangumi4.source_api.entity.PlayLine
import com.heyanle.easybangumi4.source_api.entity.PlayerInfo
import com.heyanle.easybangumi4.source_api.utils.api.NetworkHelper
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.utils.core.network.GET
import com.heyanle.easybangumi4.source_api.utils.core.network.POST
import com.heyanle.easybangumi4.source_api.withResult
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okhttp3.FormBody
import okhttp3.Headers
import okhttp3.ResponseBody
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import java.lang.NullPointerException
import java.lang.StringBuilder
import java.net.URLDecoder
/**
* Created by HeYanLe on 2023/6/6 18:34.
* https://github.com/heyanLE
*/
class AnimPageComponent(
private val okhttpHelper: OkhttpHelper,
private val networkHelper: NetworkHelper,
) : ComponentWrapper(), PageComponent,
SearchComponent, PlayComponent, DetailedComponent {
override fun getPages(): List<SourcePage> {
return PageComponent.NonLabelSinglePage(
SourcePage.SingleCartoonPage.WithoutCover(
label = "",
firstKey = { 1 },
load = {
withResult {
null to DataSource.getData(true, okhttpHelper).map {
it.toCartoonCover(source)
}
}
}
)
)
}
override fun getFirstSearchKey(keyword: String): Int {
return 1
}
override suspend fun search(
pageKey: Int,
keyword: String
): SourceResult<Pair<Int?, List<CartoonCover>>> {
return withResult {
null to DataSource.getData(false, okhttpHelper).filter {
it.name.contains(keyword) || it.intro.contains(keyword) || it.year.contains(
keyword
) || it.season.contains(keyword) || it.translator.contains(keyword)
}.map {
it.toCartoonCover(source)
}
}
}
override suspend fun getAll(summary: CartoonSummary): SourceResult<Pair<Cartoon, List<PlayLine>>> {
return withResult(Dispatchers.IO) {
Log.e("AnimPage", "https://anime1.me/?cat=${summary.id}")
val resp = okhttpHelper.client.newCall(GET("https://anime1.me/?cat=${summary.id}"))
.execute()
if(!resp.isSuccessful){
throw ParserException("网络错误")
}
val res = resp.body?.string() ?: ""
val doc = Jsoup.parse(res)
getDetailed(doc, summary) to DetailedComponent.NonPlayLine(
getPlayLine(doc, summary)
)
}
}
override suspend fun getDetailed(summary: CartoonSummary): SourceResult<Cartoon> {
return withResult(Dispatchers.IO) {
val resp = okhttpHelper.client.newCall(GET("https://anime1.me/?cat=${summary.id}"))
.execute()
if(!resp.isSuccessful){
throw ParserException("网络错误")
}
val res = resp.body?.string() ?: ""
val doc = Jsoup.parse(res)
getDetailed(doc, summary)
}
}
override suspend fun getPlayLine(summary: CartoonSummary): SourceResult<List<PlayLine>> {
return withResult(Dispatchers.IO) {
val resp = okhttpHelper.client.newCall(GET("https://anime1.me/?cat=${summary.id}"))
.execute()
if(!resp.isSuccessful){
throw ParserException("网络错误")
}
val res = resp.body?.string() ?: ""
val doc = Jsoup.parse(res)
DetailedComponent.NonPlayLine(
getPlayLine(doc, summary)
)
}
}
fun getDetailed(document: Document, summary: CartoonSummary): Cartoon {
return CartoonImpl(
id = summary.id,
source = summary.source,
url = "https://anime1.me/?cat=${summary.id}",
title = document.select("#content header h1.page-title").text(),
)
}
fun getPlayLine(document: Document, summary: CartoonSummary): PlayLine {
val allTit = document.select("#content header h1.page-title").text()
val episodeList = arrayListOf<Episode>()
val dd = document.select("div.content-area main.site-main article")
playUrlTemp.clear()
Log.e("AnimPage", dd.toString())
dd.forEachIndexed { index, it ->
Log.e("AnimPage", it.toString())
var title = it.select(".entry-header h2").first()?.text()
if (title?.startsWith(allTit) == true) {
title = title.substringAfter(allTit)
}
val dataApi = it.select("div.entry-content video").first()?.attr("data-apireq")
if (title != null && dataApi != null) {
val episode = Episode(index.toString(), title, index )
episodeList.add(episode)
playUrlTemp[episode.id] = dataApi
}
}
lastCartoonSummary = summary
return PlayLine(id = "", "", episodeList)
}
private var lastCartoonSummary: CartoonSummary? = null
private val playUrlTemp = hashMapOf<String, String>()
override suspend fun getPlayInfo(
summary: CartoonSummary,
playLine: PlayLine,
episode: Episode,
): SourceResult<PlayerInfo> {
var token = playUrlTemp[episode.id]
if(lastCartoonSummary != summary || playUrlTemp.isEmpty() || token == null){
getPlayLine(summary)
}
token = playUrlTemp[episode.id] ?: return SourceResult.Error(ParserException("token is null"), true)
var cookie = ""
return withResult(Dispatchers.IO) {
var isMp4 = true
val url = if(token.startsWith("%7B%22")){
val builder = FormBody.Builder()
builder.add("d", URLDecoder.decode(token, "utf-8"))
val resp = okhttpHelper.client.newCall(POST(
"https://v.anime1.me/api",
headers = Headers.headersOf("Content-Type", "application/x-www-form-urlencoded", "User-Agent", networkHelper.randomUA),
body = builder.build()
))
.execute()
val cookieBuilder = StringBuilder()
resp.headers("Set-Cookie").map {
val d = it.split(";").first().split("=")
var name = d[0]
var value = d[1]
cookieBuilder.append(name).append("=").append(value).append("; ")
}
if(cookieBuilder.endsWith("; ")){
cookieBuilder.setLength(cookieBuilder.length - 2)
}
cookie = cookieBuilder.toString()
val res = resp.body?.string() ?: ""
val p = JsonParser.parseString(res).asJsonObject
val o = p.get("s").asJsonArray.get(0).asJsonObject
val url = o.get("src").asString
val type = o.get("type").asString
if(type!="video/mp4"){
isMp4 = false
}
if(url.startsWith("//")) "https:${url}" else url
}else{
token
}
Log.e("AnimPage", url + " " + cookie)
PlayerInfo(uri = url, decodeType = if(isMp4)PlayerInfo.DECODE_TYPE_OTHER else PlayerInfo.DECODE_TYPE_HLS).apply{
header = hashMapOf<String, String>("Cookie" to cookie.replace("HttpOnly", ""))
}
}
}
}
================================================
FILE: extension-app/src/main/java/com/heyanle/easybangumi_extension/anim/DataSource.kt
================================================
package com.heyanle.easybangumi_extension.anim
import com.google.gson.JsonParser
import com.heyanle.easybangumi4.source_api.utils.api.NetworkHelper
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.utils.core.network.GET
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.jsoup.Jsoup
/**
* Created by HeYanLe on 2023/7/16 16:56.
* https://github.com/heyanLE
*/
object DataSource {
private var allData: List<AnimOneInfo>? = null
suspend fun getData(
refresh: Boolean,
okhttpHelper: OkhttpHelper,
):List<AnimOneInfo> {
return withContext(Dispatchers.IO){
if(allData == null || refresh){
val rs = arrayListOf<AnimOneInfo>()
runCatching {
val url = "https://d1zquzjgwo9yb.cloudfront.net/?_="
val res = okhttpHelper.client.newCall(GET(url)).execute().body?.string()?:""
val jsonElement = JsonParser.parseString(res).asJsonArray
rs.addAll(jsonElement.map {
val d = it.asJsonArray
AnimOneInfo(
id = d.get(0).asLong,
name = Jsoup.parse(d.get(1).asString).text(),
intro = d.get(2).asString,
year = d.get(3).asString,
season = d.get(4).asString,
translator = d.get(5).asString,
)
})
}.onFailure {
it.printStackTrace()
}
allData = rs
rs
}else{
allData?: emptyList()
}
}
}
}
================================================
FILE: extension-app/src/main/java/com/heyanle/easybangumi_extension/ggl/GGLComponent.kt
================================================
package com.heyanle.easybangumi_extension.ggl
import android.util.Log
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.page.PageComponent
import com.heyanle.easybangumi4.source_api.component.page.SourcePage
import com.heyanle.easybangumi4.source_api.component.search.SearchComponent
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import com.heyanle.easybangumi4.source_api.utils.core.SourceUtils
import com.heyanle.easybangumi4.source_api.withResult
import kotlinx.coroutines.Dispatchers
import java.net.URLEncoder
/**
* Created by heyanle on 2024/1/28.
* https://github.com/heyanLE
*/
class GGLComponent(
private val gglListComponent: GGLListComponent,
) : ComponentWrapper(), PageComponent, SearchComponent {
override fun getPages(): List<SourcePage> {
return listOf(
SourcePage.SingleCartoonPage.WithCover(
label = "日番",
firstKey = { 1 },
) {
withResult(Dispatchers.IO) {
gglListComponent.listHomePage(
"https://anime.girigirilove.com/show/2-----------/",
it
)
}
},
SourcePage.SingleCartoonPage.WithCover(
label = "美番",
firstKey = { 1 },
) {
withResult(Dispatchers.IO) {
gglListComponent.listHomePage(
"https://anime.girigirilove.com/show/3-----------/",
it
)
}
},
SourcePage.SingleCartoonPage.WithCover(
label = "剧场版",
firstKey = { 1 },
) {
withResult(Dispatchers.IO) {
gglListComponent.listHomePage(
"https://anime.girigirilove.com/show/21-----------/",
it
)
}
},
)
}
override fun getFirstSearchKey(keyword: String): Int {
return 1
}
override suspend fun search(
pageKey: Int,
keyword: String
): SourceResult<Pair<Int?, List<CartoonCover>>> {
return withResult(Dispatchers.IO) {
val url = SourceUtils.urlParser(
GGLListComponent.ROOT_URL,
"/search/${URLEncoder.encode(keyword, "utf-8")}----------${pageKey}---/"
)
val doc = gglListComponent.getDoc(url).getOrThrow()
val list = arrayListOf<CartoonCover>()
doc.select("div div.public-list-box.search-box").forEach {
val uu = it.child(1).child(0).attr("href")
val id = uu.subSequence(1, uu.length - 1).toString()
val coverStyle = it.select("div.cover")[0].attr("style")
val coverPattern = Regex("""(?<=url\().*(?=\))""")
var cover = coverPattern.find(coverStyle)?.value ?: ""
if (cover.startsWith("//")) {
cover = "http:${cover}"
}
Log.d("GGLSearchComponent", coverStyle)
val title = it.select("div.thumb-content div.thumb-txt").first()?.text() ?: ""
val b = CartoonCoverImpl(
id = id,
title = title,
url = SourceUtils.urlParser(GGLListComponent.ROOT_URL, uu),
intro = "",
coverUrl = SourceUtils.urlParser(GGLListComponent.ROOT_URL, cover),
source = source.key,
)
list.add(b)
}
(if (list.isEmpty()) null else pageKey + 1) to list
}
}
}
================================================
FILE: extension-app/src/main/java/com/heyanle/easybangumi_extension/ggl/GGLDetailedComponent.kt
================================================
package com.heyanle.easybangumi_extension.ggl
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.detailed.DetailedComponent
import com.heyanle.easybangumi4.source_api.component.page.PageComponent
import com.heyanle.easybangumi4.source_api.component.search.SearchComponent
import com.heyanle.easybangumi4.source_api.component.update.UpdateComponent
import com.heyanle.easybangumi4.source_api.entity.Cartoon
import com.heyanle.easybangumi4.source_api.entity.CartoonImpl
import com.heyanle.easybangumi4.source_api.entity.CartoonSummary
import com.heyanle.easybangumi4.source_api.entity.Episode
import com.heyanle.easybangumi4.source_api.entity.PlayLine
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.utils.core.SourceUtils
import com.heyanle.easybangumi4.source_api.utils.core.network.GET
import com.heyanle.easybangumi4.source_api.withResult
import kotlinx.coroutines.Dispatchers
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
/**
* Created by heyanle on 2024/1/28.
* https://github.com/heyanLE
*/
class GGLDetailedComponent(
private val okhttpHelper: OkhttpHelper,
) : ComponentWrapper(), DetailedComponent, UpdateComponent {
override suspend fun getAll(summary: CartoonSummary): SourceResult<Pair<Cartoon, List<PlayLine>>> {
return withResult(Dispatchers.IO) {
val doc = getDoc(summary)
detailed(doc, summary) to playLine(doc, summary)
}
}
override suspend fun getDetailed(summary: CartoonSummary): SourceResult<Cartoon> {
return withResult(Dispatchers.IO) {
val doc = getDoc(summary)
detailed(doc, summary)
}
}
override suspend fun getPlayLine(summary: CartoonSummary): SourceResult<List<PlayLine>> {
return withResult(Dispatchers.IO) {
val doc = getDoc(summary)
playLine(doc, summary)
}
}
private fun getDoc(summary: CartoonSummary): Document {
val d = okhttpHelper.cloudflareWebViewClient.newCall(
GET(
SourceUtils.urlParser(
GGLListComponent.ROOT_URL,
summary.id
)
)
)
.execute().body?.string() ?: throw NullPointerException()
return Jsoup.parse(d)
}
private fun detailed(doc: Document, summary: CartoonSummary): Cartoon {
val title = doc.select("div.detail-info h3.slide-info-title").text()
// val genre = doc.select("div.detail-info div.slide-info span").map { it.text() }.joinToString { ", " }
val cover = doc.select("div.wow div.detail-pic img").first()?.attr("data-src") ?: ""
val desc = doc.select("div.switch-box div.check div.text").first()?.text() ?: ""
return CartoonImpl(
id = summary.id,
url = SourceUtils.urlParser(GGLListComponent.ROOT_URL, summary.id),
source = summary.source,
title = title,
coverUrl = SourceUtils.urlParser(GGLListComponent.ROOT_URL, cover),
intro = "",
description = desc,
genre = null,
status = Cartoon.STATUS_UNKNOWN,
updateStrategy = Cartoon.UPDATE_STRATEGY_ALWAYS,
)
}
private fun playLine(doc: Document, summary: CartoonSummary): List<PlayLine> {
val tabs =
doc.select("div.anthology.wow div.anthology-tab div.swiper-wrapper a.swiper-slide")
.iterator()
val epRoot = doc.select("div.anthology-list-box div ul.anthology-list-play").iterator()
val playLines = arrayListOf<PlayLine>()
var ii = 1
while (tabs.hasNext() && epRoot.hasNext()) {
val tab = tabs.next()
val ul = epRoot.next()
val es = arrayListOf<Episode>()
ul.children().forEachIndexed { index, element ->
es.add(
Episode(
id = (index + 1).toString(),
label = element?.text() ?: "",
order = index
)
)
}
playLines.add(
PlayLine(
id = ii.toString(),
label = tab.text(),
episode = es
)
)
ii++
}
return playLines
}
override suspend fun update(
cartoon: Cartoon,
oldPlayLine: List<PlayLine>
): SourceResult<Cartoon> {
return withResult(Dispatchers.IO) {
when (val n = getAll(CartoonSummary(cartoon.id, cartoon.source))) {
is SourceResult.Complete -> {
n.data.first.apply {
val newPlayLine = n.data.second
if (oldPlayLine.size != newPlayLine.size) {
isUpdate = true
} else {
isUpdate = false
for (i in oldPlayLine.indices) {
if (oldPlayLine[i].episode.size != newPlayLine[i].episode.size) {
isUpdate = true
break
}
}
}
}
}
is SourceResult.Error -> {
throw n.throwable
}
}
}
}
}
================================================
FILE: extension-app/src/main/java/com/heyanle/easybangumi_extension/ggl/GGLListComponent.kt
================================================
package com.heyanle.easybangumi_extension.ggl
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.utils.core.SourceUtils
import com.heyanle.easybangumi4.source_api.utils.core.network.GET
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
/**
* Created by HeYanLe on 2023/5/21 21:18.
* https://github.com/heyanLE
*/
class GGLListComponent(
private val okhttpHelper: OkhttpHelper,
): ComponentWrapper() {
companion object {
val ROOT_URL = "https://anime.girigirilove.com"
}
suspend fun listHomePage(
url: String,
page: Int,
): Pair<Int?, List<CartoonCover>>{
val d = if(!url.endsWith("/")) "${url}/" else url
val u = d.replace("---/", "${page}---/")
val list = arrayListOf<CartoonCover>()
val doc = getDoc(u).getOrThrow()
doc.select("div.border-box div.public-list-box").forEach {
val uu = it.child(0).child(0).attr("href")
val id = uu.subSequence(1, uu.length-1).toString()
list.add(
CartoonCoverImpl(
id = id,
source = source.key,
url = SourceUtils.urlParser(ROOT_URL, uu),
title = it.child(1).child(0).text(),
intro = it.select("span .public-list-prb").first()?.text(),
coverUrl = SourceUtils.urlParser(ROOT_URL,it.select("img").first()?.attr("data-src")?:""),
)
)
}
return (if(list.isEmpty()) null else page+1) to list
}
fun getDoc(target: String): Result<Document> {
return runCatching {
val req = okhttpHelper.cloudflareWebViewClient.newCall(
GET(
SourceUtils.urlParser(ROOT_URL, target),
)
).execute()
val body = req.body!!.string()
Jsoup.parse(body)
}
}
}
================================================
FILE: extension-app/src/main/java/com/heyanle/easybangumi_extension/ggl/GGLPlayComponent.kt
================================================
package com.heyanle.easybangumi_extension.ggl
import android.util.Log
import com.heyanle.easybangumi4.source_api.ParserException
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.play.PlayComponent
import com.heyanle.easybangumi4.source_api.entity.CartoonSummary
import com.heyanle.easybangumi4.source_api.entity.Episode
import com.heyanle.easybangumi4.source_api.entity.PlayLine
import com.heyanle.easybangumi4.source_api.entity.PlayerInfo
import com.heyanle.easybangumi4.source_api.utils.api.NetworkHelper
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.utils.api.WebViewHelper
import com.heyanle.easybangumi4.source_api.utils.core.SourceUtils
import com.heyanle.easybangumi4.source_api.withResult
import kotlinx.coroutines.Dispatchers
import org.jsoup.Jsoup
/**
* Created by heyanle on 2024/1/28.
* https://github.com/heyanLE
*/
class GGLPlayComponent(
private val webViewHelper: WebViewHelper,
private val networkHelper: NetworkHelper,
): ComponentWrapper(), PlayComponent {
override suspend fun getPlayInfo(
summary: CartoonSummary,
playLine: PlayLine,
episode: Episode
): SourceResult<PlayerInfo> {
return withResult(Dispatchers.IO) {
val urlPath = "${if(summary.id.startsWith("GV"))summary.id else "GV${summary.id}"}-${playLine.id}-${episode.id}"
val url = SourceUtils.urlParser(GGLListComponent.ROOT_URL, "/play${urlPath}/")
val doc = webViewHelper.getRenderedHtmlCode(url = url, callBackRegex = "https://anime.girigirilove.com/addons/dp/player/index.php?.*", "utf-8", networkHelper.defaultLinuxUA, null, null, 20000L)
Log.i("GGLPlayComponent", doc)
val jsoup = Jsoup.parse(doc)
val src = jsoup.select("tbody td iframe").first()?.attr("src")?:""
val u = src.split("?").last().split("&").find {
it.startsWith("url=")
}?.let {
it.subSequence(4, it.length)
}?.toString() ?:""
if(u.isEmpty()){
throw ParserException("url 解析失败")
}
PlayerInfo(
decodeType = if(u.endsWith("m3u8")) PlayerInfo.DECODE_TYPE_HLS else PlayerInfo.DECODE_TYPE_OTHER,
uri = u
)
}
}
}
================================================
FILE: extension-app/src/main/java/com/heyanle/easybangumi_extension/ggl/GGLSource.kt
================================================
package com.heyanle.easybangumi_extension.ggl
import com.heyanle.easybangumi4.source_api.Source
import com.heyanle.extension_api.ExtensionIconSource
import com.heyanle.extension_api.ExtensionSource
import org.easybangumi.extension.R
import kotlin.reflect.KClass
/**
* Created by heyanle on 2024/1/28.
* https://github.com/heyanLE
*/
class GGLSource : ExtensionSource(), ExtensionIconSource {
override val describe: String?
get() = "girigirilove"
override val label: String
get() = "girigirilove"
override val version: String
get() = "3.0"
override val versionCode: Int
get() = 3
override fun register(): List<KClass<*>> {
return listOf(
GGLComponent::class,
GGLListComponent::class,
GGLPlayComponent::class,
GGLDetailedComponent::class
)
}
override fun getIconResourcesId(): Int? {
return R.drawable.ggl
}
override val sourceKey: String
get() = "heyanle_girigirilove"
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/AIOHtpHelper.kt
================================================
package io.github.easybangumiorg.source.aio
/**
* Created by heyanle on 2024/1/28.
* https://github.com/heyanLE
*/
class AIOHtpHelper {
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/OkHttp.kt
================================================
package io.github.easybangumiorg.source.aio
import android.util.Log
import kotlinx.serialization.json.Json
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import java.nio.charset.Charset
val json = Json {
ignoreUnknownKeys = true
}
val commonHttpClient = OkHttpClient.Builder()
.addInterceptor {
val req = it.request()
Log.d("CommonOkHttpClient", req.url.toString())
val builder = req.newBuilder()
if (req.header("user-agent")?.isNotEmpty() != true) {
builder.header(
"user-agent",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
)
}
it.proceed(builder.build())
}
.build()
fun OkHttpClient.newRequest(block: Request.Builder.() -> Unit): Response {
val req = Request.Builder()
.apply(block)
.build()
return newCall(req).execute()
}
fun OkHttpClient.newGetRequest(block: Request.Builder.() -> Unit): Response {
return newRequest {
block()
get()
}
}
fun Response.asDocument(): Document {
return Jsoup.parse(this.bodyString()).apply {
setBaseUri(request.url.toString())
}
}
fun Response.bodyString(charset: Charset = Charsets.UTF_8): String {
if (code != 200) {
throw RuntimeException("请求${request.url}失败,code: $code")
}
return this.use {
val body = it.body ?: throw RuntimeException("请求${request.url}失败,响应体为空")
body.string()
}
}
inline fun <reified T> Response.readJson(): T {
return json.decodeFromString<T>(this.bodyString())
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/SourceResult.kt
================================================
package io.github.easybangumiorg.source.aio
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.withResult
import kotlinx.coroutines.Dispatchers
fun <T, R> SourceResult<T>.map(convert: (T) -> R): SourceResult<R> {
return when (this) {
is SourceResult.Complete -> SourceResult.Complete(convert(data))
is SourceResult.Error -> SourceResult.Error(throwable, isParserError)
}
}
suspend fun <T> withIoResult(block: suspend () -> T) = withResult(Dispatchers.IO, block)
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/String.kt
================================================
package io.github.easybangumiorg.source.aio
import java.net.URLDecoder
import java.net.URLEncoder
fun String.encodeUri(): String = URLEncoder.encode(this, "UTF-8")
fun String.decodeUri(): String = URLDecoder.decode(this, "UTF-8")
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/auete/AueteDetail.kt
================================================
package io.github.easybangumiorg.source.aio.auete
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.detailed.DetailedComponent
import com.heyanle.easybangumi4.source_api.entity.Cartoon
import com.heyanle.easybangumi4.source_api.entity.CartoonImpl
import com.heyanle.easybangumi4.source_api.entity.CartoonSummary
import com.heyanle.easybangumi4.source_api.entity.Episode
import com.heyanle.easybangumi4.source_api.entity.PlayLine
import io.github.easybangumiorg.source.aio.asDocument
import io.github.easybangumiorg.source.aio.commonHttpClient
import io.github.easybangumiorg.source.aio.map
import io.github.easybangumiorg.source.aio.newGetRequest
import io.github.easybangumiorg.source.aio.withIoResult
class AueteDetail : ComponentWrapper(), DetailedComponent {
override suspend fun getAll(summary: CartoonSummary): SourceResult<Pair<Cartoon, List<PlayLine>>> =
withIoResult {
val doc = commonHttpClient.newGetRequest {
url("$AueteBaseUrl/${summary.id}/")
}.asDocument()
val container = doc.selectFirst(".main .card-thread > .card-body")!!
val img = container.selectFirst(".cover img")?.absUrl("src") ?: ""
val title =
container.selectFirst(".media > .media-body > .title")!!.text().trim().let { str ->
val idx = str.indexOf('《')
if (idx == -1) {
str
} else {
var end = str.length
for (i in (idx + 1) until str.length) {
if (str[i] == '》') {
end = i
break
}
}
str.substring(idx + 1, end)
}
}
val infoList = mutableListOf<String>()
val infoEls = container.select(".message > p")
var desc = ""
for ((index, p) in infoEls.withIndex()) {
val text = p.text().trim()
if (text.contains("简介")) {
if (index + 1 < infoEls.size) {
desc = infoEls[index + 1].text().trim()
}
break
}
infoList.add(text)
}
val playlists = container.select("[id=player_list]").map { playlistContainer ->
var name = playlistContainer.selectFirst(".title")!!.text().trim()
name.indexOf('』').let {
if (it >= 0) {
name = name.substring(it + 1)
}
}
name.indexOf(':').let {
if (it >= 0) {
name = name.substring(0, it)
}
}
val episodes = playlistContainer.select("ul > li > a").map { epEl ->
val id = epEl.attr("href").let {
it.substring(it.lastIndexOf('/') + 1, it.lastIndexOf('.'))
}
Episode(label = epEl.text().trim(), id = id, order = 0)
}
PlayLine(id = name, label = name, episode = arrayListOf(*episodes.toTypedArray()))
}
val cartoon = CartoonImpl(
id = summary.id,
source = source.key,
url = "$AueteBaseUrl/${summary.id}/",
title = title,
coverUrl = img,
description = desc,
intro = infoList.joinToString(separator = "\n")
)
cartoon to playlists
}
override suspend fun getDetailed(summary: CartoonSummary): SourceResult<Cartoon> =
getAll(summary).map { it.first }
override suspend fun getPlayLine(summary: CartoonSummary): SourceResult<List<PlayLine>> =
getAll(summary).map { it.second }
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/auete/AuetePage.kt
================================================
package io.github.easybangumiorg.source.aio.auete
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.page.PageComponent
import com.heyanle.easybangumi4.source_api.component.page.SourcePage
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import com.heyanle.easybangumi4.source_api.withResult
import io.github.easybangumiorg.source.aio.asDocument
import io.github.easybangumiorg.source.aio.commonHttpClient
import io.github.easybangumiorg.source.aio.newGetRequest
import io.github.easybangumiorg.source.aio.withIoResult
class AuetePage : ComponentWrapper(), PageComponent {
override fun getPages(): List<SourcePage> {
val home = SourcePage.Group(label = "首页", newScreen = false) {
withIoResult {
val doc = commonHttpClient.newGetRequest {
url(AueteBaseUrl)
}.asDocument()
val areas: MutableList<SourcePage.SingleCartoonPage> =
doc.select(".container > .row > .main .card").map { area ->
val areaName = area.firstElementChild()!!.selectFirst("a")!!.text().trim()
val videos =
area.select(".threadlist > li").map { it.parseAueteVideo(source.key) }
SourcePage.SingleCartoonPage.WithCover(label = areaName, firstKey = { 0 }) {
withResult {
null to videos
}
}
}.toMutableList()
doc.selectFirst(".card-site-info")
?.parent()
?.children()
?.asSequence()
?.forEach {
val title = it.selectFirst(".card-header")?.text()?.trim() ?: return@forEach
val videos = it.select(".card-body > .list-ul > li > a").map { videoEl ->
CartoonCoverImpl(
id = videoEl.attr("href").trim('/'),
source = source.key,
url = videoEl.absUrl("href"),
title = videoEl.text().trim()
)
}
if (videos.isEmpty()) {
return@forEach
}
SourcePage.SingleCartoonPage.WithoutCover(label = title, firstKey = { 0 }) {
withResult {
null to videos
}
}.let { page -> areas.add(page) }
}
areas
}
}
val others = getVideoCategories().map { (pageLabel, pageKey, subTypes) ->
SourcePage.Group(label = pageLabel, newScreen = false) {
withResult {
subTypes.map { (typeName, typeKey) ->
SourcePage.SingleCartoonPage.WithCover(
label = typeName,
firstKey = { 1 }) { page ->
withIoResult {
getVideoOfCategoryAndType(
category = pageKey,
type = typeKey,
page = page
)
}
}
}
}
}
}
return listOf(home) + others
}
private fun getVideoOfCategoryAndType(
category: String,
type: String,
page: Int
): Pair<Int?, List<CartoonCover>> {
val urlBuilder = StringBuilder(AueteBaseUrl)
.append('/')
.append(category)
if (type.isNotEmpty()) {
urlBuilder.append('/')
.append(type)
}
urlBuilder.append("/index")
if (page > 1) {
urlBuilder.append(page)
}
urlBuilder.append(".html")
val doc = commonHttpClient.newGetRequest {
url(urlBuilder.toString())
}.asDocument()
val videos = doc.select(".threadlist > li").map { it.parseAueteVideo(source = source.key) }
val nextPage = if (doc.aueteHaveNextPage()) page + 1 else null
return nextPage to videos
}
private fun getVideoCategories() = listOf(
Triple(
"电影",
"Movie",
listOf(
"全部" to "",
"喜剧片" to "xjp",
"动作片" to "dzp",
"爱情片" to "aqp",
"科幻片" to "khp",
"恐怖片" to "kbp",
"惊悚片" to "jsp",
"战争片" to "zzp",
"剧情片" to "jqp"
)
),
Triple(
"电视剧",
"Tv",
listOf(
"全部" to "",
"美剧" to "oumei",
"韩剧" to "hanju",
"日剧" to "riju",
"泰剧" to "yataiju",
"网剧" to "wangju",
"台剧" to "taiju",
"国产" to "neidi",
"港剧" to "tvbgj",
"英剧" to "yingju",
"外剧" to "waiju"
)
),
Triple(
"综艺",
"Zy",
listOf(
"全部" to "",
"国综" to "guozong",
"韩综" to "hanzong",
"美综" to "meizong"
)
),
Triple(
"动漫",
"Dm",
listOf(
"全部" to "",
"动画" to "donghua",
"日漫" to "riman",
"国漫" to "guoman",
"美漫" to "meiman"
)
),
Triple(
"其他",
"qita",
listOf(
"全部" to "",
"记录片" to "Jlp",
"经典片" to "Jdp",
"经典剧" to "Jdj",
"网大电影" to "wlp",
"国产老电影" to "laodianying"
)
)
)
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/auete/AuetePlay.kt
================================================
package io.github.easybangumiorg.source.aio.auete
import com.heyanle.easybangumi4.source_api.ParserException
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.play.PlayComponent
import com.heyanle.easybangumi4.source_api.entity.CartoonSummary
import com.heyanle.easybangumi4.source_api.entity.Episode
import com.heyanle.easybangumi4.source_api.entity.PlayLine
import com.heyanle.easybangumi4.source_api.entity.PlayerInfo
import io.github.easybangumiorg.source.aio.bodyString
import io.github.easybangumiorg.source.aio.commonHttpClient
import io.github.easybangumiorg.source.aio.newGetRequest
import io.github.easybangumiorg.source.aio.withIoResult
import kotlin.io.encoding.ExperimentalEncodingApi
class AuetePlay : ComponentWrapper(), PlayComponent {
@OptIn(ExperimentalEncodingApi::class)
override suspend fun getPlayInfo(
summary: CartoonSummary,
playLine: PlayLine,
episode: Episode
): SourceResult<PlayerInfo> = withIoResult {
val html = commonHttpClient.newGetRequest {
url("$AueteBaseUrl/${summary.id}/${episode.id}.html")
}.bodyString()
val idx = html.indexOf(" now")
var start = -1
if (idx > 0) {
for (i in (idx + 4) until html.length) {
val c = html[i]
if (c == '"') {
if (start == -1) {
start = i
} else {
val videoUrl = if (html.substring(idx, start).contains("base64")) {
kotlin.io.encoding.Base64.decode(html.substring(start + 1, i))
.toString(Charsets.UTF_8)
} else {
html.substring(start + 1, i)
}
return@withIoResult PlayerInfo(
uri = videoUrl,
decodeType = PlayerInfo.DECODE_TYPE_HLS
)
}
}
}
}
throw ParserException("未获取到视频链接")
}
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/auete/AueteSearch.kt
================================================
package io.github.easybangumiorg.source.aio.auete
//import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.search.SearchComponent
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import io.github.easybangumiorg.source.aio.asDocument
import io.github.easybangumiorg.source.aio.commonHttpClient
import io.github.easybangumiorg.source.aio.encodeUri
import io.github.easybangumiorg.source.aio.newGetRequest
import io.github.easybangumiorg.source.aio.withIoResult
class AueteSearch : ComponentWrapper(), SearchComponent {
override fun getFirstSearchKey(keyword: String): Int = 1
override suspend fun search(
pageKey: Int,
keyword: String
): SourceResult<Pair<Int?, List<CartoonCover>>> = withIoResult {
val doc = commonHttpClient.newGetRequest {
url("$AueteBaseUrl/auete3so.php?searchword=${keyword.encodeUri()}")
}.asDocument()
val videos = doc.getElementsByClass("threadlist").map { el ->
val linkEl = el.selectFirst("a")!!
CartoonCoverImpl(
id = linkEl.attr("href").trim('/'),
url = linkEl.absUrl("href"),
title = linkEl.text().trim(),
source = source.key,
)
}
null to videos
}
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/auete/AueteSource.kt
================================================
package io.github.easybangumiorg.source.aio.auete
import com.heyanle.easybangumi4.source_api.Source
import com.heyanle.extension_api.ExtensionIconSource
import org.easybangumi.extension.R
import kotlin.reflect.KClass
class AueteSource : Source, ExtensionIconSource {
override val describe: String
get() = label
override val key: String
get() = "auete"
override val label: String
get() = "Auete影视"
override val version: String
get() = "2.0"
override val versionCode: Int
get() = 4
override fun getIconResourcesId(): Int = R.drawable.auete
override fun register(): List<KClass<*>> = listOf(
AuetePage::class,
AueteDetail::class,
AueteSearch::class,
AuetePlay::class
)
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/auete/Common.kt
================================================
package io.github.easybangumiorg.source.aio.auete
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
const val AueteBaseUrl = "https://auete.pro"
fun Element.parseAueteVideo(source: String): CartoonCover {
val linkEl = selectFirst("a")!!
val id = linkEl.attr("href").trim('/')
val image = selectFirst("img")?.absUrl("src") ?: ""
val episode = selectFirst(".hdtag")?.text()?.trim()
val title = selectFirst(".title")!!.text().trim()
return CartoonCoverImpl(
id = id,
source = source,
url = linkEl.absUrl("href"),
title = title,
coverUrl = image,
intro = episode
)
}
fun Document.aueteHaveNextPage(): Boolean {
val pageItems = select(".pagination > li")
if (pageItems.isEmpty()) {
return false
}
return pageItems.indexOfLast { it.hasClass("active") } < pageItems.size - 3
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/changzhang/ChangZhangDetailPage.kt
================================================
package io.github.easybangumiorg.source.aio.changzhang
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.detailed.DetailedComponent
import com.heyanle.easybangumi4.source_api.entity.Cartoon
import com.heyanle.easybangumi4.source_api.entity.CartoonImpl
import com.heyanle.easybangumi4.source_api.entity.CartoonSummary
import com.heyanle.easybangumi4.source_api.entity.Episode
import com.heyanle.easybangumi4.source_api.entity.PlayLine
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import io.github.easybangumiorg.source.aio.asDocument
import io.github.easybangumiorg.source.aio.map
import io.github.easybangumiorg.source.aio.newGetRequest
import io.github.easybangumiorg.source.aio.withIoResult
class ChangZhangDetailPage(private val okhttpHelper: OkhttpHelper):DetailedComponent,ComponentWrapper() {
override suspend fun getAll(summary: CartoonSummary): SourceResult<Pair<Cartoon, List<PlayLine>>> =
withIoResult{
val detailPageUrl = "${ChangZhangSource.BASE_URL}/movie/${summary.id}.html"
val doc = okhttpHelper.cloudflareClient.newGetRequest {
url(detailPageUrl)
}.asDocument()
val episodes = doc.select(".paly_list_btn > a").map { epEl ->
val url = epEl.attr("href")
Episode(
id = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.')),
label = epEl.text().trim(),
order = 0
)
}
val container = doc.selectFirst(".dyxingq")!!
val image = container.selectFirst(".dyimg > img")!!.let {
it.dataset()["original"] ?: it.attr("src")
}
val title = container.selectFirst(".dytext > .moviedteail_tt > h1")!!.text()
val infoList = container.select(".dytext > .moviedteail_list > li").map { it.text().trim() }
val desc = doc.selectFirst(".yp_context")?.text()?.trim()
CartoonImpl(
id = summary.id,
source = source.key,
url = detailPageUrl,
title = title,
intro = infoList.joinToString(separator = "\n"),
coverUrl = image,
description = desc
) to listOf(PlayLine(id = "1", label = "播放列表", episode = arrayListOf(*episodes.toTypedArray())))
}
override suspend fun getDetailed(summary: CartoonSummary): SourceResult<Cartoon> = getAll(summary).map { it.first }
override suspend fun getPlayLine(summary: CartoonSummary): SourceResult<List<PlayLine>> = getAll(summary).map { it.second }
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/changzhang/ChangZhangPage.kt
================================================
package io.github.easybangumiorg.source.aio.changzhang
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.page.PageComponent
import com.heyanle.easybangumi4.source_api.component.page.SourcePage
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import io.github.easybangumiorg.source.aio.asDocument
import io.github.easybangumiorg.source.aio.changzhang.ChangZhangSource.Companion.hasNextPage
import io.github.easybangumiorg.source.aio.changzhang.ChangZhangSource.Companion.parseAnime
import io.github.easybangumiorg.source.aio.newGetRequest
import io.github.easybangumiorg.source.aio.withIoResult
class ChangZhangPage(private val okhttpHelper: OkhttpHelper):PageComponent,ComponentWrapper() {
override fun getPages(): List<SourcePage> {
val homePage = SourcePage.Group("首页",newScreen = false){
withIoResult {
val doc = okhttpHelper.cloudflareClient.newGetRequest { url(ChangZhangSource.BASE_URL) }.asDocument()
doc.getElementsByClass("mi_btcon").asSequence().map { groupEl ->
val name = groupEl.selectFirst(".bt_tit a")?.text()?.trim()?:"推荐"
val videos = groupEl.select(".bt_img > ul > li").map { it.parseAnime(source = source.key) }
name to videos
}
.filter { it.second.isNotEmpty() }
.map { (label,videos)->
SourcePage.SingleCartoonPage.WithCover(label = label, firstKey = {0}){
SourceResult.Complete(null to videos)
}
}
.toList()
}
}
val movie = SourcePage.Group("电影",newScreen = false){
withIoResult {
val doc = okhttpHelper.cloudflareClient.newGetRequest { url("${ChangZhangSource.BASE_URL}/movie_bt") }.asDocument()
doc.select("#beautiful-taxonomy-filters-tax-movie_bt_tags > a").asSequence()
.map {
it.text() to (it.attr("cat-url").takeIf { it.isNotEmpty() }?: it.attr("href"))
}
.map { (label,url)->
SourcePage.SingleCartoonPage.WithCover(label = label, firstKey = {1}){page->
withIoResult { fetchVideoCategoryPage(url,page) }
}
}
.toList()
}
}
val otherPages = listOf(
"美剧" to "meijutt",
"日剧" to "riju",
"韩剧" to "hanjutv",
"番剧" to "fanju",
"电视剧" to "dsj",
"国产剧" to "gcj",
"剧场版" to "dongmanjuchangban",
"海外剧" to "haiwaijuqita",
"热映中" to "benyueremen"
).map { (label,urlSuffix)->
SourcePage.SingleCartoonPage.WithCover(label = label, firstKey = {1}){page->
withIoResult {
fetchVideoCategoryPage("${ChangZhangSource.BASE_URL}/$urlSuffix",page)
}
}
}
return listOf(homePage,movie)+otherPages
}
private fun fetchVideoCategoryPage(url:String,page:Int): Pair<Int?,List<CartoonCover>> {
val actualUrl = if (page>1) "$url/page/$page" else url
val doc = okhttpHelper.cloudflareClient.newGetRequest { url(actualUrl) }.asDocument()
val videos = doc.select(".bt_img > ul > li").map { it.parseAnime(source = source.key) }
val next = if (doc.hasNextPage()) page +1 else null
return next to videos
}
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/changzhang/ChangZhangPlayPage.kt
================================================
package io.github.easybangumiorg.source.aio.changzhang
import com.google.gson.Gson
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.play.PlayComponent
import com.heyanle.easybangumi4.source_api.entity.CartoonSummary
import com.heyanle.easybangumi4.source_api.entity.Episode
import com.heyanle.easybangumi4.source_api.entity.PlayLine
import com.heyanle.easybangumi4.source_api.entity.PlayerInfo
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import io.github.easybangumiorg.source.aio.bodyString
import io.github.easybangumiorg.source.aio.newGetRequest
import io.github.easybangumiorg.source.aio.withIoResult
import org.jsoup.Jsoup
import java.util.Stack
import javax.crypto.Cipher
import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec
import kotlin.io.encoding.ExperimentalEncodingApi
class ChangZhangPlayPage(private val okhttpHelper: OkhttpHelper):PlayComponent,ComponentWrapper() {
override suspend fun getPlayInfo(
summary: CartoonSummary,
playLine: PlayLine,
episode: Episode
): SourceResult<PlayerInfo> = withIoResult{
val html = okhttpHelper.cloudflareClient.newGetRequest {
url("${ChangZhangSource.BASE_URL}/v_play/${episode.id}.html")
}.bodyString()
val videoUrl = getVideoPlainUrlFromHtml(html)
PlayerInfo(uri = videoUrl, decodeType = if (videoUrl.contains("m3u8")) PlayerInfo.DECODE_TYPE_HLS else PlayerInfo.DECODE_TYPE_OTHER)
}
@OptIn(ExperimentalEncodingApi::class)
private suspend fun getVideoPlainUrlFromHtml(html: String): String {
val iframeSrc = Jsoup.parse(html).selectFirst(".videoplay > iframe")?.attr("src") ?: ""
if (iframeSrc.isNotEmpty()) {
return getVideoUrlFromIframe(iframeSrc)
}
val variableName = extractVariableName(html)
val source = extractVariableValue(html, variableName)
val (key, iv) = extractKeyAndIv(html)
val code = with(Cipher.getInstance("AES/CBC/PKCS5Padding")) {
init(
Cipher.DECRYPT_MODE, SecretKeySpec(key.toByteArray(Charsets.UTF_8), "AES"),
IvParameterSpec(iv.toByteArray(Charsets.UTF_8))
)
doFinal(kotlin.io.encoding.Base64.decode(source)).toString(Charsets.UTF_8)
}
val urlIndex = code.indexOf("url")
val startIndex = code.indexOf(':', startIndex = urlIndex + 3) + 1
var quoteStartIndex = -1
for (i in startIndex until code.length) {
val c = code[i]
if (c == '\'' || c == '"') {
if (quoteStartIndex == -1) {
quoteStartIndex = i
} else {
return code.substring(quoteStartIndex + 1, i)
}
}
}
throw RuntimeException()
}
private fun getStringVariableValue(html: String, variableName: String): String? {
val keyword = " $variableName"
val idx = html.indexOf(keyword)
if (idx == -1) {
return null
}
var start = -1
var quote = '"'
for (i in (idx + keyword.length) until html.length) {
val c = html[i]
if (start == -1 && (c == '\'' || c == '"')) {
start = i
quote = c
continue
}
if (start > 0 && c == quote) {
return html.substring(start + 1, i)
}
}
return null
}
private suspend fun getVideoUrlFromIframe(iframeSrc: String): String {
val resp = okhttpHelper.client.newGetRequest {
url(iframeSrc)
header("referer", "https://www.czzy88.com/")
header("sec-fetch-dest", "iframe")
header("Sec-Fetch-Mode", "navigate")
header("Sec-Fetch-Site", "cross-site")
}
val html = resp.body!!.string()
val keyword = "\"data\""
val idx = html.indexOf(keyword)
if (idx == -1) {
return getVideoUrlOfPlayerAndRand(html)
}
val startIndex = html.indexOf('"', startIndex = idx + keyword.length)
var end = -1
for (i in (startIndex + 1) until html.length) {
if (html[i] == '"') {
end = i;
break
}
}
if (end <= startIndex) {
throw RuntimeException("未获取到data值")
}
val dataValue = html.substring(startIndex + 1, end)
val newStr = dataValue.reversed().chunked(2)
.map { it.toInt(16).toChar() }
.joinToString(separator = "")
val splitIndex = (newStr.length - 7) / 2
return newStr.substring(0, splitIndex) + newStr.substring(splitIndex + 0x7)
}
@OptIn(ExperimentalEncodingApi::class)
private fun getVideoUrlOfPlayerAndRand(html: String): String {
val rand = getStringVariableValue(html, "rand") ?: throw RuntimeException("未找到rand变量")
val player =
getStringVariableValue(html, "player") ?: throw RuntimeException("未找到player变量")
val key = "VFBTzdujpR9FWBhe"
val config = with(Cipher.getInstance("AES/CBC/PKCS5Padding")) {
init(
Cipher.DECRYPT_MODE, SecretKeySpec(key.toByteArray(Charsets.UTF_8), "AES"),
IvParameterSpec(rand.toByteArray(Charsets.UTF_8))
)
doFinal(kotlin.io.encoding.Base64.decode(player)).toString(Charsets.UTF_8)
}
val map = Gson().fromJson<Map<String, Any>>(config, Map::class.java)
return map["url"]?.let { it as String } ?: throw RuntimeException("未获取到url")
}
private fun extractKeyAndIv(html: String): Pair<String, String> {
var start = 0
val keyAndIv = mutableListOf<String>()
val keyword = "Utf8.parse("
while (start < html.length) {
val idx = html.indexOf(keyword, startIndex = start)
if (idx == -1) {
break
}
val valueStart = idx + keyword.length
for (i in valueStart until html.length) {
if (html[i] == ')') {
val value = html.substring(valueStart, i)
keyAndIv.add(value.trim('"', '\''))
if (keyAndIv.size == 2) {
return keyAndIv[0] to keyAndIv[1]
}
start = i + 1
break
}
}
}
throw RuntimeException("未获取到key和iv")
}
private fun extractVariableValue(html: String, name: String): String {
val idx = html.indexOf(" $name")
if (idx == -1) {
throw RuntimeException()
}
var quoteStart = -1
for (i in (idx + name.length + 1) until html.length) {
val c = html[i]
if (c == '\'' || c == '"') {
if (quoteStart == -1) {
quoteStart = i
} else {
return html.substring(quoteStart + 1, i)
}
}
}
throw RuntimeException()
}
private fun extractVariableName(html: String): String {
val index = html.indexOf("eval(")
if (index == -1) {
throw RuntimeException("未找到eval函数调用")
}
val bracketStack = Stack<Int>()
for (i in (index + 4) until html.length) {
val c = html[i]
if (c == '(') {
bracketStack.add(i)
} else if (c == ')') {
return html.substring(bracketStack.peek() + 1, i)
}
}
throw RuntimeException("数据不存在")
}
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/changzhang/ChangZhangSearchPage.kt
================================================
package io.github.easybangumiorg.source.aio.changzhang
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.search.SearchComponent
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import io.github.easybangumiorg.source.aio.asDocument
import io.github.easybangumiorg.source.aio.changzhang.ChangZhangSource.Companion.hasNextPage
import io.github.easybangumiorg.source.aio.changzhang.ChangZhangSource.Companion.parseAnime
import io.github.easybangumiorg.source.aio.encodeUri
import io.github.easybangumiorg.source.aio.newGetRequest
import io.github.easybangumiorg.source.aio.newRequest
import io.github.easybangumiorg.source.aio.withIoResult
import okhttp3.Cookie
import okhttp3.FormBody
class ChangZhangSearchPage(private val okhttpHelper: OkhttpHelper):SearchComponent,ComponentWrapper() {
var searchUrl:String? = null
override fun getFirstSearchKey(keyword: String): Int {
return 1
}
override suspend fun search(
pageKey: Int,
keyword: String
): SourceResult<Pair<Int?, List<CartoonCover>>> = withIoResult{
if (searchUrl == null) {
searchUrl = okhttpHelper.client.newGetRequest {
url(ChangZhangSource.BASE_URL)
}
.asDocument()
.selectFirst(".w-search-form")
?.attr("action")
?: throw RuntimeException("未获取到搜索视频链接")
}
val doc = okhttpHelper.cloudflareClient.newGetRequest {
url("$searchUrl?q=${keyword.encodeUri()}&f=_all&p=$pageKey")
}.use { resp ->
val respDoc = resp.asDocument()
if (respDoc.title().contains("人机验证")) {
val value = Cookie.parseAll(resp.request.url, resp.headers)
.lastOrNull { it.name == "result" }?.value
?: throw RuntimeException("Cookie中无验证码")
okhttpHelper.cloudflareClient.newRequest {
url(resp.request.url)
post(FormBody.Builder().add("result", value).build())
}
okhttpHelper.cloudflareClient.newGetRequest { url(resp.request.url) }.asDocument()
} else {
respDoc
}
}
val videos = doc.select(".search_list > ul > li").map { it.parseAnime(source = source.key) }
val nextPage = if (doc.hasNextPage()) pageKey + 1 else null
nextPage to videos
}
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/changzhang/ChangZhangSource.kt
================================================
package io.github.easybangumiorg.source.aio.changzhang
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import com.heyanle.extension_api.ExtensionIconSource
import com.heyanle.extension_api.ExtensionSource
import org.easybangumi.extension.R
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import kotlin.reflect.KClass
class ChangZhangSource:ExtensionSource(),ExtensionIconSource {
override val describe: String
get() = "厂长资源"
override val label: String
get() = describe
override val sourceKey: String
get() = "changzhang"
override val version: String
get() = "1.0"
override val versionCode: Int
get() = 1
override fun getIconResourcesId(): Int= R.drawable.changzhang
override fun register(): List<KClass<*>> = listOf(
ChangZhangPage::class,
ChangZhangDetailPage::class,
ChangZhangSearchPage::class,
ChangZhangPlayPage::class
)
companion object {
const val BASE_URL = "https://www.czzy88.com"
fun Element.parseAnime(source:String): CartoonCover {
val url = selectFirst("a")!!.absUrl("href")
val image = selectFirst("img")!!.let {
it.dataset()["original"] ?: it.attr("src")
}
val ep = selectFirst(".jidi")?.text()?.trim()
val title = selectFirst(".dytit")!!.text().trim()
return CartoonCoverImpl(
id = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.')),
url = url,
title = title,
source = source,
intro = ep,
coverUrl = image
)
}
fun Document.hasNextPage(): Boolean {
val pageItems = select(".pagenavi_txt > a")
if (pageItems.isEmpty()) {
return false
}
return !pageItems.last()!!.hasClass("current")
}
}
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/fengche/Common.kt
================================================
package io.github.easybangumiorg.source.aio.fengche
import android.util.Log
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import io.github.easybangumiorg.source.aio.asDocument
import io.github.easybangumiorg.source.aio.commonHttpClient
import io.github.easybangumiorg.source.aio.newGetRequest
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import java.util.concurrent.locks.ReentrantLock
import kotlin.concurrent.withLock
//private val urlPageUrl = "https://wedm.cc/"
//
//private val baseUrlFallback = "https://www.886dm.tv"
//
//@Volatile
//private var _fengCheBaseUrl: String? = null
//
//val FengCheBaseUrl: String
// get() = requireFengCheBaseUrl()
//
//private val baseUrlLock = ReentrantLock()
//
//private fun requireFengCheBaseUrl(): String {
// if (_fengCheBaseUrl == null) {
// baseUrlLock.withLock {
// if (_fengCheBaseUrl == null) {
// _fengCheBaseUrl = runCatching {
// requestFengCheBaseUrl()
// }.onFailure {
// Log.e("FengCheSourceCommon", "requireFengCheBaseUrl:${it.message}", it)
// }
// .getOrNull() ?: baseUrlFallback
// }
// }
// }
// return _fengCheBaseUrl!!
//}
//
//private fun requestFengCheBaseUrl(): String {
// val doc = commonHttpClient.newGetRequest {
// url(urlPageUrl)
// }.asDocument()
//
// val website = doc.selectFirst(".main .speedlist li a i")?.text()?.trim()?.let { text ->
// text
// }
// return if (website?.isNotBlank() == true) {
// "https://$website"
// } else {
// baseUrlFallback
// }
//}
fun String.extractFengCheIdFromUrl() =
this.substring(this.lastIndexOf('/') + 1, this.lastIndexOf('.'))
fun Document.hasNextPage(): Boolean =
this.getElementById("aapages")
?.children()
?.findLast { it.hasClass("pagenow") }
?.nextElementSibling()
?.tagName() === "a"
fun Element.parseFengCheAnime(sourceKey: String): CartoonCover {
val linkEl = selectFirst("a")!!
val url = linkEl.absUrl("href")
val imageUrl = selectFirst(".img_wrapper")?.dataset()?.get("original")
val episode = linkEl.children().last()?.text()?.trim() ?: ""
val title = linkEl.attr("title").takeIf { it.isNotEmpty() }?: linkEl.text().trim()
return CartoonCoverImpl(
id = url.extractFengCheIdFromUrl(),
url = url,
title = title,
source = sourceKey,
coverUrl = imageUrl,
intro = episode
)
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/fengche/FengCheDetail.kt
================================================
package io.github.easybangumiorg.source.aio.fengche
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.detailed.DetailedComponent
import com.heyanle.easybangumi4.source_api.entity.Cartoon
import com.heyanle.easybangumi4.source_api.entity.CartoonImpl
import com.heyanle.easybangumi4.source_api.entity.CartoonSummary
import com.heyanle.easybangumi4.source_api.entity.Episode
import com.heyanle.easybangumi4.source_api.entity.PlayLine
import com.heyanle.easybangumi4.source_api.withResult
//import com.heyanle.easybangumi4.source_api.withResult
import io.github.easybangumiorg.source.aio.asDocument
import io.github.easybangumiorg.source.aio.commonHttpClient
import io.github.easybangumiorg.source.aio.map
import io.github.easybangumiorg.source.aio.newGetRequest
import kotlinx.coroutines.Dispatchers
class FengCheDetail (
private val hostUrlHelper: FengCheHostUrlHelper
): ComponentWrapper(), DetailedComponent {
override suspend fun getAll(summary: CartoonSummary): SourceResult<Pair<Cartoon, List<PlayLine>>> =
withResult(Dispatchers.IO) {
val document = commonHttpClient.newGetRequest {
url("${hostUrlHelper.fengcheBaseUrl}/video/${summary.id}.html")
}.asDocument()
val imageUrl =
document.selectFirst(".con_c1 .img_wrapper")!!.dataset()["original"]!!
val detailContainer = document.selectFirst(".con_xinxi")!!
val title = detailContainer.selectFirst("a")!!.text().trim()
val intro = detailContainer.selectFirst(".yplx_c1")!!.children()
.find { it.text().contains("类型:") }
?.children()
?.lastOrNull()
?.text()
?.trim()
?: ""
val desc = detailContainer.selectFirst(".yplx_c3")?.children()
?.lastOrNull()
?.text()
?.trim()
val playlistNames = document.select(".playlist-tab a").map { it.text().trim() }
val episodesGroup =
document.select(".con_juji_bg > .tab-content > .con_c2_list").asSequence()
.map { epContainer ->
epContainer.select("a").map {
Episode(
id = it.attr("href").extractFengCheIdFromUrl(),
label = it.text().trim(),
order = 1
)
}
}
.toList()
val playlists = List(playlistNames.size.coerceAtMost(episodesGroup.size)) {
PlayLine(
id = it.toString(),
label = playlistNames[it],
episode = arrayListOf(*episodesGroup[it].toTypedArray())
)
}
val cartoon = CartoonImpl(
id = summary.id,
source = source.key,
url = "${hostUrlHelper.fengcheBaseUrl}/video/${summary.id}.html",
title = title,
coverUrl = imageUrl,
description = desc,
intro = intro
)
cartoon to playlists
}
override suspend fun getDetailed(summary: CartoonSummary): SourceResult<Cartoon> {
return getAll(summary).map { it.first }
}
override suspend fun getPlayLine(summary: CartoonSummary): SourceResult<List<PlayLine>> {
return getAll(summary).map { it.second }
}
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/fengche/FengCheHostUrlHelper.kt
================================================
package io.github.easybangumiorg.source.aio.fengche
import com.heyanle.easybangumi4.source_api.utils.api.PreferenceHelper
import io.github.easybangumiorg.source.aio.asDocument
import io.github.easybangumiorg.source.aio.commonHttpClient
import io.github.easybangumiorg.source.aio.newGetRequest
/**
* Created by heyanlin on 2024/5/23.
*/
class FengCheHostUrlHelper(
private val preferenceHelper: PreferenceHelper
) {
private val autoHostUrl: Boolean
get() = preferenceHelper.get("auto_host_url", "false") == "true"
private val diyUrl: String
get() = preferenceHelper.get("BaseUrl", "http://www.fcdm9.com/")
private val urlPageUrl = "https://wedm.cc/"
private val fengcheBaseUrlAutoUrl: String by lazy {
val doc = commonHttpClient.newGetRequest {
url(urlPageUrl)
}.asDocument()
val website = doc.selectFirst(".main .speedlist li a i")?.text()?.trim()?.let { text ->
text
}
return@lazy if (website?.isNotBlank() == true) {
"https://$website"
} else {
diyUrl
}
}
val fengcheBaseUrl: String
get() = (if(autoHostUrl) fengcheBaseUrlAutoUrl else diyUrl).let {
if (it.endsWith("/")){
it.substring(0, it.length - 1)
}else{
it
}
}
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/fengche/FengChePage.kt
================================================
package io.github.easybangumiorg.source.aio.fengche
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.page.PageComponent
import com.heyanle.easybangumi4.source_api.component.page.SourcePage
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.withResult
import io.github.easybangumiorg.source.aio.asDocument
import io.github.easybangumiorg.source.aio.commonHttpClient
import io.github.easybangumiorg.source.aio.encodeUri
import io.github.easybangumiorg.source.aio.newGetRequest
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
class FengChePage(
val okhttpHelper: OkhttpHelper,
private val hostUrlHelper: FengCheHostUrlHelper
) : ComponentWrapper(), PageComponent {
private val categoryLock = Mutex()
private var categories: List<VideoCategory>? = null
override fun getPages(): List<SourcePage> {
val home = SourcePage.Group("首页", false) {
withResult(Dispatchers.IO) {
val document = okhttpHelper.client.newGetRequest {
url(hostUrlHelper.fengcheBaseUrl)
}.asDocument()
val pages = mutableListOf<SourcePage.SingleCartoonPage>()
document.select("body > div.wrapper").forEach { wrapperEl ->
val videoEls = wrapperEl.select(".picList > li")
.takeIf { it.isNotEmpty() }
?: wrapperEl.select(".c2_list > li")
val title = wrapperEl.selectFirst(".cont_title")
?: wrapperEl.selectFirst(".title > .t_head")
title ?: return@forEach
val videos = videoEls.map { it.parseFengCheAnime(source.key)}
if (videos.isNotEmpty()) {
val page =
SourcePage.SingleCartoonPage.WithCover(title.text().trim(), { 0 }) {
withResult {
null to videos
}
}
pages.add(page)
}
}
pages
}
}
val categoryPages = listOf(
"ribendongman" to "日本动漫",
"guochandongman" to "国产动漫",
"dongmandianying" to "动漫电影",
"oumeidongman" to "欧美动漫",
).map { (typeKey, label) ->
SourcePage.Group(label = label, false) {
withResult(Dispatchers.IO) {
val categories = getVideoCategories()
categories.map { category ->
SourcePage.SingleCartoonPage.WithCover(
category.label,
firstKey = { 1 }) { page ->
withResult(Dispatchers.IO) {
requestVideoOfCategory(typeKey, category.value, page)
}
}
}
}
}
}
return listOf(home) + categoryPages
}
private fun requestVideoOfCategory(
typeKey: String,
category: String,
page: Int
): Pair<Int?, List<CartoonCover>> {
val pageUrl = "${hostUrlHelper.fengcheBaseUrl}/show/$typeKey---$category-----$page---.html"
val document = okhttpHelper.client.newGetRequest {
url(pageUrl)
}.asDocument()
val videos = document.select(".wrapper > .culum_con > .c2_list > li")
.map { it.parseFengCheAnime(source.key) }
val nextPage = if (document.hasNextPage()) page + 1 else null
return nextPage to videos
}
private suspend fun getVideoCategories(): List<VideoCategory> {
if (categories == null) {
categoryLock.withLock {
if (categories == null) {
categories = requestVideoCategories()
}
}
}
return categories!!
}
private fun requestVideoCategories(): List<VideoCategory> {
val document = okhttpHelper.client.newGetRequest {
url("${hostUrlHelper.fengcheBaseUrl}/type/ribendongman.html")
}.asDocument()
val row =
document.select("body > div.wrapper.culum_list > div.conx.star_bot > div > div")[1]
val ignoreKey = "ribendongman"
val linkList = row.getElementsByTag("a")
val valueIndex = linkList.last()!!.attr("href").run {
substring(lastIndexOf('/') + 1, lastIndexOf('.'))
}
.split('-')
.indexOfFirst { it.isNotEmpty() && it != ignoreKey }
// 忽略第一个
val categories = linkList.map {el->
val value = el.attr("href").run {
substring(lastIndexOf('/') + 1, lastIndexOf('.'))
}
.split('-')[valueIndex]
VideoCategory(label = el.text().trim(), value = value)
}
return categories
}
private data class VideoCategory(
val label: String,
val value: String
)
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/fengche/FengChePlay.kt
================================================
package io.github.easybangumiorg.source.aio.fengche
import android.util.Base64
import com.google.gson.Gson
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.play.PlayComponent
import com.heyanle.easybangumi4.source_api.entity.CartoonSummary
import com.heyanle.easybangumi4.source_api.entity.Episode
import com.heyanle.easybangumi4.source_api.entity.PlayLine
import com.heyanle.easybangumi4.source_api.entity.PlayerInfo
import com.heyanle.easybangumi4.source_api.withResult
import io.github.easybangumiorg.source.aio.bodyString
import io.github.easybangumiorg.source.aio.commonHttpClient
import io.github.easybangumiorg.source.aio.newGetRequest
import kotlinx.coroutines.Dispatchers
import javax.crypto.Cipher
import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec
class FengChePlay(
private val hostUrlHelper: FengCheHostUrlHelper
) : ComponentWrapper(), PlayComponent {
override suspend fun getPlayInfo(
summary: CartoonSummary,
playLine: PlayLine,
episode: Episode
): SourceResult<PlayerInfo> = withResult(Dispatchers.IO) {
val newHtml = commonHttpClient.newGetRequest {
url("https://danmu.yhdmjx.com/m3u8.php?url=" + extractPlayerParam(episode.id))
}.bodyString()
val btToken = extractBtToken(newHtml)
val encryptedUrl = extractEncryptedUrl(newHtml)
val plainUrl = Cipher.getInstance("AES/CBC/PKCS5Padding").run {
init(
Cipher.DECRYPT_MODE,
SecretKeySpec("57A891D97E332A9D".toByteArray(), "AES"),
IvParameterSpec(btToken.toByteArray(Charsets.UTF_8))
)
doFinal(Base64.decode(encryptedUrl, Base64.DEFAULT))
}.toString(Charsets.UTF_8)
PlayerInfo(
uri = plainUrl
)
}
private fun extractPlayerParam(episodeId: String): String {
val html = commonHttpClient.newGetRequest {
url("${hostUrlHelper.fengcheBaseUrl}/play/$episodeId.html")
}.bodyString()
val startIndex = html.indexOf("player_aaaa")
val startBracketIndex = html.indexOf('{', startIndex + 1)
var endIndex = -1
var bracketCount = 0
for (i in (startBracketIndex + 1)..<html.length) {
val char = html[i]
if (char == '{') {
bracketCount++
} else if (char == '}') {
if (bracketCount == 0) {
endIndex = i
break
}
bracketCount--
}
}
if (endIndex <= startIndex) {
throw RuntimeException("未找到播放信息")
}
return Gson().fromJson<Map<String, String>>(
html.substring(startBracketIndex, endIndex + 1),
Map::class.java
)["url"] ?: throw RuntimeException("未获取到播放信息")
}
private fun extractEncryptedUrl(html: String): String {
val key = "getVideoInfo("
val i1 = html.indexOf(key)
val i2 = html.indexOf('"', i1 + key.length)
val i3 = html.indexOf('"', i2 + 1)
return html.substring(i2 + 1, i3)
}
private fun extractBtToken(html: String): String {
val i1 = html.indexOf("bt_token")
val i2 = html.indexOf('"', i1)
val i3 = html.indexOf('"', i2 + 1)
return html.substring(i2 + 1, i3)
}
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/fengche/FengChePrefer.kt
================================================
package io.github.easybangumiorg.source.aio.fengche
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.preference.PreferenceComponent
import com.heyanle.easybangumi4.source_api.component.preference.SourcePreference
import com.heyanle.easybangumi4.source_api.component.search.SearchComponent
/**
* Created by heyanlin on 2024/5/23.
*/
class FengChePrefer : ComponentWrapper(), PreferenceComponent {
override fun register(): List<SourcePreference> = listOf(
SourcePreference.Switch("自动从 wedm.cc 获取网址", "auto_host_url", true),
SourcePreference.Edit("自定义网址(当自动关闭时才有效)", "BaseUrl", "http://www.fcdm9.com/"),
)
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/fengche/FengCheSearch.kt
================================================
package io.github.easybangumiorg.source.aio.fengche
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.search.SearchComponent
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import com.heyanle.easybangumi4.source_api.withResult
import io.github.easybangumiorg.source.aio.asDocument
import io.github.easybangumiorg.source.aio.commonHttpClient
import io.github.easybangumiorg.source.aio.encodeUri
import io.github.easybangumiorg.source.aio.newGetRequest
import kotlinx.coroutines.Dispatchers
class FengCheSearch(
private val hostUrlHelper: FengCheHostUrlHelper
) : ComponentWrapper(), SearchComponent {
override fun getFirstSearchKey(keyword: String): Int = 1
override suspend fun search(
pageKey: Int,
keyword: String
): SourceResult<Pair<Int?, List<CartoonCover>>> = withResult(Dispatchers.IO) {
val document = commonHttpClient.newGetRequest {
url("${hostUrlHelper.fengcheBaseUrl}/search/${keyword.encodeUri()}----------$pageKey---.html")
}.asDocument()
val videos =
document.select(".sear_con > .reusltbox").map { box->
val link = box.selectFirst("a")!!.absUrl("href")
val img = box.selectFirst(".img_wrapper")?.dataset()?.get("original")
val title = box.selectFirst(".result_title > a")!!.text().trim()
CartoonCoverImpl(
id = link.extractFengCheIdFromUrl(),
source = source.key,
url = link,
title = title,
coverUrl = img
)
}
val nextPage = if (document.hasNextPage() && videos.isNotEmpty()) pageKey + 1 else null
nextPage to videos
}
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/fengche/FengCheSource.kt
================================================
package io.github.easybangumiorg.source.aio.fengche
import com.heyanle.easybangumi4.source_api.Source
import com.heyanle.extension_api.ExtensionIconSource
import org.easybangumi.extension.R
import kotlin.reflect.KClass
class FengCheSource : Source, ExtensionIconSource {
override val describe: String
get() = "风车动漫"
override val key: String
get() = "wedm.cc"
override val label: String
get() = "风车动漫"
override val version: String
get() = "2.1"
override val versionCode: Int
get() = 5
override fun getIconResourcesId(): Int = R.drawable.fengche
override fun register(): List<KClass<*>> = listOf(
FengChePage::class,
FengCheDetail::class,
FengChePlay::class,
FengCheSearch::class,
FengChePrefer::class,
FengCheHostUrlHelper::class
)
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/libvio/LibVioDetail.kt
================================================
package io.github.easybangumiorg.source.aio.libvio
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.detailed.DetailedComponent
import com.heyanle.easybangumi4.source_api.entity.Cartoon
import com.heyanle.easybangumi4.source_api.entity.CartoonImpl
import com.heyanle.easybangumi4.source_api.entity.CartoonSummary
import com.heyanle.easybangumi4.source_api.entity.Episode
import com.heyanle.easybangumi4.source_api.entity.PlayLine
import io.github.easybangumiorg.source.aio.asDocument
import io.github.easybangumiorg.source.aio.map
import io.github.easybangumiorg.source.aio.withIoResult
class LibVioDetail(private val libVioSource: LibVioSource) : ComponentWrapper(), DetailedComponent {
override suspend fun getAll(summary: CartoonSummary): SourceResult<Pair<Cartoon, List<PlayLine>>> =
withIoResult {
val doc = libVioSource.requestWithFunCDNInterceptor {
url("${LibVioSource.BASE_URL}/detail/${summary.id}.html")
get()
}.asDocument()
val playlists = mutableListOf<PlayLine>()
for (playlistEl in doc.select(".stui-vodlist__head > .stui-content__playlist")) {
val name =
playlistEl.previousElementSibling()?.takeIf { it.hasClass("stui-pannel__head") }
?.text()?.trim() ?: continue
if (name.contains("下载") || name.contains("网盘") || name.contains("云盘")) {
continue
}
val episodes = playlistEl.select("a").map { el ->
Episode(
label = el.text(),
order = 0,
id = el.attr("href")
.let { it.substring(it.lastIndexOf('/') + 1, it.lastIndexOf('.')) }
)
}
if (episodes.isEmpty()) {
continue
}
playlists.add(
PlayLine(
id = name,
label = name,
episode = arrayListOf(*episodes.toTypedArray())
)
)
}
val detailContainer =
doc.selectFirst(".stui-content") ?: throw RuntimeException("未找到视频详情")
val img = detailContainer.selectFirst("img")?.dataset()?.get("original") ?: ""
val title = detailContainer.selectFirst(".stui-content__detail > .title")!!.text()
val infos = detailContainer.select(".stui-content__detail > .data").map { it.text() }
val desc =
detailContainer.selectFirst(".stui-content__detail > .desc > .detail-content")
?.text()
?: ""
val cartoon = CartoonImpl(
id = summary.id,
source = libVioSource.key,
title = title,
coverUrl = img,
intro = infos.joinToString(separator = "\n"),
description = desc,
url = "${LibVioSource.BASE_URL}/detail/${summary.id}.html"
)
cartoon to playlists
}
override suspend fun getDetailed(summary: CartoonSummary): SourceResult<Cartoon> =
getAll(summary).map { it.first }
override suspend fun getPlayLine(summary: CartoonSummary): SourceResult<List<PlayLine>> =
getAll(summary).map { it.second }
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/libvio/LibVioPage.kt
================================================
package io.github.easybangumiorg.source.aio.libvio
import android.content.Context
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.page.PageComponent
import com.heyanle.easybangumi4.source_api.component.page.SourcePage
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.utils.api.StringHelper
import com.heyanle.easybangumi4.source_api.withResult
import io.github.easybangumiorg.source.aio.asDocument
import io.github.easybangumiorg.source.aio.withIoResult
class LibVioPage(
private val libVioSource: LibVioSource,
context: Context,
okhttpHelper: OkhttpHelper,
stringHelper: StringHelper
) : ComponentWrapper(), PageComponent {
init {
libVioSource.init(context, okhttpHelper, stringHelper)
}
override fun getPages(): List<SourcePage> {
val pages =
listOf("电影" to "1", "剧集" to "2", "动漫" to "4").map { (groupName, groupKey) ->
SourcePage.Group(label = groupName, newScreen = false) {
withIoResult {
val doc = libVioSource.requestWithFunCDNInterceptor {
url("${LibVioSource.BASE_URL}/type/$groupKey.html")
get()
}.asDocument()
val categories =
listOf("全部" to "") + doc.getElementById("screenbox")!!.child(0)
.children()
.let {
it.subList(1, it.size)
}.map { el ->
val link = el.getElementsByTag("a")[0]
val url = link.attr("href")
val key =
url.substring(
url.lastIndexOf('/') + 1,
url.lastIndexOf('.')
)
.split('-')
.asSequence()
.filter { it.isNotEmpty() }
.last()
link.text().trim() to key
}.distinctBy { it.second }
categories.map { (categoryName, categoryKey) ->
SourcePage.SingleCartoonPage.WithCover(
label = categoryName,
firstKey = { 1 }) { page ->
withIoResult {
loadVideoOfCategory(
groupKey = groupKey,
categoryKey = categoryKey,
page = page
)
}
}
}
}
}
}
return listOf(SourcePage.Group(label = "首页", newScreen = false) {
withIoResult {
val doc = libVioSource.requestWithFunCDNInterceptor {
url(LibVioSource.BASE_URL)
get()
}.asDocument()
val list = mutableListOf<SourcePage.SingleCartoonPage>()
val containers = doc.getElementsByClass("stui-vodlist")
for (container in containers) {
val videoEls = container.select("li > .stui-vodlist__box")
if (videoEls.isEmpty()) {
break
}
val groupName =
container.previousElementSibling()
?.takeIf { it.hasClass("stui-vodlist__head") }
?.selectFirst("h3")?.text()?.trim() ?: "推荐视频"
val videos = videoEls.map { libVioSource.parseLibVioVideo(it) }
val page = SourcePage.SingleCartoonPage.WithCover(
label = groupName,
firstKey = { 0 }) {
withResult {
null to videos
}
}
list.add(page)
}
list
}
}) + pages
}
private suspend fun loadVideoOfCategory(
groupKey: String,
categoryKey: String,
page: Int
): Pair<Int?, List<CartoonCover>> {
val doc = libVioSource.requestWithFunCDNInterceptor {
url("${LibVioSource.BASE_URL}/show/$groupKey--time-$categoryKey-----$page---.html")
get()
}.asDocument()
return libVioSource.parseVideoPage(doc, page)
}
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/libvio/LibVioPlay.kt
================================================
package io.github.easybangumiorg.source.aio.libvio
import android.util.Log
import com.google.gson.Gson
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.play.PlayComponent
import com.heyanle.easybangumi4.source_api.entity.CartoonSummary
import com.heyanle.easybangumi4.source_api.entity.Episode
import com.heyanle.easybangumi4.source_api.entity.PlayLine
import com.heyanle.easybangumi4.source_api.entity.PlayerInfo
import io.github.easybangumiorg.source.aio.bodyString
import io.github.easybangumiorg.source.aio.decodeUri
import io.github.easybangumiorg.source.aio.encodeUri
import io.github.easybangumiorg.source.aio.newGetRequest
import io.github.easybangumiorg.source.aio.withIoResult
import java.net.URI
import java.util.concurrent.ConcurrentHashMap
import kotlin.io.encoding.Base64
import kotlin.io.encoding.ExperimentalEncodingApi
class LibVioPlay(private val libVioSource: LibVioSource) : ComponentWrapper(), PlayComponent {
private val playerServerCache = ConcurrentHashMap<String, String>()
@OptIn(ExperimentalEncodingApi::class)
override suspend fun getPlayInfo(
summary: CartoonSummary,
playLine: PlayLine,
episode: Episode
): SourceResult<PlayerInfo> = withIoResult {
val html = libVioSource.requestWithFunCDNInterceptor {
url("${LibVioSource.BASE_URL}/play/${episode.id}.html")
get()
}.bodyString()
val keyword = "player_aaaa"
val startIndex = html.indexOf(keyword)
if (startIndex == -1) {
throw RuntimeException("未获取到视频播放信息")
}
val configStartIndex = html.indexOf('{', startIndex = startIndex + keyword.length)
val configJson =
html.substring(
configStartIndex,
html.indexOf('}', startIndex = configStartIndex + 1) + 1
)
val cfg = Gson().fromJson<Map<String, Any>>(configJson, Map::class.java)
val encryptMode = cfg["encrypt"]?.toString() ?: ""
val url = cfg["url"]?.toString()?.takeIf { it.isNotEmpty() }
?: throw RuntimeException("播放信息中无url")
val nextLink = cfg["link_next"]?.toString()?.encodeUri() ?: ""
val data = when (encryptMode) {
"1" -> url.decodeUri()
"2" -> Base64.decode(url).toString(Charsets.UTF_8).decodeUri()
else -> url
}
val playFrom = cfg["from"]?.toString()?.takeIf { it.isNotEmpty() }
?: throw RuntimeException("播放器配置中无from属性")
var playerServer = playerServerCache[playFrom]
if (playerServer?.isNotEmpty() != true) {
val jsContent = libVioSource.requestWithFunCDNInterceptor {
url("${LibVioSource.BASE_URL}/static/player/${playFrom}.js?v=3.5")
}.bodyString()
playerServer = parseServerFromJs(jsContent)
if (!playerServer.startsWith("http:") && !playerServer.startsWith("https")) {
playerServer = LibVioSource.BASE_URL + playerServer
}
playerServerCache[playFrom] = playerServer
}
Log.d(TAG, "getPlayInfo: $playerServer")
val playerHtml =
libVioSource.httpClient.newGetRequest {
url("$playerServer?url=$data&next=$nextLink&id=${summary.id}&nid=${cfg["nid"]}")
header("referer", "${LibVioSource.BASE_URL}/")
}.bodyString()
val videoUrl = getStringVariableValue(html = playerHtml, variableName = "urls")
?: throw RuntimeException("未获取到视频链接")
PlayerInfo(uri = videoUrl)
}
private fun parseServerFromJs(jsContent: String): String {
val keyword = " src="
val idx = jsContent.indexOf(keyword)
if (idx == -1) {
throw RuntimeException("js中无src")
}
var startIndex = -1
var endIndex = -1
for (i in (keyword.length + idx) until jsContent.length) {
val c = jsContent[i]
if (c == '"' || c == '\'') {
if (startIndex == -1) {
startIndex = i + 1
} else {
endIndex = i
break
}
}
}
if (startIndex >= endIndex) {
throw RuntimeException("提前src失败")
}
return jsContent.substring(startIndex, endIndex).run {
val questionIndex = indexOf('?')
if (questionIndex == -1) {
this
} else {
substring(0, questionIndex)
}
}
}
private fun getStringVariableValue(html: String, variableName: String): String? {
val keyword = "var $variableName"
val index = html.indexOf(keyword)
if (index == -1) {
return null
}
var startIndex = -1
var quote = '"'
var endIndex = -1
for (i in (index + keyword.length) until html.length) {
val c = html[i]
if (startIndex == -1 && (c == '\'' || c == '"')) {
startIndex = i + 1
quote = c
continue
}
if (startIndex != -1 && c == quote) {
endIndex = i
break
}
}
if (startIndex < endIndex) {
return html.substring(startIndex, endIndex)
}
return null
}
companion object{
private const val TAG = "LibVioPlay"
}
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/libvio/LibVioSearch.kt
================================================
package io.github.easybangumiorg.source.aio.libvio
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.search.SearchComponent
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import io.github.easybangumiorg.source.aio.asDocument
import io.github.easybangumiorg.source.aio.encodeUri
import io.github.easybangumiorg.source.aio.withIoResult
class LibVioSearch(
private val libVioSource: LibVioSource
) : ComponentWrapper(), SearchComponent {
override fun getFirstSearchKey(keyword: String): Int = 1
override suspend fun search(
pageKey: Int,
keyword: String
): SourceResult<Pair<Int?, List<CartoonCover>>> = withIoResult {
val doc = libVioSource.requestWithFunCDNInterceptor {
url("${LibVioSource.BASE_URL}/search/${keyword.encodeUri()}----------$pageKey---.html")
}.asDocument()
libVioSource.parseVideoPage(doc, pageKey)
}
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/libvio/LibVioSource.kt
================================================
package io.github.easybangumiorg.source.aio.libvio
import android.content.Context
import android.os.Build
import android.os.Handler
import android.util.Log
import android.webkit.CookieManager
import android.webkit.WebView
import android.webkit.WebViewClient
import com.heyanle.easybangumi4.source_api.Source
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.utils.api.StringHelper
import com.heyanle.easybangumi4.source_api.utils.core.setDefaultSettings
import com.heyanle.extension_api.BuildConfig
import com.heyanle.extension_api.ExtensionIconSource
import com.heyanle.extension_api.ExtensionSource
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.withContext
import kotlinx.coroutines.withTimeout
import okhttp3.Call
import okhttp3.Callback
import okhttp3.Cookie
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import org.easybangumi.extension.R
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import java.io.IOException
import java.util.concurrent.Executor
import java.util.concurrent.RejectedExecutionException
import kotlin.reflect.KClass
import kotlin.time.Duration.Companion.seconds
class LibVioSource : Source,
ExtensionIconSource {
override val describe: String
get() = label
override val label: String
get() = "LIBVIO"
override val key: String
get() = "libvio"
override val version: String
get() = "1.0"
override val versionCode: Int
get() = 1
override fun getIconResourcesId(): Int = R.drawable.libvio
override fun register(): List<KClass<*>> =
listOf(LibVioPage::class, LibVioPlay::class, LibVioSearch::class, LibVioDetail::class)
private lateinit var context: Context
lateinit var httpClient: OkHttpClient
private set
private var cookieManager = CookieManager.getInstance()
private lateinit var executor: Executor
private lateinit var stringHelper: StringHelper
fun init(
context: Context,
okhttpHelper: OkhttpHelper,
stringHelper: StringHelper
) {
this.context = context
this.stringHelper = stringHelper
httpClient = okhttpHelper.client
executor = if (Build.VERSION.SDK_INT >= 28) {
context.mainExecutor
} else {
val handler = Handler(context.mainLooper)
Executor { command ->
if (!handler.post(command)) {
throw RejectedExecutionException("$handler is shutting down")
}
}
}
}
private suspend fun CookieManager.removeAllCookie(url: String) {
val cookieStr = getCookie(url)?.takeIf { it.isNotEmpty() } ?: return
val httpUrl = url.toHttpUrl()
val host = url.toHttpUrl().host
val cookieNames = cookieStr.split(";").asSequence()
.map { Cookie.parse(httpUrl, it)?.name }
.filterNotNull()
.toList()
if (cookieNames.isEmpty()) {
return
}
val defList = List(cookieNames.size) { CompletableDeferred<Pair<String, Boolean>>() }
withContext(Dispatchers.Main) {
cookieNames.forEachIndexed { index, cookieName ->
setCookie(host, "$cookieName=; path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT") {
defList[index].complete(cookieName to it)
}
}
flush()
}
val removeSuccess = defList.awaitAll()
removeSuccess.forEach { (name, success) ->
Log.d(TAG, "removeAllCookie: $name success: $success")
}
}
suspend fun requestWithFunCDNInterceptor(block: Request.Builder.() -> Unit): Response {
val req = Request.Builder().apply(block).build()
val resp = httpClient.executeRequestSuspend(req)
if (resp.code != 512) {
return resp
}
resp.close()
stringHelper.moeSnackBar("正在进行FunCDN检测,请耐心等待")
val requestUrl = resp.request.url.toString()
Log.d(
TAG,
"requestWithFunCDNInterceptor: oldCookie:${cookieManager.getCookie(requestUrl)}"
)
cookieManager.removeAllCookie(BASE_URL)
Log.d(
TAG,
"requestWithFunCDNInterceptor: oldCookie:${cookieManager.getCookie(requestUrl)}"
)
val cookieName = "_funcdn_token"
val cookieDef = CompletableDeferred<Unit>()
val webView: WebView = withContext(Dispatchers.Main) {
WebView(context).apply {
setDefaultSettings()
settings.userAgentString = resp.request.header("user-agent")
webViewClient = object : WebViewClient() {
override fun onPageFinished(view: WebView?, url: String) {
Log.d(TAG, "onPageFinished: $url")
if (url != requestUrl) {
return
}
val cookieStr = cookieManager.getCookie(requestUrl)
Log.d(TAG, "onPageFinished: $cookieStr")
if (cookieStr?.isNotEmpty() == true) {
val found = cookieStr.split(";")
.any {
val ck = Cookie.parse(resp.request.url, it)
if (BuildConfig.DEBUG) {
Log.d(TAG, "webViewCookie: $it")
}
ck != null && ck.name == cookieName && ck.value.isNotEmpty()
}
if (found) {
cookieDef.complete(Unit)
}
}
}
}
loadUrl(requestUrl)
}
}
try {
withTimeout(60.seconds) {
cookieDef.await()
}
} finally {
executor.execute {
with(webView) {
stopLoading()
destroy()
}
}
}
return httpClient.executeRequestSuspend(req)
}
private suspend fun OkHttpClient.executeRequestSuspend(req: Request): Response {
val def = CompletableDeferred<Result<Response>>()
newCall(req).enqueue(object : Callback {
override fun onFailure(call: Call, e: IOException) {
def.complete(Result.failure(e))
}
override fun onResponse(call: Call, response: Response) {
def.complete(Result.success(response))
}
})
return def.await().getOrThrow()
}
fun parseLibVioVideo(videoEl: Element): CartoonCover {
val linkEl =
videoEl.selectFirst(".stui-vodlist__thumb") ?: throw RuntimeException("未找到视频图片")
val image = linkEl.dataset()["original"] ?: ""
val url = linkEl.absUrl("href")
val episode = linkEl.selectFirst(".pic-text")?.text() ?: ""
val title =
videoEl.selectFirst(".stui-vodlist__detail > .title")?.text()?.trim()
?: throw RuntimeException(
"未找到视频标题"
)
return CartoonCoverImpl(
id = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.')),
url = url,
source = key,
title = title,
intro = episode,
coverUrl = image
)
}
fun parseVideoPage(doc: Document, page: Int): Pair<Int?, List<CartoonCover>> {
val videos = doc.select(".stui-vodlist .stui-vodlist__box").map { parseLibVioVideo(it) }
val next = if (haveNextPage(doc)) page + 1 else null
return next to videos
}
private fun haveNextPage(doc: Document): Boolean {
val pageEls = doc.select(".stui-pannel__ft > .stui-page__item > li")
val currentIndex = pageEls.indexOfFirst { it.hasClass("active") }
return currentIndex != -1 && currentIndex < pageEls.size - 4
}
companion object {
private const val TAG = "LibVioSource"
const val BASE_URL = "https://www.libvio.fun"
}
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/xigua/Common.kt
================================================
package io.github.easybangumiorg.source.aio.xigua
const val XiguaBaseUrl = "https://cn.xgcartoon.com"
fun String.extractXiguaIdFromUrl() = this.substring(this.lastIndexOf('/') + 1)
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/xigua/XiGuaPage.kt
================================================
package io.github.easybangumiorg.source.aio.xigua
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.page.PageComponent
import com.heyanle.easybangumi4.source_api.component.page.SourcePage
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import com.heyanle.easybangumi4.source_api.withResult
import io.github.easybangumiorg.source.aio.asDocument
import io.github.easybangumiorg.source.aio.commonHttpClient
import io.github.easybangumiorg.source.aio.encodeUri
import io.github.easybangumiorg.source.aio.newGetRequest
import io.github.easybangumiorg.source.aio.readJson
import kotlinx.coroutines.Dispatchers
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
class XiGuaPage : ComponentWrapper(), PageComponent {
override fun getPages(): List<SourcePage> {
val home = SourcePage.Group(label = "首页", newScreen = false) {
withResult(Dispatchers.IO) {
val doc = commonHttpClient.newGetRequest { url(XiguaBaseUrl) }.asDocument()
val result = mutableListOf<SourcePage.SingleCartoonPage>()
doc.select("#index .index-hot").forEach { hot ->
val title = hot.child(0).text()
val videos = hot.select(".index-hot-item > .box").map { box ->
val linkEl = box.selectFirst(".title")!!
val url = linkEl.absUrl("href")
val name = linkEl.text().trim()
val id = url.extractXiguaIdFromUrl()
CartoonCoverImpl(
id = id,
source = source.key,
url = url,
title = name,
intro = box.selectFirst(".info")?.text(),
coverUrl = "https://static-a.xgcartoon.com/cover/$id.jpg"
)
}
if (videos.isNotEmpty()) {
val page = SourcePage.SingleCartoonPage.WithCover(
label = title,
firstKey = { 0 }) {
withResult {
null to videos
}
}
result.add(page)
}
}
val recommendPages =
doc.select("#index > .index-category > .catelog").map { category ->
val videos = mutableListOf<CartoonCover>()
val title = category.selectFirst(".head")!!.text()
category.selectFirst(".top-item")?.let { item ->
val linkEl = item.selectFirst("a")!!
val url = linkEl.absUrl("href")
val name = item.selectFirst(".info > .title")!!.text()
val id = url.extractXiguaIdFromUrl()
CartoonCoverImpl(
id = id,
source = source.key,
url = url,
title = name,
intro = item.selectFirst(".info > .author")?.text(),
coverUrl = "https://static-a.xgcartoon.com/cover/$id.jpg"
).run {
videos.add(this)
}
}
category.select(".list > a").forEach { linkEl ->
val url = linkEl.absUrl("href")
val infoEls = linkEl.selectFirst(".topic-info")!!.children()
val id = url.extractXiguaIdFromUrl()
CartoonCoverImpl(
id = id,
source = source.key,
url = url,
title = infoEls[0].text().trim(),
intro = infoEls.getOrNull(1)?.text(),
coverUrl = "https://static-a.xgcartoon.com/cover/$id.jpg"
).run {
videos.add(this)
}
}
SourcePage.SingleCartoonPage.WithCover(label = title, firstKey = { 0 }) {
withResult {
null to videos
}
}
}
result.addAll(recommendPages)
result
}
}
val categoryPage = SourcePage.Group("分类导航", false) {
withResult(Dispatchers.IO) {
val categoryDoc = commonHttpClient.newGetRequest {
url("$XiguaBaseUrl/classify?type=")
}.asDocument()
categoryDoc.select("#classify .filter-type > .filter-item > a")
.asSequence()
.map { linkEl ->
val url = linkEl.attr("href")
val paramNameAndValue =
url.substring(url.indexOf('?') + 1, url.indexOf('&')).split('=')
linkEl.text().trim() to (paramNameAndValue.getOrNull(1) ?: "")
}
.filter { it.second.isNotEmpty() }
.map { (pageLabel, filterType) ->
SourcePage.SingleCartoonPage.WithCover(pageLabel, { 1 }) { page ->
withResult(Dispatchers.IO) {
queryVideoOfCategory(filterType, page)
}
}
}
.toList()
}
}
return listOf(home, categoryPage)
}
private fun queryVideoOfCategory(category: String, page: Int): Pair<Int?, List<CartoonCover>> {
val star = "*".encodeUri()
val resp = commonHttpClient.newGetRequest {
url("$XiguaBaseUrl/api/amp_query_cartoon_list?type=$category®ion=$star&filter=$star&page=$page&limit=36&language=cn&__amp_source_origin=${XiguaBaseUrl.encodeUri()}")
}
.readJson<CategoryResponse>()
val videos = resp.items.map { item ->
CartoonCoverImpl(
id = item.id,
source = source.key,
url = "$XiguaBaseUrl/detail/${item.id}",
title = item.name,
intro = (listOf(item.regionName, item.author) + item.typeNames).asSequence()
.filter { it.isNotEmpty() }.joinToString(separator = " "),
coverUrl = item.topicImg.takeIf { it.isNotEmpty() }
?.let { "https://static-a.xgcartoon.com/cover/${item.topicImg}" }
)
}
val nextPage = if (resp.next.isNotEmpty()) page + 1 else null
return nextPage to videos
}
@Serializable
data class CategoryResponse(
val items: List<CategoryVideoItem> = emptyList(),
val next: String = ""
)
@Serializable
data class CategoryVideoItem(
@SerialName("cartoon_id")
val id: String,
val name: String,
val region: String = "",
val author: String = "",
@SerialName("region_name")
val regionName: String = "",
@SerialName("topic_img")
val topicImg: String = "",
@SerialName("type_names")
val typeNames: List<String> = emptyList(),
)
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/xigua/XiguaDetail.kt
================================================
package io.github.easybangumiorg.source.aio.xigua
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.detailed.DetailedComponent
import com.heyanle.easybangumi4.source_api.entity.Cartoon
import com.heyanle.easybangumi4.source_api.entity.CartoonImpl
import com.heyanle.easybangumi4.source_api.entity.CartoonSummary
import com.heyanle.easybangumi4.source_api.entity.Episode
import com.heyanle.easybangumi4.source_api.entity.PlayLine
import com.heyanle.easybangumi4.source_api.withResult
import io.github.easybangumiorg.source.aio.asDocument
import io.github.easybangumiorg.source.aio.commonHttpClient
import io.github.easybangumiorg.source.aio.map
import io.github.easybangumiorg.source.aio.newGetRequest
import kotlinx.coroutines.Dispatchers
class XiguaDetail : ComponentWrapper(), DetailedComponent {
override suspend fun getAll(summary: CartoonSummary): SourceResult<Pair<Cartoon, List<PlayLine>>> {
return withResult(Dispatchers.IO) {
val doc = commonHttpClient.newGetRequest {
url("$XiguaBaseUrl/detail/${summary.id}")
}.asDocument()
val detailContainer = doc.selectFirst(".detail-right")!!
val name = detailContainer.selectFirst(".detail-right__title")!!.text()
val tags = detailContainer.select(".detail-right__tags .tag").map { it.text() }
val desc =
detailContainer.selectFirst(".detail-right__desc")?.children()?.last()?.text()
val cartoon = CartoonImpl(
id = summary.id,
source = source.key,
url = "$XiguaBaseUrl/detail/${summary.id}",
title = name,
genre = tags.joinToString(" "),
coverUrl = "https://static-a.xgcartoon.com/cover/${summary.id}.jpg",
description = desc
)
val playlists = mutableListOf<PlayLine>()
var currentEpisodes = arrayListOf<Episode>()
var playLineId = 0
detailContainer.selectFirst(".detail-right__volumes")?.lastElementChild()?.children()
?.forEach { element ->
if (element.hasClass("volume-title")) {
currentEpisodes = arrayListOf()
playlists.add(
PlayLine(
(playLineId++).toString(),
label = element.text(),
currentEpisodes
)
)
} else {
val linkEl = element.selectFirst("a")!!
currentEpisodes.add(
Episode(
id = linkEl.attr("href").let {
it.substring(it.lastIndexOf('=') + 1)
},
label = linkEl.text(),
order = 0
)
)
}
}
cartoon to playlists
}
}
override suspend fun getDetailed(summary: CartoonSummary): SourceResult<Cartoon> {
return getAll(summary).map { it.first }
}
override suspend fun getPlayLine(summary: CartoonSummary): SourceResult<List<PlayLine>> {
return getAll(summary).map { it.second }
}
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/xigua/XiguaPlay.kt
================================================
package io.github.easybangumiorg.source.aio.xigua
import com.heyanle.easybangumi4.source_api.ParserException
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.play.PlayComponent
import com.heyanle.easybangumi4.source_api.entity.CartoonSummary
import com.heyanle.easybangumi4.source_api.entity.Episode
import com.heyanle.easybangumi4.source_api.entity.PlayLine
import com.heyanle.easybangumi4.source_api.entity.PlayerInfo
import com.heyanle.easybangumi4.source_api.withResult
import io.github.easybangumiorg.source.aio.asDocument
import io.github.easybangumiorg.source.aio.commonHttpClient
import io.github.easybangumiorg.source.aio.newGetRequest
import kotlinx.coroutines.Dispatchers
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
class XiguaPlay : PlayComponent, ComponentWrapper() {
override suspend fun getPlayInfo(
summary: CartoonSummary,
playLine: PlayLine,
episode: Episode
): SourceResult<PlayerInfo> {
val url = "$XiguaBaseUrl/video/${summary.id}/${episode.id}.html"
return withResult(Dispatchers.IO) {
val doc = commonHttpClient.newGetRequest {
url(url)
}.asDocument()
val iframe =
doc.selectFirst("#video_content iframe")
?: throw ParserException("未获取到播放器")
val iframeSrc = iframe.attr("src")
if (iframeSrc.isEmpty()) {
throw ParserException("未获取到播放器链接")
}
val vid = iframeSrc.toHttpUrlOrNull()?.queryParameter("vid")
val videoUrl = if (vid != null) {
"https://xgct-video.vzcdn.net/$vid/playlist.m3u8"
} else {
commonHttpClient.newGetRequest { url(iframeSrc) }.asDocument()
.getElementsByTag("source")
.firstOrNull()
?.attr("src")
?.takeIf { it.isNotEmpty() }
?: throw RuntimeException("未获取到video source")
}
PlayerInfo(
decodeType = PlayerInfo.DECODE_TYPE_HLS,
uri = videoUrl
)
}
}
companion object {
private const val TAG = "XiguaPlay"
}
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/xigua/XiguaSearch.kt
================================================
package io.github.easybangumiorg.source.aio.xigua
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.search.SearchComponent
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import com.heyanle.easybangumi4.source_api.withResult
import io.github.easybangumiorg.source.aio.asDocument
import io.github.easybangumiorg.source.aio.commonHttpClient
import io.github.easybangumiorg.source.aio.encodeUri
import io.github.easybangumiorg.source.aio.newGetRequest
import kotlinx.coroutines.Dispatchers
class XiguaSearch : ComponentWrapper(), SearchComponent {
override fun getFirstSearchKey(keyword: String): Int = 0
override suspend fun search(
pageKey: Int,
keyword: String
): SourceResult<Pair<Int?, List<CartoonCover>>> = withResult(Dispatchers.IO) {
val doc = commonHttpClient.newGetRequest {
url("$XiguaBaseUrl/search?q=${keyword.encodeUri()}")
}.asDocument()
val videos =
doc.select("#layout > .container.search > .topic-list > .topic-list-box").map { box ->
val url = box.selectFirst("a")!!.absUrl("href")
val id = url.extractXiguaIdFromUrl()
val tags =
box.select(".topic-tag .tag").asSequence().map { it.text() }.toMutableList()
val infoList = box.selectFirst(".topic-list-item__info")!!.children()
val name = infoList.last()!!.text()
if (infoList.size > 1) {
tags.add(infoList[0].text())
}
CartoonCoverImpl(
id = id,
source = source.key,
url = url,
title = name,
intro = tags.joinToString(" "),
coverUrl = "https://static-a.xgcartoon.com/cover/$id.jpg"
)
}
null to videos
}
}
================================================
FILE: extension-app/src/main/java/io/github/easybangumiorg/source/aio/xigua/XiguaSource.kt
================================================
package io.github.easybangumiorg.source.aio.xigua
import com.heyanle.easybangumi4.source_api.Source
import com.heyanle.extension_api.ExtensionIconSource
import org.easybangumi.extension.R
import kotlin.reflect.KClass
class XiguaSource : Source, ExtensionIconSource {
override val describe: String
get() = "西瓜卡通"
override val key: String
get() = "xgcartoon"
override val label: String
get() = "西瓜卡通"
override val version: String
get() = "2.0"
override val versionCode: Int
get() = 4
override fun getIconResourcesId(): Int = R.drawable.xigua
override fun register(): List<KClass<*>> {
return listOf(
XiGuaPage::class,
XiguaDetail::class,
XiguaPlay::class,
XiguaSearch::class
)
}
}
================================================
FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mikudm/MikudmApiSource.kt
================================================
package io.github.peacefulprogram.easybangumi_mikudm
import com.heyanle.easybangumi4.source_api.Source
import com.heyanle.extension_api.ExtensionIconSource
import com.heyanle.extension_api.ExtensionSource
import org.easybangumi.extension.R
import kotlin.reflect.KClass
class MikudmApiSource : Source, ExtensionIconSource {
override val describe: String
get() = label
override val label: String
get() = "异世界动漫"
override val version: String
get() = "2.0"
override val versionCode: Int
get() = 2
override fun getIconResourcesId(): Int = R.drawable.mikudm
override val key: String
get() = "io.github.peacefulprogram.easybangumi_mikudm-io.github.peacefulprogram.easybangumi_mikudm"
override fun register(): List<KClass<*>> {
return listOf(
MikudmPageComponent::class,
MikudmSearchComponent::class,
MikudmDetailComponent::class,
MikudmPlayComponent::class,
MikudmPreferenceComponent::class,
MikudmUtil::class
)
}
}
================================================
FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mikudm/MikudmDetailComponent.kt
================================================
package io.github.peacefulprogram.easybangumi_mikudm
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.detailed.DetailedComponent
import com.heyanle.easybangumi4.source_api.entity.Cartoon
import com.heyanle.easybangumi4.source_api.entity.CartoonImpl
import com.heyanle.easybangumi4.source_api.entity.CartoonSummary
import com.heyanle.easybangumi4.source_api.entity.Episode
import com.heyanle.easybangumi4.source_api.entity.PlayLine
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.withResult
import kotlinx.coroutines.Dispatchers
import org.jsoup.Jsoup
class MikudmDetailComponent(
private val okhttpHelper: OkhttpHelper,
private val mikudmUtil: MikudmUtil,
) : ComponentWrapper(), DetailedComponent {
override suspend fun getAll(summary: CartoonSummary): SourceResult<Pair<Cartoon, List<PlayLine>>> =
withResult(Dispatchers.IO) {
getVideoDetail(summary.id)
}
override suspend fun getDetailed(summary: CartoonSummary): SourceResult<Cartoon> =
withResult(Dispatchers.IO) {
getVideoDetail(summary.id).first
}
override suspend fun getPlayLine(summary: CartoonSummary): SourceResult<List<PlayLine>> =
withResult(Dispatchers.IO) {
getVideoDetail(summary.id).second
}
private fun getVideoDetail(videoId: String): Pair<Cartoon, List<PlayLine>> {
val document =
Jsoup.parse(
mikudmUtil.getDocument(okhttpHelper, "/index.php/vod/detail/id/$videoId.html"),
mikudmUtil.BASE_URL
)
val detailContainer = document.selectFirst(".detail_list")!!
val videoTitle = detailContainer.selectFirst(".content_detail .title")!!.text().trim()
val desc = detailContainer.selectFirst(".desc")?.text()
val coverUrl = detailContainer.selectFirst(".vodlist_thumb")?.run {
mikudmUtil.extractImageSrc(this)
}
val cartoon = CartoonImpl(
id = videoId,
source = source.key,
url = "${mikudmUtil.BASE_URL}/index.php/vod/detail/id/$videoId.html",
title = videoTitle,
coverUrl = coverUrl,
description = desc
)
val episodeList = (document.select(".content_playlist").last()?.let { playlist ->
playlist.getElementsByTag("a").map { it.text().trim() }
} ?: emptyList())
val ep = arrayListOf<Episode>()
for (s in episodeList.indices) {
val d = episodeList[s]
ep.add(Episode(s.toString(), d, s))
}
return cartoon to DetailedComponent.NonPlayLine(
PlayLine(
id = "1",
label = "异世界动漫",
episode = ep
)
)
}
}
================================================
FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mikudm/MikudmPageComponent.kt
================================================
package io.github.peacefulprogram.easybangumi_mikudm
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.page.PageComponent
import com.heyanle.easybangumi4.source_api.component.page.SourcePage
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import com.heyanle.easybangumi4.source_api.utils.api.NetworkHelper
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.withResult
import kotlinx.coroutines.Dispatchers
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
class MikudmPageComponent(
private val okhttpHelper: OkhttpHelper,
private val mikudmUtil: MikudmUtil,
) : ComponentWrapper(), PageComponent {
override fun getPages(): List<SourcePage> {
val pages = mutableListOf<SourcePage>()
val homePage = SourcePage.Group("首页", false) {
withResult(Dispatchers.IO) {
parseHomePage(Jsoup.parse(mikudmUtil.getDocument(okhttpHelper, "/"), mikudmUtil.BASE_URL))
}
}
pages.add(homePage)
listOf(
22 to "新番",
20 to "完结"
).forEach { (typeId, typeName) ->
val page = SourcePage.SingleCartoonPage.WithCover(typeName, { 1 }) { page ->
withResult(Dispatchers.IO) {
buildPageOfType(typeId, page)
}
}
pages.add(page)
}
return pages
}
private fun buildPageOfType(typeId: Int, page: Int): Pair<Int?, List<CartoonCover>> {
val document = Jsoup.parse(
mikudmUtil.getDocument(okhttpHelper, "/index.php/vod/type/id/$typeId/page/$page.html"),
mikudmUtil.BASE_URL
)
val videos = document.select(".vodlist_item").map { it.parseToCartoon() }
val nextPage =
if (mikudmUtil.hasNextPage(document) && videos.isNotEmpty()) page + 1 else null
return nextPage to videos
}
private fun parseHomePage(document: Document): List<SourcePage.SingleCartoonPage> {
val result = mutableListOf<SourcePage.SingleCartoonPage>()
document.select(".vod_row .pannel").forEach { videoGroupContainer ->
val groupTitle =
videoGroupContainer.selectFirst(".title")!!.textNodes().last().text().trim()
if (groupTitle.contains("福利")) {
return@forEach
}
val videos = videoGroupContainer.select(".vodlist_item").map { it.parseToCartoon() }
val page = SourcePage.SingleCartoonPage.WithCover(groupTitle, { 0 }) {
withResult {
null to videos
}
}
result.add(page)
}
return result
}
private fun Element.parseToCartoon(): CartoonCover {
val linkEl = this.selectFirst("a")!!
val url = linkEl.absUrl("href")
val coverUrl = mikudmUtil.extractImageSrc(linkEl)
val title = this.selectFirst(".vodlist_title")!!.text().trim()
val episode = this.selectFirst(".pic_text")?.text()?.trim()
return CartoonCoverImpl(
id = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.')),
source = source.key,
url = url,
title = title,
intro = episode,
coverUrl = coverUrl
)
}
}
================================================
FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mikudm/MikudmPlayComponent.kt
================================================
package io.github.peacefulprogram.easybangumi_mikudm
import android.util.Base64
import com.google.gson.Gson
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.play.PlayComponent
import com.heyanle.easybangumi4.source_api.entity.CartoonSummary
import com.heyanle.easybangumi4.source_api.entity.Episode
import com.heyanle.easybangumi4.source_api.entity.PlayLine
import com.heyanle.easybangumi4.source_api.entity.PlayerInfo
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.utils.api.WebViewHelper
import com.heyanle.easybangumi4.source_api.utils.core.SourceUtils
import com.heyanle.easybangumi4.source_api.withResult
import kotlinx.coroutines.Dispatchers
import javax.crypto.Cipher
import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec
class MikudmPlayComponent(
private val okhttpHelper: OkhttpHelper,
private val mikudmUtil: MikudmUtil,
private val webViewHelper: WebViewHelper,
) : ComponentWrapper(), PlayComponent {
override suspend fun getPlayInfo(
summary: CartoonSummary,
playLine: PlayLine,
episode: Episode,
): SourceResult<PlayerInfo> = withResult(Dispatchers.IO) {
// val url = SourceUtils.urlParser(mikudmUtil.BASE_URL, "/index.php/vod/play/id/${summary.id}/sid/${playLine.id}/nid/${(episode.id.toIntOrNull() ?: episode.order) + 1}.html")
// val playerUrl = webViewHelper.interceptResource(
// url,
// "https://json.mmiku.net/jsonapi.php?.*",
// userAgentString = mikudmUtil.USER_AGENT
// )
val html =
mikudmUtil.getDocument(okhttpHelper, "/index.php/vod/play/id/${summary.id}/sid/${playLine.id}/nid/${(episode.id.toIntOrNull() ?: episode.order) + 1}.html")
val newHtml =
mikudmUtil.getDocument(
okhttpHelper, "${mikudmUtil.BASE_M3U8_URL}/m3u8.php?url=" + extractPlayerParam(
html
)
)
val leToken = extractLeToken(newHtml)
val encryptedUrl = extractEncryptedUrl(newHtml)
val plainUrl = Cipher.getInstance("AES/CBC/PKCS5Padding").run {
init(
Cipher.DECRYPT_MODE,
SecretKeySpec("A42EAC0C2B408472".toByteArray(), "AES"),
IvParameterSpec(leToken.toByteArray(Charsets.UTF_8))
)
doFinal(Base64.decode(encryptedUrl, Base64.DEFAULT))
}.toString(Charsets.UTF_8)
PlayerInfo(uri = plainUrl, decodeType = PlayerInfo.DECODE_TYPE_HLS).apply {
header = mapOf("User-Agent" to mikudmUtil.USER_AGENT)
}
}
private fun extractPlayerParam(html: String): String {
val startIndex = html.indexOf("player_aaaa")
val startBracketIndex = html.indexOf('{', startIndex + 1)
var endIndex = -1
var bracketCount = 0
for (i in (startBracketIndex + 1)..<html.length) {
val char = html[i]
if (char == '{') {
bracketCount++
} else if (char == '}') {
if (bracketCount == 0) {
endIndex = i
break
}
bracketCount--
}
}
if (endIndex <= startIndex) {
throw RuntimeException("未找到播放信息")
}
return Gson().fromJson<Map<String, String>>(
html.substring(startBracketIndex, endIndex + 1),
Map::class.java
)["url"] ?: throw RuntimeException("未获取到播放信息")
}
fun extractEncryptedUrl(html: String): String {
val key = "getVideoInfo("
val i1 = html.indexOf(key)
val i2 = html.indexOf('"', i1 + key.length)
val i3 = html.indexOf('"', i2 + 1)
return html.substring(i2 + 1, i3)
}
fun extractLeToken(html: String): String {
val i1 = html.indexOf("le_token")
val i2 = html.indexOf('"', i1)
val i3 = html.indexOf('"', i2 + 1)
return html.substring(i2 + 1, i3)
}
}
================================================
FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mikudm/MikudmPreferenceComponent.kt
================================================
package io.github.peacefulprogram.easybangumi_mikudm
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.preference.PreferenceComponent
import com.heyanle.easybangumi4.source_api.component.preference.SourcePreference
/**
* Created by heyanle on 2024/6/9.
* https://github.com/heyanLE
*/
class MikudmPreferenceComponent : ComponentWrapper(), PreferenceComponent {
override fun register(): List<SourcePreference> = listOf(
SourcePreference.Edit("异世界动漫网址", "BaseUrl", "https://www.dmmiku.com"),
SourcePreference.Edit("异世界动漫视频 M3U8 网址", "BaseM3u8Url", "https://bf.mmiku.net"),
)
override fun needMigrate(oldVersionCode: Int): Boolean {
return false
}
}
================================================
FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mikudm/MikudmSearchComponent.kt
================================================
package io.github.peacefulprogram.easybangumi_mikudm
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.search.SearchComponent
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.utils.api.WebViewHelper
import com.heyanle.easybangumi4.source_api.withResult
import kotlinx.coroutines.Dispatchers
import org.jsoup.Jsoup
import java.net.URLEncoder
class MikudmSearchComponent(
private val okhttpHelper: OkhttpHelper,
private val mikudmUtil: MikudmUtil,
) : ComponentWrapper(), SearchComponent {
override fun getFirstSearchKey(keyword: String): Int = 1
override suspend fun search(
pageKey: Int,
keyword: String
): SourceResult<Pair<Int?, List<CartoonCover>>> = withResult(Dispatchers.IO) {
val document =
Jsoup.parse(
mikudmUtil.getDocument(
okhttpHelper, "/index.php/vod/search/page/$pageKey/wd/${
encodeUrlComponent(
keyword
)
}.html"
),
mikudmUtil.BASE_URL
)
val videos = document.select(".searchlist_item").map { videoElement ->
val link = videoElement.selectFirst(".vodlist_thumb")!!
val url = link.absUrl("href")
val videoTitle = videoElement.selectFirst(".vodlist_title>a")!!.attr("title")
val coverUrl = mikudmUtil.extractImageSrc(link)
CartoonCoverImpl(
id = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.')),
source = source.key,
url = url,
title = videoTitle,
coverUrl = coverUrl
)
}
val nextPage =
if (mikudmUtil.hasNextPage(document) && videos.isNotEmpty()) pageKey + 1 else null
nextPage to videos
}
private fun encodeUrlComponent(text: String): String =
URLEncoder.encode(text, Charsets.UTF_8.name())
}
================================================
FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mikudm/MikudmUtil.kt
================================================
package io.github.peacefulprogram.easybangumi_mikudm
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.utils.api.PreferenceHelper
import okhttp3.Request
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
class MikudmUtil(
private val preferenceHelper: PreferenceHelper
) {
val BASE_URL:String
get() = preferenceHelper.get("BaseUrl", "https://www.dmmiku.com").let {
if (it.endsWith("/")){
it.substring(0, it.length - 1)
}else{
it
}
}
val BASE_M3U8_URL:String
get() = preferenceHelper.get("BaseM3u8Url", "https://bf.mmiku.net").let {
if (it.endsWith("/")){
it.substring(0, it.length - 1)
}else{
it
}
}
val USER_AGENT =
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36"
fun getDocument(okhttpHelper: OkhttpHelper, url: String): String {
val actualUrl = if (url.startsWith("http")) {
url
} else {
BASE_URL + url
}
val req = Request.Builder()
.header("user-agent", USER_AGENT)
.header("referer", "$BASE_URL/")
.url(actualUrl)
.get()
.build()
return okhttpHelper.client.newCall(req).execute().body?.string() ?: throw RuntimeException(
"响应为空:$url"
)
}
fun hasNextPage(document: Document): Boolean {
val page = document.selectFirst(".page") ?: return false
val currentIndex = page.children().indexOfFirst { it.hasClass("active") }
return page.child(currentIndex + 1).getElementsByTag("a").attr("href") != page.child(
currentIndex
).getElementsByTag("a").attr("href")
}
fun extractImageSrc(imageElement: Element): String {
val img = imageElement.dataset()["original"] ?: ""
if (img.isEmpty()) {
return img
}
if (img.startsWith("http")) {
return img
}
return BASE_URL + img
}
}
================================================
FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mxdm/MxdmApiSource.kt
================================================
package io.github.peacefulprogram.easybangumi_mxdm
import com.heyanle.easybangumi4.source_api.Source
import com.heyanle.extension_api.ExtensionIconSource
import com.heyanle.extension_api.ExtensionSource
import org.easybangumi.extension.R
import kotlin.reflect.KClass
class MxdmApiSource : Source, ExtensionIconSource {
override val describe: String
get() = label
override val label: String
get() = "MX动漫"
override val version: String
get() = "1.1"
override val versionCode: Int
get() = 2
override fun getIconResourcesId(): Int = R.drawable.mxdm
override val key: String
get() = "io.github.peacefulprogram.easybangumi_mxdm-io.github.peacefulprogram.easybangumi_mxdm"
override fun register(): List<KClass<*>> {
return listOf(
MxdmPageComponent::class,
MxdmSearchComponent::class,
MxdmDetailComponent::class,
MxdmPlayComponent::class,
MxdmPreferenceComponent::class,
MxdmUtil::class
)
}
}
================================================
FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mxdm/MxdmDetailComponent.kt
================================================
package io.github.peacefulprogram.easybangumi_mxdm
import com.heyanle.easybangumi4.source_api.SourceResult
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.detailed.DetailedComponent
import com.heyanle.easybangumi4.source_api.entity.Cartoon
import com.heyanle.easybangumi4.source_api.entity.CartoonImpl
import com.heyanle.easybangumi4.source_api.entity.CartoonSummary
import com.heyanle.easybangumi4.source_api.entity.Episode
import com.heyanle.easybangumi4.source_api.entity.PlayLine
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.withResult
import kotlinx.coroutines.Dispatchers
import org.jsoup.Jsoup
class MxdmDetailComponent(
private val okhttpHelper: OkhttpHelper,
private val mxdmUtil: MxdmUtil,
) : ComponentWrapper(), DetailedComponent {
override suspend fun getAll(summary: CartoonSummary): SourceResult<Pair<Cartoon, List<PlayLine>>> =
withResult(Dispatchers.IO) {
getVideoDetail(summary.id)
}
override suspend fun getDetailed(summary: CartoonSummary): SourceResult<Cartoon> =
withResult(Dispatchers.IO) {
getVideoDetail(summary.id).first
}
override suspend fun getPlayLine(summary: CartoonSummary): SourceResult<List<PlayLine>> =
withResult(Dispatchers.IO) {
getVideoDetail(summary.id).second
}
private fun getVideoDetail(videoId: String): Pair<Cartoon, List<PlayLine>> {
val document =
Jsoup.parse(mxdmUtil.getDocument("/dongman/$videoId.html"), mxdmUtil.baseUrl)
val videoTitle = document.selectFirst(".page-title")!!.text().trim()
val tags = document.select(".video-info-aux a").joinToString(", ") { it.text().trim() }
val desc = document.selectFirst(".video-info-content")?.text()
val coverUrl = document.selectFirst(".module-item-pic img")?.run {
mxdmUtil.extractImageSrc(this)
}
val cartoon = CartoonImpl(
id = videoId,
source = source.key,
url = "${mxdmUtil.baseUrl}/dongman/$videoId.html",
title = videoTitle,
genre = tags,
coverUrl = coverUrl,
description = desc
)
val playlistNames = document.select(".module-player-tab .module-tab-item").map { el ->
if (el.childrenSize() > 0) {
el.child(0).text().trim()
} else {
el.text().trim()
}
}
val playLineList = mutableListOf<PlayLine>()
document.select(".module-player-list > .module-blocklist")
.forEachIndexed { index, container ->
if (index >= playlistNames.size) {
return@forEachIndexed
}
val episodeElements = container.getElementsByTag("a")
if (episodeElements.isEmpty()) {
return@forEachIndexed
}
val playlistId = episodeElements[0].attr("href").split('-').run {
this[size - 2]
}
val episodeNames = container.getElementsByTag("a").map { it.text().trim() }
val ep = arrayListOf<Episode>()
for (s in episodeNames.indices) {
val d = episodeNames[s]
ep.add(Episode(s.toString(), d, s))
}
playLineList.add(
PlayLine(
playlistId,
playlistNames[index],
ep
)
)
}
return cartoon to playLineList
}
}
================================================
FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mxdm/MxdmPageComponent.kt
================================================
package io.github.peacefulprogram.easybangumi_mxdm
import android.util.Log
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper
import com.heyanle.easybangumi4.source_api.component.page.PageComponent
import com.heyanle.easybangumi4.source_api.component.page.SourcePage
import com.heyanle.easybangumi4.source_api.entity.CartoonCover
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper
import com.heyanle.easybangumi4.source_api.withResult
import kotlinx.coroutines.Dispatchers
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
class MxdmPageComponent(
private val okhttpHelper: OkhttpHelper,
private val mxdmUtil: MxdmUtil
) : ComponentWrapper(), PageComponent {
override fun getPages(): List<SourcePage> {
val pages = mutableListOf<SourcePage>()
val homePage = SourcePage.Group("首页", false) {
withResult(Dispatchers.IO) {
parseHomePage(Jsoup.parse(mxdmUtil.getDocument( "/").apply {
Log.i("MxdmPageComponent", this)
}, mxdmUtil.baseUrl))
}
}
pages.add(homePage)
val timeline = SourcePage.Group("更新时间表", false) {
withResult(Dispatchers.IO) {
parseTimeLine(Jsoup.parse(mxdmUtil.getDocument("/"), mxdmUtil.baseUrl))
}
}
pages.add(timeline)
listOf(
"riman" to "日本动漫",
"guoman" to "国产动漫",
"dmdianying" to "动漫电影",
"oman" to "欧美动漫",
).forEach { (typeId, typeName) ->
val page = SourcePage.SingleCartoonPage.WithCover(typeName, { 1 }) { page ->
withResult(Dispatchers.IO) {
buildPageOfType(typeId, page)
}
}
pages.add(page)
}
return pages
}
private fun buildPageOfType(typeId: String, page: Int): Pair<Int?, List<CartoonCover>> {
val document = Jsoup.parse(
mxdmUtil.getDocument("/show/${typeId}--------${page}---.html"),
mxdmUtil.baseUrl
)
val videos = document.select(".content .module .module-item").map { it.parseToCartoon() }
val nextPage = if (mxdmUtil.hasNextPage(document) && videos.isNo
gitextract_yt_82lji/ ├── .github/ │ └── workflows/ │ └── release.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle.kts ├── extension-app/ │ ├── .gitignore │ ├── build.gradle.kts │ ├── proguard-rules.pro │ └── src/ │ └── main/ │ ├── AndroidManifest.xml │ ├── java/ │ │ ├── com/ │ │ │ └── heyanle/ │ │ │ └── easybangumi_extension/ │ │ │ ├── anfun/ │ │ │ │ ├── AnfunDetailedComponent.kt │ │ │ │ ├── AnfunListComponent.kt │ │ │ │ ├── AnfunPageComponent.kt │ │ │ │ ├── AnfunSearchComponent.kt │ │ │ │ └── AnfunSource.kt │ │ │ ├── anim/ │ │ │ │ ├── AnimOneInfo.kt │ │ │ │ ├── AnimOneSource.kt │ │ │ │ ├── AnimPageComponent.kt │ │ │ │ └── DataSource.kt │ │ │ └── ggl/ │ │ │ ├── GGLComponent.kt │ │ │ ├── GGLDetailedComponent.kt │ │ │ ├── GGLListComponent.kt │ │ │ ├── GGLPlayComponent.kt │ │ │ └── GGLSource.kt │ │ ├── io/ │ │ │ └── github/ │ │ │ ├── easybangumiorg/ │ │ │ │ └── source/ │ │ │ │ └── aio/ │ │ │ │ ├── AIOHtpHelper.kt │ │ │ │ ├── OkHttp.kt │ │ │ │ ├── SourceResult.kt │ │ │ │ ├── String.kt │ │ │ │ ├── auete/ │ │ │ │ │ ├── AueteDetail.kt │ │ │ │ │ ├── AuetePage.kt │ │ │ │ │ ├── AuetePlay.kt │ │ │ │ │ ├── AueteSearch.kt │ │ │ │ │ ├── AueteSource.kt │ │ │ │ │ └── Common.kt │ │ │ │ ├── changzhang/ │ │ │ │ │ ├── ChangZhangDetailPage.kt │ │ │ │ │ ├── ChangZhangPage.kt │ │ │ │ │ ├── ChangZhangPlayPage.kt │ │ │ │ │ ├── ChangZhangSearchPage.kt │ │ │ │ │ └── ChangZhangSource.kt │ │ │ │ ├── fengche/ │ │ │ │ │ ├── Common.kt │ │ │ │ │ ├── FengCheDetail.kt │ │ │ │ │ ├── FengCheHostUrlHelper.kt │ │ │ │ │ ├── FengChePage.kt │ │ │ │ │ ├── FengChePlay.kt │ │ │ │ │ ├── FengChePrefer.kt │ │ │ │ │ ├── FengCheSearch.kt │ │ │ │ │ └── FengCheSource.kt │ │ │ │ ├── libvio/ │ │ │ │ │ ├── LibVioDetail.kt │ │ │ │ │ ├── LibVioPage.kt │ │ │ │ │ ├── LibVioPlay.kt │ │ │ │ │ ├── LibVioSearch.kt │ │ │ │ │ └── LibVioSource.kt │ │ │ │ └── xigua/ │ │ │ │ ├── Common.kt │ │ │ │ ├── XiGuaPage.kt │ │ │ │ ├── XiguaDetail.kt │ │ │ │ ├── XiguaPlay.kt │ │ │ │ ├── XiguaSearch.kt │ │ │ │ └── XiguaSource.kt │ │ │ └── peacefulprogram/ │ │ │ ├── easybangumi_mikudm/ │ │ │ │ ├── MikudmApiSource.kt │ │ │ │ ├── MikudmDetailComponent.kt │ │ │ │ ├── MikudmPageComponent.kt │ │ │ │ ├── MikudmPlayComponent.kt │ │ │ │ ├── MikudmPreferenceComponent.kt │ │ │ │ ├── MikudmSearchComponent.kt │ │ │ │ └── MikudmUtil.kt │ │ │ ├── easybangumi_mxdm/ │ │ │ │ ├── MxdmApiSource.kt │ │ │ │ ├── MxdmDetailComponent.kt │ │ │ │ ├── MxdmPageComponent.kt │ │ │ │ ├── MxdmPlayComponent.kt │ │ │ │ ├── MxdmPreferenceComponent.kt │ │ │ │ ├── MxdmSearchComponent.kt │ │ │ │ └── MxdmUtil.kt │ │ │ └── easybangumi_nivod/ │ │ │ ├── NivodApiSource.kt │ │ │ ├── NivodConstants.kt │ │ │ ├── NivodDetailComponent.kt │ │ │ ├── NivodPageComponent.kt │ │ │ ├── NivodPlayComponent.kt │ │ │ ├── NivodSearchComponent.kt │ │ │ ├── Util.kt │ │ │ └── dto/ │ │ │ ├── ChannelRecommendResponse.kt │ │ │ ├── Common.kt │ │ │ ├── SearchVideoResponse.kt │ │ │ ├── VideoDetailResponse.kt │ │ │ └── VideoStreamUrlResponse.kt │ │ └── org/ │ │ └── easybangumi/ │ │ └── extension/ │ │ └── EasySourceFactory.kt │ └── res/ │ ├── values/ │ │ └── strings.xml │ └── xml/ │ ├── backup_rules.xml │ └── data_extraction_rules.xml ├── gradle/ │ └── wrapper/ │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat └── settings.gradle.kts
Condensed preview — 93 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (259K chars).
[
{
"path": ".github/workflows/release.yml",
"chars": 1578,
"preview": "name: release\non:\n push:\n tags:\n - '**'\n workflow_dispatch:\njobs:\n build-and-release:\n runs-on: ubuntu-lat"
},
{
"path": ".gitignore",
"chars": 243,
"preview": "*.iml\n.gradle\n.idea\n/local.properties\n/.idea/caches\n/.idea/libraries\n/.idea/modules.xml\n/.idea/workspace.xml\n/.idea/navE"
},
{
"path": "LICENSE",
"chars": 11358,
"preview": " Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 494,
"preview": " \n\n<p align=\"center\">\n <img alt=\"release\" src=\"https://img.shields.io/github/v/release/eas"
},
{
"path": "build.gradle.kts",
"chars": 537,
"preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\nplugins {\n id(\"co"
},
{
"path": "extension-app/.gitignore",
"chars": 6,
"preview": "/build"
},
{
"path": "extension-app/build.gradle.kts",
"chars": 1052,
"preview": "plugins {\n id (\"com.android.application\")\n id (\"org.jetbrains.kotlin.android\")\n}\n\n// 包名\nval packageName = \"org.eas"
},
{
"path": "extension-app/proguard-rules.pro",
"chars": 1665,
"preview": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguar"
},
{
"path": "extension-app/src/main/AndroidManifest.xml",
"chars": 1254,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:to"
},
{
"path": "extension-app/src/main/java/com/heyanle/easybangumi_extension/anfun/AnfunDetailedComponent.kt",
"chars": 8718,
"preview": "package com.heyanle.easybangumi_extension.anfun\n\nimport android.util.Log\nimport com.heyanle.easybangumi4.source_api.Pars"
},
{
"path": "extension-app/src/main/java/com/heyanle/easybangumi_extension/anfun/AnfunListComponent.kt",
"chars": 1734,
"preview": "package com.heyanle.easybangumi_extension.anfun\n\nimport com.heyanle.easybangumi4.source_api.component.ComponentWrapper\ni"
},
{
"path": "extension-app/src/main/java/com/heyanle/easybangumi_extension/anfun/AnfunPageComponent.kt",
"chars": 4769,
"preview": "package com.heyanle.easybangumi_extension.anfun\n\nimport com.heyanle.easybangumi4.source_api.component.ComponentWrapper\ni"
},
{
"path": "extension-app/src/main/java/com/heyanle/easybangumi_extension/anfun/AnfunSearchComponent.kt",
"chars": 3688,
"preview": "package com.heyanle.easybangumi_extension.anfun\n\nimport android.util.Log\nimport com.heyanle.easybangumi4.source_api.Sour"
},
{
"path": "extension-app/src/main/java/com/heyanle/easybangumi_extension/anfun/AnfunSource.kt",
"chars": 1057,
"preview": "package com.heyanle.easybangumi_extension.anfun\n\nimport com.heyanle.extension_api.ExtensionIconSource\nimport com.heyanle"
},
{
"path": "extension-app/src/main/java/com/heyanle/easybangumi_extension/anim/AnimOneInfo.kt",
"chars": 897,
"preview": "package com.heyanle.easybangumi_extension.anim\n\nimport com.heyanle.easybangumi4.source_api.Source\nimport com.heyanle.eas"
},
{
"path": "extension-app/src/main/java/com/heyanle/easybangumi_extension/anim/AnimOneSource.kt",
"chars": 941,
"preview": "package com.heyanle.easybangumi_extension.anim\n\n\nimport com.heyanle.easybangumi4.source_api.Source\nimport com.heyanle.ex"
},
{
"path": "extension-app/src/main/java/com/heyanle/easybangumi_extension/anim/AnimPageComponent.kt",
"chars": 8701,
"preview": "package com.heyanle.easybangumi_extension.anim\n\nimport android.util.Log\nimport com.google.gson.JsonParser\nimport com.hey"
},
{
"path": "extension-app/src/main/java/com/heyanle/easybangumi_extension/anim/DataSource.kt",
"chars": 1822,
"preview": "package com.heyanle.easybangumi_extension.anim\n\nimport com.google.gson.JsonParser\nimport com.heyanle.easybangumi4.source"
},
{
"path": "extension-app/src/main/java/com/heyanle/easybangumi_extension/ggl/GGLComponent.kt",
"chars": 3917,
"preview": "package com.heyanle.easybangumi_extension.ggl\n\nimport android.util.Log\nimport com.heyanle.easybangumi4.source_api.Source"
},
{
"path": "extension-app/src/main/java/com/heyanle/easybangumi_extension/ggl/GGLDetailedComponent.kt",
"chars": 5612,
"preview": "package com.heyanle.easybangumi_extension.ggl\n\nimport com.heyanle.easybangumi4.source_api.SourceResult\nimport com.heyanl"
},
{
"path": "extension-app/src/main/java/com/heyanle/easybangumi_extension/ggl/GGLListComponent.kt",
"chars": 2164,
"preview": "package com.heyanle.easybangumi_extension.ggl\n\nimport com.heyanle.easybangumi4.source_api.component.ComponentWrapper\nimp"
},
{
"path": "extension-app/src/main/java/com/heyanle/easybangumi_extension/ggl/GGLPlayComponent.kt",
"chars": 2453,
"preview": "package com.heyanle.easybangumi_extension.ggl\n\nimport android.util.Log\nimport com.heyanle.easybangumi4.source_api.Parser"
},
{
"path": "extension-app/src/main/java/com/heyanle/easybangumi_extension/ggl/GGLSource.kt",
"chars": 1026,
"preview": "package com.heyanle.easybangumi_extension.ggl\n\nimport com.heyanle.easybangumi4.source_api.Source\nimport com.heyanle.exte"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/AIOHtpHelper.kt",
"chars": 141,
"preview": "package io.github.easybangumiorg.source.aio\n\n/**\n * Created by heyanle on 2024/1/28.\n * https://github.com/heyanLE\n */\nc"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/OkHttp.kt",
"chars": 1713,
"preview": "package io.github.easybangumiorg.source.aio\n\nimport android.util.Log\nimport kotlinx.serialization.json.Json\nimport okhtt"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/SourceResult.kt",
"chars": 538,
"preview": "package io.github.easybangumiorg.source.aio\n\n\n\nimport com.heyanle.easybangumi4.source_api.SourceResult\nimport com.heyanl"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/String.kt",
"chars": 233,
"preview": "package io.github.easybangumiorg.source.aio\n\nimport java.net.URLDecoder\nimport java.net.URLEncoder\n\nfun String.encodeUri"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/auete/AueteDetail.kt",
"chars": 4085,
"preview": "package io.github.easybangumiorg.source.aio.auete\n\nimport com.heyanle.easybangumi4.source_api.SourceResult\nimport com.he"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/auete/AuetePage.kt",
"chars": 6235,
"preview": "package io.github.easybangumiorg.source.aio.auete\n\nimport com.heyanle.easybangumi4.source_api.component.ComponentWrapper"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/auete/AuetePlay.kt",
"chars": 2208,
"preview": "package io.github.easybangumiorg.source.aio.auete\n\nimport com.heyanle.easybangumi4.source_api.ParserException\nimport com"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/auete/AueteSearch.kt",
"chars": 1525,
"preview": "package io.github.easybangumiorg.source.aio.auete\n\n//import com.heyanle.easybangumi4.source_api.SourceResult\nimport com."
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/auete/AueteSource.kt",
"chars": 775,
"preview": "package io.github.easybangumiorg.source.aio.auete\n\nimport com.heyanle.easybangumi4.source_api.Source\nimport com.heyanle."
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/auete/Common.kt",
"chars": 1016,
"preview": "package io.github.easybangumiorg.source.aio.auete\n\nimport com.heyanle.easybangumi4.source_api.entity.CartoonCover\nimport"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/changzhang/ChangZhangDetailPage.kt",
"chars": 2693,
"preview": "package io.github.easybangumiorg.source.aio.changzhang\n\nimport com.heyanle.easybangumi4.source_api.SourceResult\nimport c"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/changzhang/ChangZhangPage.kt",
"chars": 3752,
"preview": "package io.github.easybangumiorg.source.aio.changzhang\n\nimport com.heyanle.easybangumi4.source_api.SourceResult\nimport c"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/changzhang/ChangZhangPlayPage.kt",
"chars": 7773,
"preview": "package io.github.easybangumiorg.source.aio.changzhang\n\nimport com.google.gson.Gson\nimport com.heyanle.easybangumi4.sour"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/changzhang/ChangZhangSearchPage.kt",
"chars": 2613,
"preview": "package io.github.easybangumiorg.source.aio.changzhang\n\nimport com.heyanle.easybangumi4.source_api.SourceResult\nimport c"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/changzhang/ChangZhangSource.kt",
"chars": 2030,
"preview": "package io.github.easybangumiorg.source.aio.changzhang\n\nimport com.heyanle.easybangumi4.source_api.entity.CartoonCover\ni"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/fengche/Common.kt",
"chars": 2618,
"preview": "package io.github.easybangumiorg.source.aio.fengche\n\nimport android.util.Log\nimport com.heyanle.easybangumi4.source_api."
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/fengche/FengCheDetail.kt",
"chars": 3650,
"preview": "package io.github.easybangumiorg.source.aio.fengche\n\nimport com.heyanle.easybangumi4.source_api.SourceResult\nimport com."
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/fengche/FengCheHostUrlHelper.kt",
"chars": 1366,
"preview": "package io.github.easybangumiorg.source.aio.fengche\n\nimport com.heyanle.easybangumi4.source_api.utils.api.PreferenceHelp"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/fengche/FengChePage.kt",
"chars": 5360,
"preview": "package io.github.easybangumiorg.source.aio.fengche\n\nimport com.heyanle.easybangumi4.source_api.component.ComponentWrapp"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/fengche/FengChePlay.kt",
"chars": 3484,
"preview": "package io.github.easybangumiorg.source.aio.fengche\n\nimport android.util.Base64\nimport com.google.gson.Gson\nimport com.h"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/fengche/FengChePrefer.kt",
"chars": 707,
"preview": "package io.github.easybangumiorg.source.aio.fengche\n\nimport com.heyanle.easybangumi4.source_api.component.ComponentWrapp"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/fengche/FengCheSearch.kt",
"chars": 1988,
"preview": "package io.github.easybangumiorg.source.aio.fengche\n\nimport com.heyanle.easybangumi4.source_api.SourceResult\nimport com."
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/fengche/FengCheSource.kt",
"chars": 856,
"preview": "package io.github.easybangumiorg.source.aio.fengche\n\nimport com.heyanle.easybangumi4.source_api.Source\nimport com.heyanl"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/libvio/LibVioDetail.kt",
"chars": 3557,
"preview": "package io.github.easybangumiorg.source.aio.libvio\n\nimport com.heyanle.easybangumi4.source_api.SourceResult\nimport com.h"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/libvio/LibVioPage.kt",
"chars": 5032,
"preview": "package io.github.easybangumiorg.source.aio.libvio\n\nimport android.content.Context\nimport com.heyanle.easybangumi4.sourc"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/libvio/LibVioPlay.kt",
"chars": 5552,
"preview": "package io.github.easybangumiorg.source.aio.libvio\n\nimport android.util.Log\nimport com.google.gson.Gson\nimport com.heyan"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/libvio/LibVioSearch.kt",
"chars": 1038,
"preview": "package io.github.easybangumiorg.source.aio.libvio\n\nimport com.heyanle.easybangumi4.source_api.SourceResult\nimport com.h"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/libvio/LibVioSource.kt",
"chars": 8546,
"preview": "package io.github.easybangumiorg.source.aio.libvio\n\nimport android.content.Context\nimport android.os.Build\nimport androi"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/xigua/Common.kt",
"chars": 183,
"preview": "package io.github.easybangumiorg.source.aio.xigua\n\nconst val XiguaBaseUrl = \"https://cn.xgcartoon.com\"\n\nfun String.extra"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/xigua/XiGuaPage.kt",
"chars": 7787,
"preview": "package io.github.easybangumiorg.source.aio.xigua\n\nimport com.heyanle.easybangumi4.source_api.component.ComponentWrapper"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/xigua/XiguaDetail.kt",
"chars": 3537,
"preview": "package io.github.easybangumiorg.source.aio.xigua\n\nimport com.heyanle.easybangumi4.source_api.SourceResult\nimport com.he"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/xigua/XiguaPlay.kt",
"chars": 2338,
"preview": "package io.github.easybangumiorg.source.aio.xigua\n\nimport com.heyanle.easybangumi4.source_api.ParserException\nimport com"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/xigua/XiguaSearch.kt",
"chars": 2089,
"preview": "package io.github.easybangumiorg.source.aio.xigua\n\nimport com.heyanle.easybangumi4.source_api.SourceResult\nimport com.he"
},
{
"path": "extension-app/src/main/java/io/github/easybangumiorg/source/aio/xigua/XiguaSource.kt",
"chars": 819,
"preview": "package io.github.easybangumiorg.source.aio.xigua\n\nimport com.heyanle.easybangumi4.source_api.Source\nimport com.heyanle."
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mikudm/MikudmApiSource.kt",
"chars": 1072,
"preview": "package io.github.peacefulprogram.easybangumi_mikudm\n\nimport com.heyanle.easybangumi4.source_api.Source\nimport com.heyan"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mikudm/MikudmDetailComponent.kt",
"chars": 2935,
"preview": "package io.github.peacefulprogram.easybangumi_mikudm\n\nimport com.heyanle.easybangumi4.source_api.SourceResult\nimport com"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mikudm/MikudmPageComponent.kt",
"chars": 3506,
"preview": "package io.github.peacefulprogram.easybangumi_mikudm\n\nimport com.heyanle.easybangumi4.source_api.component.ComponentWrap"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mikudm/MikudmPlayComponent.kt",
"chars": 4146,
"preview": "package io.github.peacefulprogram.easybangumi_mikudm\n\nimport android.util.Base64\nimport com.google.gson.Gson\nimport com."
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mikudm/MikudmPreferenceComponent.kt",
"chars": 766,
"preview": "package io.github.peacefulprogram.easybangumi_mikudm\n\nimport com.heyanle.easybangumi4.source_api.component.ComponentWrap"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mikudm/MikudmSearchComponent.kt",
"chars": 2289,
"preview": "package io.github.peacefulprogram.easybangumi_mikudm\n\nimport com.heyanle.easybangumi4.source_api.SourceResult\nimport com"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mikudm/MikudmUtil.kt",
"chars": 2185,
"preview": "package io.github.peacefulprogram.easybangumi_mikudm\n\nimport com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper\n"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mxdm/MxdmApiSource.kt",
"chars": 1050,
"preview": "package io.github.peacefulprogram.easybangumi_mxdm\n\nimport com.heyanle.easybangumi4.source_api.Source\nimport com.heyanle"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mxdm/MxdmDetailComponent.kt",
"chars": 3740,
"preview": "package io.github.peacefulprogram.easybangumi_mxdm\n\nimport com.heyanle.easybangumi4.source_api.SourceResult\nimport com.h"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mxdm/MxdmPageComponent.kt",
"chars": 6395,
"preview": "package io.github.peacefulprogram.easybangumi_mxdm\n\n\nimport android.util.Log\nimport com.heyanle.easybangumi4.source_api."
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mxdm/MxdmPlayComponent.kt",
"chars": 3330,
"preview": "package io.github.peacefulprogram.easybangumi_mxdm\n\nimport android.util.Base64\nimport com.google.gson.Gson\nimport com.he"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mxdm/MxdmPreferenceComponent.kt",
"chars": 715,
"preview": "package io.github.peacefulprogram.easybangumi_mxdm\n\nimport com.heyanle.easybangumi4.source_api.component.ComponentWrappe"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mxdm/MxdmSearchComponent.kt",
"chars": 2277,
"preview": "package io.github.peacefulprogram.easybangumi_mxdm\n\nimport com.heyanle.easybangumi4.source_api.SourceResult\nimport com.h"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mxdm/MxdmUtil.kt",
"chars": 1937,
"preview": "package io.github.peacefulprogram.easybangumi_mxdm\n\nimport com.heyanle.easybangumi4.source_api.utils.api.NetworkHelper\ni"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/NivodApiSource.kt",
"chars": 997,
"preview": "package io.github.peacefulprogram.easybangumi_nivod\n\nimport com.heyanle.easybangumi4.source_api.Source\nimport com.heyanl"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/NivodConstants.kt",
"chars": 223,
"preview": "package io.github.peacefulprogram.easybangumi_nivod\n\nobject NivodConstants {\n\n const val BASE_URL = \"https://api.nivo"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/NivodDetailComponent.kt",
"chars": 3030,
"preview": "package io.github.peacefulprogram.easybangumi_nivod\n\nimport com.google.gson.Gson\nimport com.heyanle.easybangumi4.source_"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/NivodPageComponent.kt",
"chars": 3724,
"preview": "package io.github.peacefulprogram.easybangumi_nivod\n\nimport com.google.gson.Gson\nimport com.heyanle.easybangumi4.source_"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/NivodPlayComponent.kt",
"chars": 1689,
"preview": "package io.github.peacefulprogram.easybangumi_nivod\n\nimport com.google.gson.Gson\nimport com.heyanle.easybangumi4.source_"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/NivodSearchComponent.kt",
"chars": 2126,
"preview": "package io.github.peacefulprogram.easybangumi_nivod\n\nimport com.google.gson.Gson\nimport com.heyanle.easybangumi4.source_"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/Util.kt",
"chars": 3652,
"preview": "package io.github.peacefulprogram.easybangumi_nivod\n\nimport com.google.gson.Gson\nimport com.google.gson.reflect.TypeToke"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/dto/ChannelRecommendResponse.kt",
"chars": 4028,
"preview": "package io.github.peacefulprogram.easybangumi_nivod.dto\n\nimport com.google.gson.annotations.SerializedName\n\ndata class C"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/dto/Common.kt",
"chars": 392,
"preview": "package io.github.peacefulprogram.easybangumi_nivod.dto\n\nimport com.google.gson.annotations.SerializedName\n\n\ndata class "
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/dto/SearchVideoResponse.kt",
"chars": 2346,
"preview": "package io.github.peacefulprogram.easybangumi_nivod.dto\n\nimport com.google.gson.annotations.SerializedName\n\n\ndata class "
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/dto/VideoDetailResponse.kt",
"chars": 3478,
"preview": "package io.github.peacefulprogram.easybangumi_nivod.dto\n\nimport com.google.gson.annotations.SerializedName\n\ndata class V"
},
{
"path": "extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/dto/VideoStreamUrlResponse.kt",
"chars": 456,
"preview": "package io.github.peacefulprogram.easybangumi_nivod.dto\n\nimport com.google.gson.annotations.SerializedName\n\ndata class V"
},
{
"path": "extension-app/src/main/java/org/easybangumi/extension/EasySourceFactory.kt",
"chars": 1355,
"preview": "package org.easybangumi.extension\n\nimport com.heyanle.easybangumi4.source_api.Source\nimport com.heyanle.easybangumi4.sou"
},
{
"path": "extension-app/src/main/res/values/strings.xml",
"chars": 75,
"preview": "<resources>\n <string name=\"app_name\">纯纯看番:AllInOne</string>\n</resources>"
},
{
"path": "extension-app/src/main/res/xml/backup_rules.xml",
"chars": 478,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?><!--\n Sample backup rules file; uncomment and customize as necessary.\n See htt"
},
{
"path": "extension-app/src/main/res/xml/data_extraction_rules.xml",
"chars": 551,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?><!--\n Sample data extraction rules file; uncomment and customize as necessary.\n "
},
{
"path": "gradle/wrapper/gradle-wrapper.properties",
"chars": 230,
"preview": "#Sun Dec 10 21:18:58 HKT 2023\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https\\://"
},
{
"path": "gradle.properties",
"chars": 1358,
"preview": "# Project-wide Gradle settings.\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will ov"
},
{
"path": "gradlew",
"chars": 5766,
"preview": "#!/usr/bin/env sh\n\n#\n# Copyright 2015 the original author or authors.\n#\n# Licensed under the Apache License, Version 2.0"
},
{
"path": "gradlew.bat",
"chars": 2674,
"preview": "@rem\n@rem Copyright 2015 the original author or authors.\n@rem\n@rem Licensed under the Apache License, Version 2.0 (the \""
},
{
"path": "settings.gradle.kts",
"chars": 491,
"preview": "pluginManagement {\n repositories {\n google()\n mavenCentral()\n gradlePluginPortal()\n }\n}\ndepen"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the easybangumiorg/CommunityExtension GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 93 files (233.4 KB), approximately 58.6k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.