generated from easybangumiorg/EasyBangumi-ExtensionBase
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
80 changed files
with
4,475 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: release | ||
on: | ||
push: | ||
tags: | ||
- '**' | ||
workflow_dispatch: | ||
jobs: | ||
build-and-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
- name: Setup Java JDK | ||
uses: actions/[email protected] | ||
with: | ||
java-version: 17 | ||
- name: Build | ||
run: | | ||
chmod +x ./gradlew | ||
./gradlew :app:assemble | ||
- name: sign-apk | ||
uses: r0adkll/sign-android-release@v1 | ||
with: | ||
releaseDirectory: app/build/outputs/apk/release | ||
signingKeyBase64: ${{ secrets.SIGNING_KEY }} | ||
alias: ${{ secrets.KEY_ALIAS }} | ||
keyStorePassword: ${{ secrets.KEY_STORE_PWD }} | ||
keyPassword: ${{ secrets.KEY_PWD }} | ||
- name: rename-apk | ||
run: | | ||
mv 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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
extension-app/src/main/java/com/heyanle/easybangumi_extension/EasySourceFactory.kt
This file was deleted.
Oops, something went wrong.
219 changes: 219 additions & 0 deletions
219
...nsion-app/src/main/java/com/heyanle/easybangumi_extension/anfun/AnfunDetailedComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
package com.heyanle.easybangumi_extension.anfun | ||
|
||
import android.util.Log | ||
import com.heyanle.easybangumi4.source_api.ParserException | ||
import com.heyanle.easybangumi4.source_api.SourceResult | ||
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper | ||
import com.heyanle.easybangumi4.source_api.component.detailed.DetailedComponent | ||
import com.heyanle.easybangumi4.source_api.component.play.PlayComponent | ||
import com.heyanle.easybangumi4.source_api.component.update.UpdateComponent | ||
import com.heyanle.easybangumi4.source_api.entity.Cartoon | ||
import com.heyanle.easybangumi4.source_api.entity.CartoonImpl | ||
import com.heyanle.easybangumi4.source_api.entity.CartoonSummary | ||
import com.heyanle.easybangumi4.source_api.entity.Episode | ||
import com.heyanle.easybangumi4.source_api.entity.PlayLine | ||
import com.heyanle.easybangumi4.source_api.entity.PlayerInfo | ||
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper | ||
import com.heyanle.easybangumi4.source_api.utils.api.WebViewHelper | ||
import com.heyanle.easybangumi4.source_api.utils.core.SourceUtils | ||
import com.heyanle.easybangumi4.source_api.utils.core.network.GET | ||
import com.heyanle.easybangumi4.source_api.withResult | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.withTimeoutOrNull | ||
import org.jsoup.Jsoup | ||
import org.jsoup.nodes.Document | ||
|
||
/** | ||
* Created by heyanle on 2024/1/29. | ||
* https://github.com/heyanLE | ||
*/ | ||
class AnfunDetailedComponent( | ||
private val okhttpHelper: OkhttpHelper, | ||
private val webViewHelper: WebViewHelper | ||
): ComponentWrapper(), DetailedComponent, UpdateComponent, PlayComponent { | ||
|
||
|
||
override suspend fun getDetailed(summary: CartoonSummary): SourceResult<Cartoon> { | ||
return withResult(Dispatchers.IO) { | ||
detailed(getDoc(summary), summary) | ||
} | ||
} | ||
|
||
override suspend fun getPlayLine(summary: CartoonSummary): SourceResult<List<PlayLine>> { | ||
return withResult(Dispatchers.IO) { | ||
playLine(getDoc(summary), summary) | ||
} | ||
} | ||
|
||
override suspend fun getAll(summary: CartoonSummary): SourceResult<Pair<Cartoon, List<PlayLine>>> { | ||
return withResult(Dispatchers.IO) { | ||
detailed(getDoc(summary), summary) to playLine(getDoc(summary), summary) | ||
} | ||
} | ||
|
||
override suspend fun update( | ||
cartoon: Cartoon, | ||
oldPlayLine: List<PlayLine> | ||
): SourceResult<Cartoon> { | ||
return withResult(Dispatchers.IO) { | ||
|
||
when (val n = getAll(CartoonSummary(cartoon.id, cartoon.source))) { | ||
is SourceResult.Complete -> { | ||
n.data.first.apply { | ||
|
||
val newPlayLine = n.data.second | ||
|
||
if (oldPlayLine.size != newPlayLine.size) { | ||
isUpdate = true | ||
} else { | ||
isUpdate = false | ||
for (i in oldPlayLine.indices) { | ||
if (oldPlayLine[i].episode.size != newPlayLine[i].episode.size) { | ||
isUpdate = true | ||
break | ||
} | ||
} | ||
} | ||
} | ||
} | ||
is SourceResult.Error -> { | ||
throw n.throwable | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun getDoc(summary: CartoonSummary): Document { | ||
val d = okhttpHelper.cloudflareWebViewClient.newCall(GET(SourceUtils.urlParser(AnfunSource.ROOT_URL, "/anime/${summary.id}.html"))) | ||
.execute().body?.string() ?: throw NullPointerException() | ||
return Jsoup.parse(d) | ||
} | ||
private fun playLine(document: Document, summary: CartoonSummary): List<PlayLine> { | ||
Log.e("TAG","------->>>>>>>playLine") | ||
val res = arrayListOf<PlayLine>() | ||
val module = document.select(".hl-play-source").first() ?: return res | ||
val playNameList = module.select(".hl-plays-wrap").first()?.select("a") ?: return res | ||
val playEpisodeList = module.select(".hl-tabs-box") | ||
for (index in 0..playNameList.size) { | ||
val playName = playNameList.getOrNull(index)?.text() | ||
val playEpisode = playEpisodeList.getOrNull(index) | ||
if (playName != null && playEpisode != null) { | ||
val results = playEpisode.select("li").select("a") | ||
val es = arrayListOf<Episode>() | ||
|
||
for (i in results.indices) { | ||
es.add(Episode((i+1).toString(), results[i].text(), i)) // title | ||
|
||
} | ||
val playLine = PlayLine( | ||
id = (index + 1).toString(), | ||
label = playName, | ||
episode = es | ||
) | ||
res.add(playLine) | ||
} | ||
} | ||
return res | ||
} | ||
|
||
override suspend fun getPlayInfo( | ||
summary: CartoonSummary, | ||
playLine: PlayLine, | ||
episode: Episode | ||
): SourceResult<PlayerInfo> { | ||
Log.e("TAG","------->>>>>>>开始播放") | ||
return withResult(Dispatchers.IO) { | ||
|
||
// Log.e("TAG","${playUrlTemp[playLine.id.toInt()]}") // [/play/632-1-1.html] | ||
val url = SourceUtils.urlParser(AnfunSource.ROOT_URL, "/play/${summary.id}-${playLine.id}-${episode.id}") | ||
// Log.e("TAG", url) // https://www.anfuns.cc/play/632-1-1.html | ||
var videoUrl = webViewHelper.interceptResource( | ||
url, regex = "https://www.anfuns.cc/vapi/AIRA/mui.php?.*" | ||
) | ||
Log.e("TAG", "地址:$videoUrl") | ||
if (videoUrl.isNotEmpty()) { | ||
when { | ||
videoUrl.contains(".m3u8&") -> videoUrl = videoUrl.substringAfter("url=") | ||
.substringBefore("&") | ||
videoUrl.contains(".mp4") -> videoUrl = videoUrl.substringAfter("url=") | ||
.substringBefore("&next=") | ||
} | ||
Log.e("TAG", "解析后url:$videoUrl") | ||
if (videoUrl.indexOf(".mp4") != -1){ | ||
PlayerInfo( | ||
decodeType = PlayerInfo.DECODE_TYPE_OTHER, | ||
uri = SourceUtils.urlParser(AnfunSource.ROOT_URL,videoUrl) | ||
) | ||
}else{ | ||
PlayerInfo( | ||
decodeType = PlayerInfo.DECODE_TYPE_HLS, | ||
uri = SourceUtils.urlParser(AnfunSource.ROOT_URL,videoUrl) | ||
) | ||
} | ||
}else{ | ||
throw ParserException("Unknown") | ||
} | ||
} | ||
} | ||
|
||
private fun detailed(document: Document, summary: CartoonSummary): Cartoon { | ||
Log.e("TAG","------->>>>>>>detailed") | ||
|
||
var desc = "" | ||
var update = 0 | ||
var status = 0 | ||
|
||
val cover = document.select(".hl-dc-pic").select("span").attr("data-original") | ||
val title = document.select(".hl-dc-headwrap").select(".hl-dc-title").text() | ||
//document.select(".hl-dc-headwrap").select(".hl-dc-sub").text() | ||
// 更新状况 | ||
val upStateItems = document.select(".hl-dc-content") | ||
.select(".hl-vod-data").select(".hl-full-box").select("ul").select("li") | ||
for (upStateEm in upStateItems){ | ||
val t = upStateEm.text() | ||
when{ | ||
t.contains("状态:") -> { | ||
status = | ||
if (t.startsWith("连载")) Cartoon.STATUS_ONGOING | ||
else if (t.startsWith("全")) Cartoon.STATUS_COMPLETED | ||
else Cartoon.STATUS_UNKNOWN | ||
val isTheater = title.contains("剧场版") | ||
update = | ||
if (isTheater) { | ||
if (status == Cartoon.STATUS_COMPLETED) { | ||
Cartoon.UPDATE_STRATEGY_NEVER | ||
} else { | ||
Cartoon.UPDATE_STRATEGY_ONLY_STRICT | ||
} | ||
} else { | ||
if (status == Cartoon.STATUS_COMPLETED) { | ||
Cartoon.UPDATE_STRATEGY_ONLY_STRICT | ||
} else { | ||
Cartoon.UPDATE_STRATEGY_ALWAYS | ||
} | ||
} | ||
} | ||
t.contains("简介:") -> desc = t | ||
} | ||
} | ||
|
||
return CartoonImpl( | ||
id = summary.id, | ||
url = SourceUtils.urlParser(AnfunSource.ROOT_URL, "/anime/${summary.id}.html"), | ||
source = summary.source, | ||
|
||
title = title, | ||
coverUrl = cover, | ||
|
||
intro = "", | ||
description = desc, | ||
|
||
genre = "", | ||
|
||
status = status, | ||
updateStrategy = update, | ||
) | ||
} | ||
|
||
|
||
} |
49 changes: 49 additions & 0 deletions
49
extension-app/src/main/java/com/heyanle/easybangumi_extension/anfun/AnfunListComponent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.heyanle.easybangumi_extension.anfun | ||
|
||
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper | ||
import com.heyanle.easybangumi4.source_api.entity.CartoonCover | ||
import com.heyanle.easybangumi4.source_api.entity.CartoonCoverImpl | ||
import com.heyanle.easybangumi4.source_api.utils.api.OkhttpHelper | ||
import com.heyanle.easybangumi4.source_api.utils.core.SourceUtils | ||
import org.jsoup.select.Elements | ||
|
||
/** | ||
* Created by heyanle on 2024/1/28. | ||
* https://github.com/heyanLE | ||
*/ | ||
class AnfunListComponent( | ||
private val okhttpHelper: OkhttpHelper, | ||
) : ComponentWrapper() { | ||
|
||
companion object { | ||
const val ROOT_URL = "https://www.anfuns.cc" | ||
} | ||
|
||
suspend fun listPage( | ||
element: Elements, | ||
): Pair<Int?, List<CartoonCover>> { | ||
val r = arrayListOf<CartoonCover>() | ||
for (video in element) { | ||
video.apply { | ||
val name = select("a").attr("title") | ||
val videoUrl = select("a").attr("href") | ||
val coverUrl = select("a").attr("data-original") | ||
val episode = select(".remarks").text() | ||
val id = videoUrl.subSequence(7, videoUrl.length - 5).toString() | ||
if (!name.isNullOrBlank() && !videoUrl.isNullOrBlank() && !coverUrl.isNullOrBlank()) { | ||
val b = CartoonCoverImpl( | ||
id = id, | ||
source = source.key, | ||
url = videoUrl, | ||
title = name, | ||
intro = episode ?: "", | ||
coverUrl = SourceUtils.urlParser(ROOT_URL, coverUrl) | ||
) | ||
r.add(b) | ||
} | ||
} | ||
} | ||
return Pair(null, r) | ||
} | ||
|
||
} |
Oops, something went wrong.