diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index ab7ced6..644713b 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -92,7 +92,11 @@
+
diff --git a/app/src/main/java/soko/ekibun/bangumi/api/bangumi/Bangumi.kt b/app/src/main/java/soko/ekibun/bangumi/api/bangumi/Bangumi.kt
index c7178a5..d47a707 100644
--- a/app/src/main/java/soko/ekibun/bangumi/api/bangumi/Bangumi.kt
+++ b/app/src/main/java/soko/ekibun/bangumi/api/bangumi/Bangumi.kt
@@ -1,7 +1,6 @@
package soko.ekibun.bangumi.api.bangumi
import android.annotation.SuppressLint
-import android.util.Log
import android.webkit.CookieManager
import okhttp3.FormBody
import org.jsoup.Jsoup
@@ -24,119 +23,14 @@ import kotlin.math.min
interface Bangumi {
- @GET("/search/subject/{keywords}")
- fun search(@Path("keywords") keywords: String,
- @SubjectType.SubjectType @Query("type") type: Int = SubjectType.ALL,
- @Query("start")start: Int = 0,
- @Query("max_results")max_results: Int = 10,
- @Header("cookie") cookie: String = "chii_searchDateLine=0"
- ): Call
-
- @GET("/subject/{id}")
- fun subject(@Path("id") id: Int,
- @ResponseGroup.ResponseGroup @Query("responseGroup") responseGroup: String = ResponseGroup.LARGE
- ): Call
-
- @GET("/subject/{id}/ep")
- fun subjectEp(@Path("id") id: Int): Call
-
- @GET("/user/{username}")
- fun user(@Path("username") id: String
- ): Call
-
@GET("/user/{username}/collection")
fun collection(@Path("username") username: String,
@Query("cat") cat: String = "all_watching"
): Call>
- @GET("/collection/{subject_id}")
- fun collectionStatus(@Path("subject_id") subject_id: Int,
- @Query("access_token") access_token: String
- ): Call
-
- @GET("/ep/{id}/status/{status}")
- fun updateProgress(@Path("id") id: Int,
- @SubjectProgress.EpisodeProgress.EpisodeStatus.Companion.EpStatusType
- @Path("status") status: String,
- @Query("access_token") access_token: String
- ): Call
-
- @FormUrlEncoded
- @POST("/subject/{subject_id}/update/watched_eps")
- fun updateWatchEps(@Path("subject_id") subject_id: Int,
- @Field("watched_eps") watched_eps: String,
- @Query("access_token") access_token: String
- ): Call
-
- @FormUrlEncoded
- @POST("/ep/{id}/status/{status}")
- fun updateProgress(@Path("id") id: Int,
- @SubjectProgress.EpisodeProgress.EpisodeStatus.Companion.EpStatusType
- @Path("status") status: String,
- @Query("access_token") access_token: String,
- @Field("ep_id") epIds: String
- ): Call
-
- @GET("/user/{username}/progress")
- fun progress(@Path("username") username: String,
- @Query("subject_id") subject_id: Int,
- @Query("access_token") access_token: String
- ): Call
-
- @FormUrlEncoded
- @POST("/collection/{subject_id}/update")
- fun updateCollectionStatus(@Path("subject_id") subject_id: Int,
- @Field("access_token") access_token: String,
- @Field("status") status: String,
- @Field("tags") tags: String,
- @Field("comment") comment: String?,
- @Field("rating") rating: Int,
- @Field("privacy") privacy: Int = 0
- ): Call
-
- @FormUrlEncoded
- @POST("/oauth/access_token")
- fun accessToken(@Field("code") code : String,
- @Field("redirect_uri") redirect_uri: String = REDIRECT_URL,
- @Field("grant_type") grant_type : String = "authorization_code",
- @Field("client_id") client_id : String = APP_ID,
- @Field("client_secret") client_secret : String = APP_SECRET
- ): Call
-
- @FormUrlEncoded
- @POST("/oauth/access_token")
- fun refreshToken(@Field("refresh_token") refresh_token : String,
- @Field("redirect_uri") redirect_uri: String = REDIRECT_URL,
- @Field("grant_type") grant_type : String = "refresh_token",
- @Field("client_id") client_id : String = APP_ID,
- @Field("client_secret") client_secret : String = APP_SECRET
- ): Call
-
- /*
- @FormUrlEncoded
- @POST("/oauth/token_status")
- fun tokenStatus(@Field("access_token") access_token : String
- ): Call
- */
-
- @GET("/calendar")
- fun calendar(): Call>
-
- /*
- @GET("/{subject_type}/list/{username}/{collection_status}")
- fun getCollectionList(@SubjectType.SubjectTypeName @Path("subject_type")subject_type: String,
- @Path("username") username: String,
- @CollectionStatusType.CollectionStatusType @Path("collection_status") collection_status: String,
- @Query("page")page: Int = 1
- ): Call>
- */
-
companion object {
const val SERVER = "https://bgm.tv"
private const val SERVER_API = "https://api.bgm.tv"
- const val APP_ID = "bgm2315af5554b7f887"
- const val APP_SECRET = "adaf4941f83f2fb3c4336ee80a087f75"
- const val REDIRECT_URL = "bangumi://redirect"
fun createInstance(): Bangumi{
return Retrofit.Builder().baseUrl(SERVER_API)
.addConverterFactory(GsonConverterFactory.create())
@@ -199,8 +93,9 @@ interface Bangumi {
val infobox = doc.select("#infobox li")?.map{
val tip = it.selectFirst("span.tip")?.text()?:""
- Pair(tip.trim(':',' '),
- it.text().substring(tip.length).trim())
+ var value = ""
+ it.childNodes()?.forEach { if(it !is Element || !it.hasClass("tip")) value += it.outerHtml() }
+ Pair(tip.trim(':',' '), value.trim())
}
var eps_count = infobox?.firstOrNull { it.first == "话数" }?.second?.toIntOrNull()?:subject.eps_count
//air-date
@@ -443,8 +338,8 @@ interface Bangumi {
fun browserAirTime(@SubjectType.SubjectTypeName subject_type: String,
year: Int, month: Int,
- page: Int = 1, ua: String): Call>{
- return ApiHelper.buildHttpCall("$SERVER/$subject_type/browser/airtime/$year-$month?page=$page", mapOf("User-Agent" to ua)){
+ page: Int = 1, ua: String, sub_cat: String): Call>{
+ return ApiHelper.buildHttpCall("$SERVER/$subject_type/browser${if(sub_cat.isEmpty())"" else "/$sub_cat"}/airtime/$year-$month?page=$page", mapOf("User-Agent" to ua)){
val doc = Jsoup.parse(it.body()?.string()?:"")
val ret = ArrayList()
doc.select(".item")?.forEach{
diff --git a/app/src/main/java/soko/ekibun/bangumi/api/bangumi/bean/SubjectType.kt b/app/src/main/java/soko/ekibun/bangumi/api/bangumi/bean/SubjectType.kt
index b63b5aa..0a0f06f 100644
--- a/app/src/main/java/soko/ekibun/bangumi/api/bangumi/bean/SubjectType.kt
+++ b/app/src/main/java/soko/ekibun/bangumi/api/bangumi/bean/SubjectType.kt
@@ -26,7 +26,8 @@ object SubjectType{
ANIME to NAME_ANIME,
MUSIC to NAME_MUSIC,
GAME to NAME_GAME,
- REAL to NAME_REAL
+ REAL to NAME_REAL,
+ BOOK to NAME_BOOK
)
@SuppressLint("SwitchIntDef")
diff --git a/app/src/main/java/soko/ekibun/bangumi/api/tinygrail/Tinygrail.kt b/app/src/main/java/soko/ekibun/bangumi/api/tinygrail/Tinygrail.kt
index c342ad5..ffeacea 100644
--- a/app/src/main/java/soko/ekibun/bangumi/api/tinygrail/Tinygrail.kt
+++ b/app/src/main/java/soko/ekibun/bangumi/api/tinygrail/Tinygrail.kt
@@ -2,6 +2,10 @@ package soko.ekibun.bangumi.api.tinygrail
import org.jsoup.Jsoup
import retrofit2.Call
+import retrofit2.Retrofit
+import retrofit2.converter.gson.GsonConverterFactory
+import retrofit2.http.GET
+import retrofit2.http.Path
import soko.ekibun.bangumi.api.ApiHelper
import soko.ekibun.bangumi.api.bangumi.Bangumi
import soko.ekibun.bangumi.api.bangumi.bean.Episode
@@ -9,9 +13,19 @@ import soko.ekibun.bangumi.api.bangumi.bean.Images
import soko.ekibun.bangumi.api.bangumi.bean.Subject
import soko.ekibun.bangumi.api.bangumi.bean.SubjectType
import soko.ekibun.bangumi.api.tinygrail.bean.OnAir
+import soko.ekibun.bangumi.api.tinygrail.bean.OnAirInfo
interface Tinygrail{
+ @GET("/api/episode/subject/{id}")
+ fun onAirInfo(@Path("id") id: Int): Call
+
companion object {
+ fun createInstance(): Tinygrail{
+ return Retrofit.Builder().baseUrl("https://www.tinygrail.com")
+ .addConverterFactory(GsonConverterFactory.create())
+ .build().create(Tinygrail::class.java)
+ }
+
fun onAirList(): Call