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 ================================================ ![纯纯看番本体番剧源](./headline.png)

release license

本仓库内容均来自互联网投稿,为了代码安全性只收录提交到纯纯看番官方的代码,并由官方编译。 如果使用其他的源,用户需要自己甄别插件安全性,纯纯看番官方无法保证这些插件是否安全。 如果本仓库内容您认为侵犯了你的权益,请提交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("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 { ; } -keepclassmembers class kotlin.Metadata { public ; } -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 ; } ================================================ FILE: extension-app/src/main/AndroidManifest.xml ================================================ ================================================ 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 { return withResult(Dispatchers.IO) { detailed(getDoc(summary), summary) } } override suspend fun getPlayLine(summary: CartoonSummary): SourceResult> { return withResult(Dispatchers.IO) { playLine(getDoc(summary), summary) } } override suspend fun getAll(summary: CartoonSummary): SourceResult>> { return withResult(Dispatchers.IO) { detailed(getDoc(summary), summary) to playLine(getDoc(summary), summary) } } override suspend fun update( cartoon: Cartoon, oldPlayLine: List ): SourceResult { 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 { Log.e("TAG","------->>>>>>>playLine") val res = arrayListOf() 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() 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 { 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> { val r = arrayListOf() 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 { return listOf( // 首页 SourcePage.Group( "首页", false, ) { withResult(Dispatchers.IO) { homeListPages() } }, // 新番时刻表 SourcePage.Group( "每日更新列表", false, ) { withResult(Dispatchers.IO) { homeTimelinePages() } }, ) } // 获取主页所有 ListPage private suspend fun homeListPages(): List { val res = arrayListOf() 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 { val res = arrayListOf() 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() 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() 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>> { 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() 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> { 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> { 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 { 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>> { 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>> { 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 { 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> { 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() 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() override suspend fun getPlayInfo( summary: CartoonSummary, playLine: PlayLine, episode: Episode, ): SourceResult { 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("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? = null suspend fun getData( refresh: Boolean, okhttpHelper: OkhttpHelper, ):List { return withContext(Dispatchers.IO){ if(allData == null || refresh){ val rs = arrayListOf() 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 { 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>> { 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() 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>> { return withResult(Dispatchers.IO) { val doc = getDoc(summary) detailed(doc, summary) to playLine(doc, summary) } } override suspend fun getDetailed(summary: CartoonSummary): SourceResult { return withResult(Dispatchers.IO) { val doc = getDoc(summary) detailed(doc, summary) } } override suspend fun getPlayLine(summary: CartoonSummary): SourceResult> { 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 { 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() var ii = 1 while (tabs.hasNext() && epRoot.hasNext()) { val tab = tabs.next() val ul = epRoot.next() val es = arrayListOf() 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 ): SourceResult { 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>{ val d = if(!url.endsWith("/")) "${url}/" else url val u = d.replace("---/", "${page}---/") val list = arrayListOf() 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 { 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 { 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> { 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 Response.readJson(): T { return json.decodeFromString(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 SourceResult.map(convert: (T) -> R): SourceResult { return when (this) { is SourceResult.Complete -> SourceResult.Complete(convert(data)) is SourceResult.Error -> SourceResult.Error(throwable, isParserError) } } suspend fun 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>> = 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() 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 = getAll(summary).map { it.first } override suspend fun getPlayLine(summary: CartoonSummary): SourceResult> = 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 { val home = SourcePage.Group(label = "首页", newScreen = false) { withIoResult { val doc = commonHttpClient.newGetRequest { url(AueteBaseUrl) }.asDocument() val areas: MutableList = 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> { 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 = 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>> = 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> = 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>> = 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 = getAll(summary).map { it.first } override suspend fun getPlayLine(summary: CartoonSummary): SourceResult> = 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 { 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> { 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 = 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>(config, Map::class.java) return map["url"]?.let { it as String } ?: throw RuntimeException("未获取到url") } private fun extractKeyAndIv(html: String): Pair { var start = 0 val keyAndIv = mutableListOf() 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() 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>> = 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> = 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>> = 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 { return getAll(summary).map { it.first } } override suspend fun getPlayLine(summary: CartoonSummary): SourceResult> { 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? = null override fun getPages(): List { val home = SourcePage.Group("首页", false) { withResult(Dispatchers.IO) { val document = okhttpHelper.client.newGetRequest { url(hostUrlHelper.fengcheBaseUrl) }.asDocument() val pages = mutableListOf() 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> { 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 { if (categories == null) { categoryLock.withLock { if (categories == null) { categories = requestVideoCategories() } } } return categories!! } private fun requestVideoCategories(): List { 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 = 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.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 = 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>> = 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> = 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>> = withIoResult { val doc = libVioSource.requestWithFunCDNInterceptor { url("${LibVioSource.BASE_URL}/detail/${summary.id}.html") get() }.asDocument() val playlists = mutableListOf() 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 = getAll(summary).map { it.first } override suspend fun getPlayLine(summary: CartoonSummary): SourceResult> = 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 { 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() 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> { 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() @OptIn(ExperimentalEncodingApi::class) override suspend fun getPlayInfo( summary: CartoonSummary, playLine: PlayLine, episode: Episode ): SourceResult = 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>(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>> = 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> = 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>() } 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() 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>() 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> { 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 { val home = SourcePage.Group(label = "首页", newScreen = false) { withResult(Dispatchers.IO) { val doc = commonHttpClient.newGetRequest { url(XiguaBaseUrl) }.asDocument() val result = mutableListOf() 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() 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> { 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() 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 = 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 = 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>> { 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() var currentEpisodes = arrayListOf() 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 { return getAll(summary).map { it.first } } override suspend fun getPlayLine(summary: CartoonSummary): SourceResult> { 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 { 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>> = 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> { 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> { 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>> = withResult(Dispatchers.IO) { getVideoDetail(summary.id) } override suspend fun getDetailed(summary: CartoonSummary): SourceResult = withResult(Dispatchers.IO) { getVideoDetail(summary.id).first } override suspend fun getPlayLine(summary: CartoonSummary): SourceResult> = withResult(Dispatchers.IO) { getVideoDetail(summary.id).second } private fun getVideoDetail(videoId: String): Pair> { 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() 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 { val pages = mutableListOf() 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> { 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 { val result = mutableListOf() 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 = 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.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 = 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>> = 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> { 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>> = withResult(Dispatchers.IO) { getVideoDetail(summary.id) } override suspend fun getDetailed(summary: CartoonSummary): SourceResult = withResult(Dispatchers.IO) { getVideoDetail(summary.id).first } override suspend fun getPlayLine(summary: CartoonSummary): SourceResult> = withResult(Dispatchers.IO) { getVideoDetail(summary.id).second } private fun getVideoDetail(videoId: String): Pair> { 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() 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() 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 { val pages = mutableListOf() 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> { 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.isNotEmpty()) page + 1 else null return nextPage to videos } private fun parseTimeLine(document: Document): List { val tabs = document.selectFirst(".mxoneweek-tabs") ?: return emptyList() val result = mutableListOf() var activeTabIndex = 0 val tabNames = tabs.children().mapIndexed { index, el -> if (el.hasClass("active")) { activeTabIndex = index } el.text().trim() } val videoGroups = document.select(".mxoneweek-list").map { el -> el.getElementsByTag("a").map { link -> val title = if (link.childrenSize() > 0) link.child(0).text().trim() else link.text().trim() val episodeText = if (link.childrenSize() > 1) link.child(1).text().trim() else "" val url = link.absUrl("href") val videoId = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.')) CartoonCoverImpl( id = videoId, source = source.key, url = "${mxdmUtil.baseUrl}/dongman/$videoId.html", title = title, intro = episodeText ) } } for (i in activeTabIndex until tabNames.size.coerceAtMost(videoGroups.size)) { val page = SourcePage.SingleCartoonPage.WithoutCover(tabNames[i], { 0 }) { withResult { null to videoGroups[i] } } result.add(page) } for (i in 0 until activeTabIndex) { val page = SourcePage.SingleCartoonPage.WithoutCover(tabNames[i], { 0 }) { withResult { null to videoGroups[i] } } result.add(page) } return result } private fun parseHomePage(document: Document): List { val result = mutableListOf() val contents = document.select(".content .module .module-list>.module-items").iterator() val titles = document.select(".content .module .module-title").iterator() while (contents.hasNext() && titles.hasNext()) { val contentEl = contents.next() val titleEl = titles.next() val videos = contentEl.select(".module-item") if (videos.isEmpty()) { continue } if (videos[0].classNames().size > 1) { continue } val cartoonList = videos.map { videoEl -> videoEl.parseToCartoon() } val page = SourcePage.SingleCartoonPage.WithCover(titleEl.text().trim(), { 0 }) { withResult { Pair(null, cartoonList) } } result.add(page) } return result } private fun Element.parseToCartoon(): CartoonCover { val coverUrl = mxdmUtil.extractImageSrc(this.selectFirst("img")!!) val linkEl = this.selectFirst("a")!! val url = linkEl.absUrl("href") val id = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.')) val videoTitle = this.selectFirst(".video-name")!!.text().trim() val tags = LinkedHashSet() val episode = this.selectFirst(".module-item-text")?.text()?.trim() ?: "" if (episode.isEmpty()) { tags.add(episode) } this.selectFirst(".module-item-caption")?.children()?.forEach { val text = it.text().trim() if (text.isNotEmpty()) { tags.add(text) } } return CartoonCoverImpl( id = id, source = source.key, url = url, title = videoTitle, intro = tags.joinToString(" | "), coverUrl = coverUrl ) } } ================================================ FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mxdm/MxdmPlayComponent.kt ================================================ package io.github.peacefulprogram.easybangumi_mxdm 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.withResult import kotlinx.coroutines.Dispatchers import javax.crypto.Cipher import javax.crypto.spec.IvParameterSpec import javax.crypto.spec.SecretKeySpec class MxdmPlayComponent( private val okhttpHelper: OkhttpHelper, private val mxdmUtil: MxdmUtil, ) : ComponentWrapper(), PlayComponent { override suspend fun getPlayInfo( summary: CartoonSummary, playLine: PlayLine, episode: Episode, ): SourceResult = withResult(Dispatchers.IO) { val html = mxdmUtil.getDocument( "/dongmanplay/${summary.id}-${playLine.id}-${(episode.id.toIntOrNull()?:episode.order) + 1}.html") val newHtml = mxdmUtil.getDocument( "https://danmu.yhdmjx.com/m3u8.php?url=" + extractPlayerParam(html)) 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(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.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 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/peacefulprogram/easybangumi_mxdm/MxdmPreferenceComponent.kt ================================================ package io.github.peacefulprogram.easybangumi_mxdm import com.heyanle.easybangumi4.source_api.component.ComponentWrapper import com.heyanle.easybangumi4.source_api.component.play.PlayComponent import com.heyanle.easybangumi4.source_api.component.preference.PreferenceComponent import com.heyanle.easybangumi4.source_api.component.preference.SourcePreference /** * Created by heyanlin on 2024/5/22. */ class MxdmPreferenceComponent : ComponentWrapper(), PreferenceComponent { override fun register(): List = listOf( SourcePreference.Edit("MX 动漫网址", "BaseUrl", "https://www.mxdm.tv/"), ) override fun needMigrate(oldVersionCode: Int): Boolean { return false } } ================================================ FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_mxdm/MxdmSearchComponent.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.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.withResult import kotlinx.coroutines.Dispatchers import org.jsoup.Jsoup import java.net.URLEncoder class MxdmSearchComponent( private val okhttpHelper: OkhttpHelper, private val mxdmUtil: MxdmUtil ) : ComponentWrapper(), SearchComponent { override fun getFirstSearchKey(keyword: String): Int = 1 override suspend fun search( pageKey: Int, keyword: String ): SourceResult>> = withResult(Dispatchers.IO) { val document = Jsoup.parse( mxdmUtil.getDocument( "/search/${encodeUrlComponent(keyword)}----------$pageKey---.html"), mxdmUtil.baseUrl ) val videos = document.select(".module-search-item").map { videoElement -> val link = videoElement.selectFirst("a")!! val url = link.absUrl("href") val videoTitle = videoElement.selectFirst("h3")!!.text() val coverUrl = mxdmUtil.extractImageSrc(videoElement.selectFirst("img")!!) val desc = videoElement.select(".video-info-item").last()?.text() val videoId = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.')) CartoonCoverImpl( id = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.')), source = source.key, url = "${mxdmUtil.baseUrl}/dongman/$videoId.html", title = videoTitle, intro = desc, coverUrl = coverUrl ) } val nextPage = if (mxdmUtil.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_mxdm/MxdmUtil.kt ================================================ package io.github.peacefulprogram.easybangumi_mxdm 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.PreferenceHelper import okhttp3.Request import org.jsoup.nodes.Document import org.jsoup.nodes.Element class MxdmUtil( private val okhttpHelper: OkhttpHelper, private val networkHelper: NetworkHelper, private val preferenceHelper: PreferenceHelper ) { val baseUrl:String get() = preferenceHelper.get("BaseUrl", "https://www.mxdm.tv").let { if (it.endsWith("/")){ it.substring(0, it.length - 1) }else{ it } } val userAgent = "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(url: String): String { val actualUrl = if (url.startsWith("http")) { url } else { baseUrl + url } val req = Request.Builder() .header("user-agent", networkHelper.defaultAndroidUA) .url(actualUrl) .get() .build() return okhttpHelper.cloudflareWebViewClient.newCall(req).execute().body?.string() ?: throw RuntimeException( "响应为空:$url" ) } fun hasNextPage(document: Document): Boolean { val page = document.getElementById("page") ?: return false val currentPageIndex = page.children().indexOfFirst { it.hasClass("page-current") } return currentPageIndex != -1 && currentPageIndex < page.childrenSize() - 3 } fun extractImageSrc(imageElement: Element): String { var img = imageElement.dataset()["src"] ?: "" if (img.isEmpty() && imageElement.hasAttr("src")) { img = imageElement.attr("src") } return img } } ================================================ FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/NivodApiSource.kt ================================================ package io.github.peacefulprogram.easybangumi_nivod 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 NivodApiSource : Source, ExtensionIconSource { override val describe: String get() = "nivod.tv,科学上网" override val label: String get() = "泥视频" override val version: String get() = "2.0" override val versionCode: Int get() = 4 override fun getIconResourcesId(): Int = R.drawable.nivod override fun register(): List> { return listOf( NivodPageComponent::class, NivodSearchComponent::class, NivodDetailComponent::class, NivodPlayComponent::class ) } override val key: String get() = "io.github.peacefulprogram.easybangumi_nivod-io.github.peacefulprogram.easybangumi_nivod" } ================================================ FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/NivodConstants.kt ================================================ package io.github.peacefulprogram.easybangumi_nivod object NivodConstants { const val BASE_URL = "https://api.nivodz.com" const val WEBPAGE_URL = "https://www.nivod4.tv" const val REFERER = "$WEBPAGE_URL/" } ================================================ FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/NivodDetailComponent.kt ================================================ package io.github.peacefulprogram.easybangumi_nivod 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.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 io.github.peacefulprogram.easybangumi_nivod.dto.VideoDetailResponse import kotlinx.coroutines.Dispatchers class NivodDetailComponent( private val okhttpHelper: OkhttpHelper ) : ComponentWrapper(), DetailedComponent { val gson = Gson() override suspend fun getAll(summary: CartoonSummary): SourceResult>> { return withResult(Dispatchers.IO) { val detail = getVideoDetail(summary.id) Pair(detail.toCartoon(), getVideoDetail(summary.id).toPlayLine()) } } override suspend fun getDetailed(summary: CartoonSummary): SourceResult { return withResult(Dispatchers.IO) { getVideoDetail(summary.id).toCartoon() } } override suspend fun getPlayLine(summary: CartoonSummary): SourceResult> { return withResult(Dispatchers.IO) { getVideoDetail(summary.id).toPlayLine() } } private fun VideoDetailResponse.toPlayLine(): List { val ids = mutableListOf() val names = arrayListOf() entity.plays.forEachIndexed { i, it -> ids.add(it.playIdCode) names.add(Episode(it.playIdCode, it.episodeName, it.seq)) } return DetailedComponent.NonPlayLine( PlayLine( "播放列表", "泥视频", episode = names ) ) } private fun getVideoDetail(id: String): VideoDetailResponse { val req = NivodRequest( "/show/detail/WEB/3.2", body = mapOf("show_id_code" to id) ) return gson.fromJson( okhttpHelper.client.newCall(req).execute().decryptResponseBodyIfCan() ) } private fun VideoDetailResponse.toCartoon(): Cartoon = CartoonImpl( id = this.entity.showIdCode, source = source.key, url = "${NivodConstants.WEBPAGE_URL}/detail.html?showIdCode=${entity.showIdCode}", title = this.entity.showTitle, coverUrl = this.entity.showImg, description = this.entity.showDesc, genre = listOf( entity.showTypeName, entity.postYear.toString(), entity.episodesUpdateDesc ).filter { it.isNotBlank() }.joinToString(", ") ) } ================================================ FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/NivodPageComponent.kt ================================================ package io.github.peacefulprogram.easybangumi_nivod import com.google.gson.Gson import com.heyanle.easybangumi4.source_api.Source 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.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 io.github.peacefulprogram.easybangumi_nivod.dto.ChannelRecommendResponse import kotlinx.coroutines.Dispatchers class NivodPageComponent( private val okhttpHelper: OkhttpHelper ) : PageComponent, ComponentWrapper() { val gson = Gson() override fun getPages(): List { val channels = listOf( Pair("首页", null), Pair("电影", 1), Pair("动漫", 4), Pair("电视剧", 2), Pair("综艺", 3), Pair("纪录片", 6) ) return channels.map { (channelName, channelId) -> SourcePage.Group(channelName, false) { withResult(Dispatchers.IO) { getChannelRecommend(channelId = channelId) } } } } private fun getChannelRecommend(channelId: Int?): List { val pages = mutableListOf() var start = 0 val step = 6 while (true) { val req = NivodRequest( "/index/desktop/WEB/3.4", body = NoEmptyValueMap( "channel_id" to channelId, "start" to start, "more" to "1" ) ) val resp = gson.fromJson( okhttpHelper.client.newCall(req).execute().decryptResponseBodyIfCan() ) if (resp.banners.isNotEmpty()) { SourcePage.SingleCartoonPage.WithCover("推荐", { 1 }) { withResult { null to resp.banners.filter { it.show != null }.map { banner -> CartoonCoverImpl( id = banner.show!!.showIdCode, source = source.key, url = "${NivodConstants.WEBPAGE_URL}/detail.html?showIdCode=${banner.show.showIdCode}", title = banner.show.showTitle, coverUrl = banner.show.showImg ) } } }.let { pages.add(it) } } resp.list.forEach { recommendRow -> SourcePage.SingleCartoonPage.WithCover(recommendRow.title, { 1 }) { withResult { null to recommendRow.rows.flatMap { it.cells }.map { video -> CartoonCoverImpl( id = video.show.showIdCode, source = source.key, url = "${NivodConstants.WEBPAGE_URL}/detail.html?showIdCode=${video.show.showIdCode}", title = video.show.showTitle, coverUrl = video.show.showImg ) } } }.let { pages.add(it) } } if (resp.more != 1) { break } start += step } return pages } } ================================================ FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/NivodPlayComponent.kt ================================================ package io.github.peacefulprogram.easybangumi_nivod 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.withResult import io.github.peacefulprogram.easybangumi_nivod.dto.VideoStreamUrlResponse import kotlinx.coroutines.Dispatchers class NivodPlayComponent( private val okhttpHelper: OkhttpHelper, ) : ComponentWrapper(), PlayComponent { val gson = Gson() override suspend fun getPlayInfo( summary: CartoonSummary, playLine: PlayLine, episode: Episode ): SourceResult { return withResult(Dispatchers.IO) { val episodeId = episode.id val req = NivodRequest( "/show/play/info/WEB/3.2", body = mapOf( "show_id_code" to summary.id, "play_id_code" to episodeId ) ) val resp = gson.fromJson( okhttpHelper.client.newCall(req).execute().decryptResponseBodyIfCan() ) PlayerInfo( decodeType = PlayerInfo.DECODE_TYPE_HLS, uri = resp.entity.playUrl ) } } } ================================================ FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/NivodSearchComponent.kt ================================================ package io.github.peacefulprogram.easybangumi_nivod 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.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.withResult import io.github.peacefulprogram.easybangumi_nivod.dto.SearchVideoResponse import kotlinx.coroutines.Dispatchers class NivodSearchComponent( private val okhttpHelper: OkhttpHelper, ) : ComponentWrapper(), SearchComponent { private val pageSize = 20 private val gson = Gson() override fun getFirstSearchKey(keyword: String): Int { return 0 } override suspend fun search( pageKey: Int, keyword: String ): SourceResult>> { return withResult(Dispatchers.IO) { val req = NivodRequest( "/show/search/WEB/3.2", body = mapOf( "keyword" to keyword, "start" to pageKey.toString(), "cat_id" to "1", "keyword_type" to "0" ) ) val resp = gson.fromJson( okhttpHelper.client.newCall(req).execute().decryptResponseBodyIfCan() ) val nextPageKey = if (resp.more == 1) pageKey + pageSize else null val videos = resp.list.map { video -> CartoonCoverImpl( id = video.showIdCode, source = source.key, url = "${NivodConstants.WEBPAGE_URL}/detail.html?showIdCode=${video.showIdCode}", title = video.showTitle, coverUrl = video.showImg, intro = video.episodesTxt ) } Pair(nextPageKey, videos) } } } ================================================ FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/Util.kt ================================================ package io.github.peacefulprogram.easybangumi_nivod import com.google.gson.Gson import com.google.gson.reflect.TypeToken import okhttp3.FormBody import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.Request import okhttp3.Response import java.security.MessageDigest import javax.crypto.Cipher import javax.crypto.spec.SecretKeySpec fun Response.decryptResponseBodyIfCan(): String { if (code == 403) { throw RuntimeException("请求被禁止,请科学上网后重试") } val encryptedText = body?.string() ?: throw RuntimeException("响应体为空") val cipherText = (encryptedText).decodeHexString() val key = "diao.com".toByteArray() return Cipher.getInstance("DES/ECB/PKCS5Padding").run { init(Cipher.DECRYPT_MODE, SecretKeySpec(key, "DES")) doFinal(cipherText) }.toString(Charsets.UTF_8) } private fun String.decodeHexString(): ByteArray = this.chunked(2).map { it.toInt(16).toByte() }.toByteArray() @OptIn(ExperimentalStdlibApi::class) private fun createSign(queryParams: Map, body: Map): String { val prefixes = arrayOf("__QUERY::", "__BODY::") val params = arrayOf(queryParams, body) val str = StringBuilder() for (i in prefixes.indices) { val param = params[i] str.append(prefixes[i]) param.keys.toList().sorted().filter { it.isNotEmpty() && param[it]?.isNotEmpty() == true }.forEach { str.append(it) str.append('=') str.append(param[it]) str.append('&') } } str.append("__KEY::2x_Give_it_a_shot") return MessageDigest.getInstance("MD5").digest(str.toString().toByteArray(Charsets.UTF_8)) .toHexString() } private fun HttpUrl.Builder.withSign( body: Map = emptyMap(), queryParams: Map = emptyMap() ): HttpUrl.Builder { val allQueryParams = mutableMapOf( "_ts" to System.currentTimeMillis().toString(), "app_version" to "1.0", "platform" to "3", "market_id" to "web_nivod", "device_code" to "web", "versioncode" to "1", "oid" to "8ca275aa5e12ba504b266d4c70d95d77a0c2eac5726198ea" ).apply { putAll(queryParams) } allQueryParams.forEach { (name, value) -> addQueryParameter(name, value) } addQueryParameter("sign", createSign(allQueryParams, body = body)) return this } fun NoEmptyValueMap(vararg pairs: Pair): Map { val result = pairs.asSequence() .filter { (k, v) -> k.isNotEmpty() && v != null && (v !is String || v.isNotEmpty()) } .map { (k, v) -> k to v.toString() } .toList() .toTypedArray() return mapOf(*result) } inline fun Gson.fromJson(json: String): T = fromJson(json, object : TypeToken() {}) fun NivodRequest( url: String, body: Map = emptyMap(), queryParams: Map = emptyMap() ): Request { val url = (NivodConstants.BASE_URL + url).toHttpUrl() .newBuilder() .withSign(body, queryParams) .build() val formBody = FormBody.Builder() .apply { body.entries.forEach { (name, value) -> add(name, value) } }.build() return Request.Builder() .header("referer", NivodConstants.REFERER) .header( "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" ) .post(formBody) .url(url) .build() } ================================================ FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/dto/ChannelRecommendResponse.kt ================================================ package io.github.peacefulprogram.easybangumi_nivod.dto import com.google.gson.annotations.SerializedName data class ChannelRecommendResponse( @SerializedName("banners") val banners: List, @SerializedName("list") val list: List, @SerializedName("more") val more: Int, @SerializedName("msg") val msg: String, @SerializedName("start") val start: String, @SerializedName("status") val status: Int ) data class ChannelRecommendBanner( @SerializedName("id") val id: Int, @SerializedName("imageUrl") val imageUrl: String, @SerializedName("seq") val seq: Int, @SerializedName("show") val show: ChannelRecommendShow? = null, @SerializedName("title") val title: String ) data class ChannelRecommend( @SerializedName("blockId") val blockId: Int, @SerializedName("blockType") val blockType: Int, @SerializedName("channelId") val channelId: Int, @SerializedName("layout") val layout: Int, @SerializedName("rows") val rows: List, @SerializedName("srcChannelId") val srcChannelId: Int, @SerializedName("title") val title: String ) data class ChannelRecommendShow( @SerializedName("actors") val actors: String, @SerializedName("addDate") val addDate: Long, @SerializedName("catId") val catId: Int, @SerializedName("channelId") val channelId: Int, @SerializedName("channelName") val channelName: String, @SerializedName("commentCount") val commentCount: Int, @SerializedName("director") val director: String, @SerializedName("episodesTxt") val episodesTxt: String, @SerializedName("favoriteCount") val favoriteCount: Int, @SerializedName("hot") val hot: Int, @SerializedName("inSeries") val inSeries: Int, @SerializedName("isEpisodes") val isEpisodes: Int, @SerializedName("isEpisodesEnd") val isEpisodesEnd: Int, @SerializedName("pageBgImg") val pageBgImg: String, @SerializedName("playLangs") val playLangs: List, @SerializedName("playResolutions") val playResolutions: List, @SerializedName("playSources") val playSources: List, @SerializedName("postYear") val postYear: Int, @SerializedName("rating") val rating: Int, @SerializedName("regionId") val regionId: Int, @SerializedName("regionName") val regionName: String, @SerializedName("shareCount") val shareCount: Int, @SerializedName("shareForced") val shareForced: Int, @SerializedName("showId") val showId: Int, @SerializedName("showIdCode") val showIdCode: String, @SerializedName("showImg") val showImg: String, @SerializedName("showTcTitle") val showTcTitle: String, @SerializedName("showTitle") val showTitle: String, @SerializedName("showTypeId") val showTypeId: Int, @SerializedName("showTypeName") val showTypeName: String = "", @SerializedName("status") val status: Int, @SerializedName("titleImg") val titleImg: String, @SerializedName("voteDown") val voteDown: Int, @SerializedName("voteUp") val voteUp: Int ) data class ChannelRecommendRow( @SerializedName("blockId") val blockId: Int, @SerializedName("cells") val cells: List, @SerializedName("overflow") val overflow: String, @SerializedName("rowId") val rowId: Int, @SerializedName("type") val type: Int ) data class ChannelRecommendCell( @SerializedName("bottomRightText") val bottomRightText: String, @SerializedName("cellId") val cellId: Int, @SerializedName("img") val img: String, @SerializedName("intro") val intro: String = "", @SerializedName("rowId") val rowId: Int, @SerializedName("show") val show: ChannelRecommendShow, @SerializedName("title") val title: String ) ================================================ FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/dto/Common.kt ================================================ package io.github.peacefulprogram.easybangumi_nivod.dto import com.google.gson.annotations.SerializedName data class VideoPlayLang( @SerializedName("langId") val langId: Int, @SerializedName("langName") val langName: String ) data class VideoPlaySource( @SerializedName("sourceId") val sourceId: Int, @SerializedName("sourceName") val sourceName: String ) ================================================ FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/dto/SearchVideoResponse.kt ================================================ package io.github.peacefulprogram.easybangumi_nivod.dto import com.google.gson.annotations.SerializedName data class SearchVideoResponse( @SerializedName("list") val list: List, @SerializedName("more") val more: Int, @SerializedName("msg") val msg: String, @SerializedName("start") val start: String, @SerializedName("status") val status: Int ) data class SearchVideo( @SerializedName("actors") val actors: String = "", @SerializedName("addDate") val addDate: Long, @SerializedName("catId") val catId: Int, @SerializedName("channelId") val channelId: Int, @SerializedName("channelName") val channelName: String, @SerializedName("commentCount") val commentCount: Int, @SerializedName("director") val director: String = "", @SerializedName("episodesTxt") val episodesTxt: String = "", @SerializedName("favoriteCount") val favoriteCount: Int, @SerializedName("hot") val hot: Int, @SerializedName("inSeries") val inSeries: Int, @SerializedName("isEpisodes") val isEpisodes: Int, @SerializedName("isEpisodesEnd") val isEpisodesEnd: Int, @SerializedName("playLangs") val playLangs: List, @SerializedName("playResolutions") val playResolutions: List, @SerializedName("playSources") val playSources: List, @SerializedName("postYear") val postYear: Int, @SerializedName("rating") val rating: Int, @SerializedName("regionId") val regionId: Int, @SerializedName("regionName") val regionName: String, @SerializedName("shareCount") val shareCount: Int, @SerializedName("shareForced") val shareForced: Int, @SerializedName("showId") val showId: Int, @SerializedName("showIdCode") val showIdCode: String, @SerializedName("showImg") val showImg: String, @SerializedName("showTcTitle") val showTcTitle: String, @SerializedName("showTitle") val showTitle: String, @SerializedName("showTypeId") val showTypeId: Int, @SerializedName("showTypeName") val showTypeName: String = "", @SerializedName("status") val status: Int, @SerializedName("voteDown") val voteDown: Int, @SerializedName("voteUp") val voteUp: Int ) ================================================ FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/dto/VideoDetailResponse.kt ================================================ package io.github.peacefulprogram.easybangumi_nivod.dto import com.google.gson.annotations.SerializedName data class VideoDetailResponse( @SerializedName("entity") val entity: VideoDetailEntity, @SerializedName("msg") val msg: String, @SerializedName("status") val status: Int ) data class VideoDetailEntity( @SerializedName("actors") val actors: String, @SerializedName("addDate") val addDate: Long, @SerializedName("catId") val catId: Int, @SerializedName("channelId") val channelId: Int, @SerializedName("channelName") val channelName: String, @SerializedName("commentCount") val commentCount: Int, @SerializedName("director") val director: String, @SerializedName("episodesTxt") val episodesTxt: String, @SerializedName("episodesUpdateDesc") val episodesUpdateDesc: String, @SerializedName("episodesUpdateRemark") val episodesUpdateRemark: String, @SerializedName("favoriteCount") val favoriteCount: Int, @SerializedName("forceApp") val forceApp: String, @SerializedName("hot") val hot: Int, @SerializedName("inSeries") val inSeries: Int, @SerializedName("isEpisodes") val isEpisodes: Int, @SerializedName("isEpisodesEnd") val isEpisodesEnd: Int, @SerializedName("pageBgImg") val pageBgImg: String, @SerializedName("playLangs") val playLangs: List, @SerializedName("playResolutions") val playResolutions: List, @SerializedName("playSources") val playSources: List, @SerializedName("plays") val plays: List, @SerializedName("postYear") val postYear: Int, @SerializedName("rating") val rating: Int, @SerializedName("regionId") val regionId: Int, @SerializedName("regionName") val regionName: String, @SerializedName("shareCount") val shareCount: Int, @SerializedName("shareForced") val shareForced: Int, @SerializedName("shareTxt") val shareTxt: String, @SerializedName("shareUrl") val shareUrl: String, @SerializedName("showDesc") val showDesc: String, @SerializedName("showId") val showId: Int, @SerializedName("showIdCode") val showIdCode: String, @SerializedName("showImg") val showImg: String, @SerializedName("showTcTitle") val showTcTitle: String, @SerializedName("showTitle") val showTitle: String, @SerializedName("showTypeId") val showTypeId: Int, @SerializedName("showTypeName") val showTypeName: String = "", @SerializedName("status") val status: Int, @SerializedName("titleImg") val titleImg: String, @SerializedName("voteDown") val voteDown: Int, @SerializedName("voteUp") val voteUp: Int ) data class VideoDetailPlay( @SerializedName("displayName") val displayName: String, @SerializedName("episodeId") val episodeId: Int, @SerializedName("episodeName") val episodeName: String, @SerializedName("external") val `external`: Int, @SerializedName("langId") val langId: Int, @SerializedName("playIdCode") val playIdCode: String, @SerializedName("resolution") val resolution: String, @SerializedName("resolutionInt") val resolutionInt: Int, @SerializedName("seq") val seq: Int, @SerializedName("size") val size: Long, @SerializedName("sourceId") val sourceId: Int ) ================================================ FILE: extension-app/src/main/java/io/github/peacefulprogram/easybangumi_nivod/dto/VideoStreamUrlResponse.kt ================================================ package io.github.peacefulprogram.easybangumi_nivod.dto import com.google.gson.annotations.SerializedName data class VideoStreamUrlResponse( @SerializedName("entity") val entity: VideoStreamUrlEntity, @SerializedName("msg") val msg: String, @SerializedName("status") val status: Int ) data class VideoStreamUrlEntity( @SerializedName("playType") val playType: Int, @SerializedName("playUrl") val playUrl: String ) ================================================ FILE: extension-app/src/main/java/org/easybangumi/extension/EasySourceFactory.kt ================================================ package org.easybangumi.extension import com.heyanle.easybangumi4.source_api.Source import com.heyanle.easybangumi4.source_api.SourceFactory import com.heyanle.easybangumi_extension.anfun.AnfunSource import com.heyanle.easybangumi_extension.anim.AnimOneSource import com.heyanle.easybangumi_extension.ggl.GGLSource import io.github.easybangumiorg.source.aio.auete.AueteSource import io.github.easybangumiorg.source.aio.changzhang.ChangZhangSource import io.github.easybangumiorg.source.aio.fengche.FengCheSource import io.github.easybangumiorg.source.aio.libvio.LibVioSource import io.github.easybangumiorg.source.aio.xigua.XiguaSource import io.github.peacefulprogram.easybangumi_mikudm.MikudmApiSource import io.github.peacefulprogram.easybangumi_mxdm.MxdmApiSource import io.github.peacefulprogram.easybangumi_nivod.NivodApiSource /** * Created by HeYanLe on 2023/2/19 23:23. * https://github.com/heyanLE */ class EasySourceFactory: SourceFactory { override fun create(): List { return listOf( AnimOneSource(), LibVioSource(), AueteSource(), FengCheSource(), XiguaSource(), MikudmApiSource(), MxdmApiSource(), NivodApiSource(), GGLSource(), AnfunSource(), ChangZhangSource(), ) } } ================================================ FILE: extension-app/src/main/res/values/strings.xml ================================================ 纯纯看番:AllInOne ================================================ FILE: extension-app/src/main/res/xml/backup_rules.xml ================================================ ================================================ FILE: extension-app/src/main/res/xml/data_extraction_rules.xml ================================================ ================================================ FILE: gradle/wrapper/gradle-wrapper.properties ================================================ #Sun Dec 10 21:18:58 HKT 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists ================================================ FILE: gradle.properties ================================================ # Project-wide Gradle settings. # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* # any settings specified in this file. # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true # AndroidX package structure to make it clearer which packages are bundled with the # Android operating system, and which are packaged with your app's APK # https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official # Enables namespacing of each library's R class so that its R class includes only the # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library android.nonTransitiveRClass=true ================================================ FILE: gradlew ================================================ #!/usr/bin/env sh # # Copyright 2015 the original author or authors. # # 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 # # https://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. # ############################################################################## ## ## Gradle start up script for UN*X ## ############################################################################## # Attempt to set APP_HOME # Resolve links: $0 may be a link PRG="$0" # Need this for relative symlinks. while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`"/$link" fi done SAVED="`pwd`" cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME="`pwd -P`" cd "$SAVED" >/dev/null APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" warn () { echo "$*" } die () { echo echo "$*" echo exit 1 } # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false case "`uname`" in CYGWIN* ) cygwin=true ;; Darwin* ) darwin=true ;; MINGW* ) msys=true ;; NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables JAVACMD="$JAVA_HOME/jre/sh/java" else JAVACMD="$JAVA_HOME/bin/java" fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD="java" which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi # Increase the maximum file descriptors if we can. if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then MAX_FD_LIMIT=`ulimit -H -n` if [ $? -eq 0 ] ; then if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD="$MAX_FD_LIMIT" fi ulimit -n $MAX_FD if [ $? -ne 0 ] ; then warn "Could not set maximum file descriptor limit: $MAX_FD" fi else warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" fi fi # For Darwin, add options to specify how the application appears in the dock if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi # For Cygwin or MSYS, switch paths to Windows format before running java if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` SEP="" for dir in $ROOTDIRSRAW ; do ROOTDIRS="$ROOTDIRS$SEP$dir" SEP="|" done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments if [ "$GRADLE_CYGPATTERN" != "" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh i=0 for arg in "$@" ; do CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` else eval `echo args$i`="\"$arg\"" fi i=`expr $i + 1` done case $i in 0) set -- ;; 1) set -- "$args0" ;; 2) set -- "$args0" "$args1" ;; 3) set -- "$args0" "$args1" "$args2" ;; 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi # Escape application args save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" exec "$JAVACMD" "$@" ================================================ FILE: gradlew.bat ================================================ @rem @rem Copyright 2015 the original author or authors. @rem @rem Licensed under the Apache License, Version 2.0 (the "License"); @rem you may not use this file except in compliance with the License. @rem You may obtain a copy of the License at @rem @rem https://www.apache.org/licenses/LICENSE-2.0 @rem @rem Unless required by applicable law or agreed to in writing, software @rem distributed under the License is distributed on an "AS IS" BASIS, @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @rem @rem ########################################################################## @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @rem Resolve any "." and ".." in APP_HOME to make it shorter. for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. goto fail :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell if "%ERRORLEVEL%"=="0" goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal :omega ================================================ FILE: settings.gradle.kts ================================================ pluginManagement { repositories { google() mavenCentral() gradlePluginPortal() } } dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/") } maven { url = uri("https://jitpack.io") } } } rootProject.name = "EasyBangumi-Extension" include(":extension-app")