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
heyanlin
committed
May 23, 2024
1 parent
a584850
commit 1fd0636
Showing
10 changed files
with
148 additions
and
68 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
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
50 changes: 50 additions & 0 deletions
50
...ion-app/src/main/java/io/github/easybangumiorg/source/aio/fengche/FengCheHostUrlHelper.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,50 @@ | ||
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 | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
} |
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
17 changes: 17 additions & 0 deletions
17
extension-app/src/main/java/io/github/easybangumiorg/source/aio/fengche/FengChePrefer.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,17 @@ | ||
package io.github.easybangumiorg.source.aio.fengche | ||
|
||
import com.heyanle.easybangumi4.source_api.component.ComponentWrapper | ||
import com.heyanle.easybangumi4.source_api.component.preference.PreferenceComponent | ||
import com.heyanle.easybangumi4.source_api.component.preference.SourcePreference | ||
import com.heyanle.easybangumi4.source_api.component.search.SearchComponent | ||
|
||
/** | ||
* Created by heyanlin on 2024/5/23. | ||
*/ | ||
class FengChePrefer : ComponentWrapper(), PreferenceComponent { | ||
|
||
override fun register(): List<SourcePreference> = listOf( | ||
SourcePreference.Switch("自动从 wedm.cc 获取网址", "auto_host_url", true), | ||
SourcePreference.Edit("自定义网址(当自动关闭时才有效)", "BaseUrl", "http://www.fcdm9.com/"), | ||
) | ||
} |
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