|
@@ -39,43 +39,45 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
|
|
|
return if (query.startsWith(PREFIX_MY)) {
|
|
|
val realQuery = query.removePrefix(PREFIX_MY)
|
|
|
getList()
|
|
|
- .flatMap { Observable.from(it) }
|
|
|
- .filter { it.title.contains(realQuery, true) }
|
|
|
- .toList()
|
|
|
+ .flatMap { Observable.from(it) }
|
|
|
+ .filter { it.title.contains(realQuery, true) }
|
|
|
+ .toList()
|
|
|
} else {
|
|
|
client.newCall(GET(searchUrl(query)))
|
|
|
- .asObservable()
|
|
|
- .flatMap { response ->
|
|
|
- Observable.from(Jsoup.parse(response.consumeBody())
|
|
|
- .select("div.js-categories-seasonal.js-block-list.list")
|
|
|
- .select("table").select("tbody")
|
|
|
- .select("tr").drop(1))
|
|
|
- }
|
|
|
- .filter { row ->
|
|
|
- row.select(TD)[2].text() != "Novel"
|
|
|
- }
|
|
|
- .map { row ->
|
|
|
- TrackSearch.create(TrackManager.MYANIMELIST).apply {
|
|
|
- title = row.searchTitle()
|
|
|
- media_id = row.searchMediaId()
|
|
|
- total_chapters = row.searchTotalChapters()
|
|
|
- summary = row.searchSummary()
|
|
|
- cover_url = row.searchCoverUrl()
|
|
|
- tracking_url = mangaUrl(media_id)
|
|
|
- publishing_status = row.searchPublishingStatus()
|
|
|
- publishing_type = row.searchPublishingType()
|
|
|
- start_date = row.searchStartDate()
|
|
|
- }
|
|
|
+ .asObservable()
|
|
|
+ .flatMap { response ->
|
|
|
+ Observable.from(
|
|
|
+ Jsoup.parse(response.consumeBody())
|
|
|
+ .select("div.js-categories-seasonal.js-block-list.list")
|
|
|
+ .select("table").select("tbody")
|
|
|
+ .select("tr").drop(1)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ .filter { row ->
|
|
|
+ row.select(TD)[2].text() != "Novel"
|
|
|
+ }
|
|
|
+ .map { row ->
|
|
|
+ TrackSearch.create(TrackManager.MYANIMELIST).apply {
|
|
|
+ title = row.searchTitle()
|
|
|
+ media_id = row.searchMediaId()
|
|
|
+ total_chapters = row.searchTotalChapters()
|
|
|
+ summary = row.searchSummary()
|
|
|
+ cover_url = row.searchCoverUrl()
|
|
|
+ tracking_url = mangaUrl(media_id)
|
|
|
+ publishing_status = row.searchPublishingStatus()
|
|
|
+ publishing_type = row.searchPublishingType()
|
|
|
+ start_date = row.searchStartDate()
|
|
|
}
|
|
|
- .toList()
|
|
|
+ }
|
|
|
+ .toList()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
fun addLibManga(track: Track): Observable<Track> {
|
|
|
return Observable.defer {
|
|
|
authClient.newCall(POST(url = addUrl(), body = mangaPostPayload(track)))
|
|
|
- .asObservableSuccess()
|
|
|
- .map { track }
|
|
|
+ .asObservableSuccess()
|
|
|
+ .map { track }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -95,40 +97,40 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
|
|
|
|
|
|
// Update remote
|
|
|
authClient.newCall(POST(url = editPageUrl(track.media_id), body = mangaEditPostBody(editData)))
|
|
|
- .asObservableSuccess()
|
|
|
- .map {
|
|
|
- track
|
|
|
- }
|
|
|
+ .asObservableSuccess()
|
|
|
+ .map {
|
|
|
+ track
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
fun findLibManga(track: Track): Observable<Track?> {
|
|
|
return authClient.newCall(GET(url = editPageUrl(track.media_id)))
|
|
|
- .asObservable()
|
|
|
- .map { response ->
|
|
|
- var libTrack: Track? = null
|
|
|
- response.use {
|
|
|
- if (it.priorResponse?.isRedirect != true) {
|
|
|
- val trackForm = Jsoup.parse(it.consumeBody())
|
|
|
-
|
|
|
- libTrack = Track.create(TrackManager.MYANIMELIST).apply {
|
|
|
- last_chapter_read = trackForm.select("#add_manga_num_read_chapters").`val`().toInt()
|
|
|
- total_chapters = trackForm.select("#totalChap").text().toInt()
|
|
|
- status = trackForm.select("#add_manga_status > option[selected]").`val`().toInt()
|
|
|
- score = trackForm.select("#add_manga_score > option[selected]").`val`().toFloatOrNull()
|
|
|
- ?: 0f
|
|
|
- started_reading_date = trackForm.searchDatePicker("#add_manga_start_date")
|
|
|
- finished_reading_date = trackForm.searchDatePicker("#add_manga_finish_date")
|
|
|
- }
|
|
|
+ .asObservable()
|
|
|
+ .map { response ->
|
|
|
+ var libTrack: Track? = null
|
|
|
+ response.use {
|
|
|
+ if (it.priorResponse?.isRedirect != true) {
|
|
|
+ val trackForm = Jsoup.parse(it.consumeBody())
|
|
|
+
|
|
|
+ libTrack = Track.create(TrackManager.MYANIMELIST).apply {
|
|
|
+ last_chapter_read = trackForm.select("#add_manga_num_read_chapters").`val`().toInt()
|
|
|
+ total_chapters = trackForm.select("#totalChap").text().toInt()
|
|
|
+ status = trackForm.select("#add_manga_status > option[selected]").`val`().toInt()
|
|
|
+ score = trackForm.select("#add_manga_score > option[selected]").`val`().toFloatOrNull()
|
|
|
+ ?: 0f
|
|
|
+ started_reading_date = trackForm.searchDatePicker("#add_manga_start_date")
|
|
|
+ finished_reading_date = trackForm.searchDatePicker("#add_manga_finish_date")
|
|
|
}
|
|
|
}
|
|
|
- libTrack
|
|
|
}
|
|
|
+ libTrack
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
fun getLibManga(track: Track): Observable<Track> {
|
|
|
return findLibManga(track)
|
|
|
- .map { it ?: throw Exception("Could not find manga") }
|
|
|
+ .map { it ?: throw Exception("Could not find manga") }
|
|
|
}
|
|
|
|
|
|
fun login(username: String, password: String): String {
|
|
@@ -143,8 +145,8 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
|
|
|
val response = client.newCall(GET(loginUrl())).execute()
|
|
|
|
|
|
return Jsoup.parse(response.consumeBody())
|
|
|
- .select("meta[name=csrf_token]")
|
|
|
- .attr("content")
|
|
|
+ .select("meta[name=csrf_token]")
|
|
|
+ .attr("content")
|
|
|
}
|
|
|
|
|
|
private fun login(username: String, password: String, csrf: String) {
|
|
@@ -157,45 +159,45 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
|
|
|
|
|
|
private fun getList(): Observable<List<TrackSearch>> {
|
|
|
return getListUrl()
|
|
|
- .flatMap { url ->
|
|
|
- getListXml(url)
|
|
|
- }
|
|
|
- .flatMap { doc ->
|
|
|
- Observable.from(doc.select("manga"))
|
|
|
- }
|
|
|
- .map {
|
|
|
- TrackSearch.create(TrackManager.MYANIMELIST).apply {
|
|
|
- title = it.selectText("manga_title")!!
|
|
|
- media_id = it.selectInt("manga_mangadb_id")
|
|
|
- last_chapter_read = it.selectInt("my_read_chapters")
|
|
|
- status = getStatus(it.selectText("my_status")!!)
|
|
|
- score = it.selectInt("my_score").toFloat()
|
|
|
- total_chapters = it.selectInt("manga_chapters")
|
|
|
- tracking_url = mangaUrl(media_id)
|
|
|
- started_reading_date = it.searchDateXml("my_start_date")
|
|
|
- finished_reading_date = it.searchDateXml("my_finish_date")
|
|
|
- }
|
|
|
+ .flatMap { url ->
|
|
|
+ getListXml(url)
|
|
|
+ }
|
|
|
+ .flatMap { doc ->
|
|
|
+ Observable.from(doc.select("manga"))
|
|
|
+ }
|
|
|
+ .map {
|
|
|
+ TrackSearch.create(TrackManager.MYANIMELIST).apply {
|
|
|
+ title = it.selectText("manga_title")!!
|
|
|
+ media_id = it.selectInt("manga_mangadb_id")
|
|
|
+ last_chapter_read = it.selectInt("my_read_chapters")
|
|
|
+ status = getStatus(it.selectText("my_status")!!)
|
|
|
+ score = it.selectInt("my_score").toFloat()
|
|
|
+ total_chapters = it.selectInt("manga_chapters")
|
|
|
+ tracking_url = mangaUrl(media_id)
|
|
|
+ started_reading_date = it.searchDateXml("my_start_date")
|
|
|
+ finished_reading_date = it.searchDateXml("my_finish_date")
|
|
|
}
|
|
|
- .toList()
|
|
|
+ }
|
|
|
+ .toList()
|
|
|
}
|
|
|
|
|
|
private fun getListUrl(): Observable<String> {
|
|
|
return authClient.newCall(POST(url = exportListUrl(), body = exportPostBody()))
|
|
|
- .asObservable()
|
|
|
- .map { response ->
|
|
|
- baseUrl + Jsoup.parse(response.consumeBody())
|
|
|
- .select("div.goodresult")
|
|
|
- .select("a")
|
|
|
- .attr("href")
|
|
|
- }
|
|
|
+ .asObservable()
|
|
|
+ .map { response ->
|
|
|
+ baseUrl + Jsoup.parse(response.consumeBody())
|
|
|
+ .select("div.goodresult")
|
|
|
+ .select("a")
|
|
|
+ .attr("href")
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private fun getListXml(url: String): Observable<Document> {
|
|
|
return authClient.newCall(GET(url))
|
|
|
- .asObservable()
|
|
|
- .map { response ->
|
|
|
- Jsoup.parse(response.consumeXmlBody(), "", Parser.xmlParser())
|
|
|
- }
|
|
|
+ .asObservable()
|
|
|
+ .map { response ->
|
|
|
+ Jsoup.parse(response.consumeXmlBody(), "", Parser.xmlParser())
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private fun Response.consumeBody(): String? {
|
|
@@ -222,28 +224,28 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
|
|
|
val tables = page.select("form#main-form table")
|
|
|
|
|
|
return MyAnimeListEditData(
|
|
|
- entry_id = tables[0].select("input[name=entry_id]").`val`(), // Always 0
|
|
|
- manga_id = tables[0].select("#manga_id").`val`(),
|
|
|
- status = tables[0].select("#add_manga_status > option[selected]").`val`(),
|
|
|
- num_read_volumes = tables[0].select("#add_manga_num_read_volumes").`val`(),
|
|
|
- last_completed_vol = tables[0].select("input[name=last_completed_vol]").`val`(), // Always empty
|
|
|
- num_read_chapters = tables[0].select("#add_manga_num_read_chapters").`val`(),
|
|
|
- score = tables[0].select("#add_manga_score > option[selected]").`val`(),
|
|
|
- start_date_month = tables[0].select("#add_manga_start_date_month > option[selected]").`val`(),
|
|
|
- start_date_day = tables[0].select("#add_manga_start_date_day > option[selected]").`val`(),
|
|
|
- start_date_year = tables[0].select("#add_manga_start_date_year > option[selected]").`val`(),
|
|
|
- finish_date_month = tables[0].select("#add_manga_finish_date_month > option[selected]").`val`(),
|
|
|
- finish_date_day = tables[0].select("#add_manga_finish_date_day > option[selected]").`val`(),
|
|
|
- finish_date_year = tables[0].select("#add_manga_finish_date_year > option[selected]").`val`(),
|
|
|
- tags = tables[1].select("#add_manga_tags").`val`(),
|
|
|
- priority = tables[1].select("#add_manga_priority > option[selected]").`val`(),
|
|
|
- storage_type = tables[1].select("#add_manga_storage_type > option[selected]").`val`(),
|
|
|
- num_retail_volumes = tables[1].select("#add_manga_num_retail_volumes").`val`(),
|
|
|
- num_read_times = tables[1].select("#add_manga_num_read_times").`val`(),
|
|
|
- reread_value = tables[1].select("#add_manga_reread_value > option[selected]").`val`(),
|
|
|
- comments = tables[1].select("#add_manga_comments").`val`(),
|
|
|
- is_asked_to_discuss = tables[1].select("#add_manga_is_asked_to_discuss > option[selected]").`val`(),
|
|
|
- sns_post_type = tables[1].select("#add_manga_sns_post_type > option[selected]").`val`()
|
|
|
+ entry_id = tables[0].select("input[name=entry_id]").`val`(), // Always 0
|
|
|
+ manga_id = tables[0].select("#manga_id").`val`(),
|
|
|
+ status = tables[0].select("#add_manga_status > option[selected]").`val`(),
|
|
|
+ num_read_volumes = tables[0].select("#add_manga_num_read_volumes").`val`(),
|
|
|
+ last_completed_vol = tables[0].select("input[name=last_completed_vol]").`val`(), // Always empty
|
|
|
+ num_read_chapters = tables[0].select("#add_manga_num_read_chapters").`val`(),
|
|
|
+ score = tables[0].select("#add_manga_score > option[selected]").`val`(),
|
|
|
+ start_date_month = tables[0].select("#add_manga_start_date_month > option[selected]").`val`(),
|
|
|
+ start_date_day = tables[0].select("#add_manga_start_date_day > option[selected]").`val`(),
|
|
|
+ start_date_year = tables[0].select("#add_manga_start_date_year > option[selected]").`val`(),
|
|
|
+ finish_date_month = tables[0].select("#add_manga_finish_date_month > option[selected]").`val`(),
|
|
|
+ finish_date_day = tables[0].select("#add_manga_finish_date_day > option[selected]").`val`(),
|
|
|
+ finish_date_year = tables[0].select("#add_manga_finish_date_year > option[selected]").`val`(),
|
|
|
+ tags = tables[1].select("#add_manga_tags").`val`(),
|
|
|
+ priority = tables[1].select("#add_manga_priority > option[selected]").`val`(),
|
|
|
+ storage_type = tables[1].select("#add_manga_storage_type > option[selected]").`val`(),
|
|
|
+ num_retail_volumes = tables[1].select("#add_manga_num_retail_volumes").`val`(),
|
|
|
+ num_read_times = tables[1].select("#add_manga_num_read_times").`val`(),
|
|
|
+ reread_value = tables[1].select("#add_manga_reread_value > option[selected]").`val`(),
|
|
|
+ comments = tables[1].select("#add_manga_comments").`val`(),
|
|
|
+ is_asked_to_discuss = tables[1].select("#add_manga_is_asked_to_discuss > option[selected]").`val`(),
|
|
|
+ sns_post_type = tables[1].select("#add_manga_sns_post_type > option[selected]").`val`()
|
|
|
)
|
|
|
}
|
|
|
|
|
@@ -259,98 +261,99 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
|
|
|
private fun mangaUrl(remoteId: Int) = baseMangaUrl + remoteId
|
|
|
|
|
|
private fun loginUrl() = Uri.parse(baseUrl).buildUpon()
|
|
|
- .appendPath("login.php")
|
|
|
- .toString()
|
|
|
+ .appendPath("login.php")
|
|
|
+ .toString()
|
|
|
|
|
|
private fun searchUrl(query: String): String {
|
|
|
val col = "c[]"
|
|
|
return Uri.parse(baseUrl).buildUpon()
|
|
|
- .appendPath("manga.php")
|
|
|
- .appendQueryParameter("q", query)
|
|
|
- .appendQueryParameter(col, "a")
|
|
|
- .appendQueryParameter(col, "b")
|
|
|
- .appendQueryParameter(col, "c")
|
|
|
- .appendQueryParameter(col, "d")
|
|
|
- .appendQueryParameter(col, "e")
|
|
|
- .appendQueryParameter(col, "g")
|
|
|
- .toString()
|
|
|
+ .appendPath("manga.php")
|
|
|
+ .appendQueryParameter("q", query)
|
|
|
+ .appendQueryParameter(col, "a")
|
|
|
+ .appendQueryParameter(col, "b")
|
|
|
+ .appendQueryParameter(col, "c")
|
|
|
+ .appendQueryParameter(col, "d")
|
|
|
+ .appendQueryParameter(col, "e")
|
|
|
+ .appendQueryParameter(col, "g")
|
|
|
+ .toString()
|
|
|
}
|
|
|
|
|
|
private fun exportListUrl() = Uri.parse(baseUrl).buildUpon()
|
|
|
- .appendPath("panel.php")
|
|
|
- .appendQueryParameter("go", "export")
|
|
|
- .toString()
|
|
|
+ .appendPath("panel.php")
|
|
|
+ .appendQueryParameter("go", "export")
|
|
|
+ .toString()
|
|
|
|
|
|
private fun editPageUrl(mediaId: Int) = Uri.parse(baseModifyListUrl).buildUpon()
|
|
|
- .appendPath(mediaId.toString())
|
|
|
- .appendPath("edit")
|
|
|
- .toString()
|
|
|
+ .appendPath(mediaId.toString())
|
|
|
+ .appendPath("edit")
|
|
|
+ .toString()
|
|
|
|
|
|
private fun addUrl() = Uri.parse(baseModifyListUrl).buildUpon()
|
|
|
- .appendPath("add.json")
|
|
|
- .toString()
|
|
|
+ .appendPath("add.json")
|
|
|
+ .toString()
|
|
|
|
|
|
private fun loginPostBody(username: String, password: String, csrf: String): RequestBody {
|
|
|
return FormBody.Builder()
|
|
|
- .add("user_name", username)
|
|
|
- .add("password", password)
|
|
|
- .add("cookie", "1")
|
|
|
- .add("sublogin", "Login")
|
|
|
- .add("submit", "1")
|
|
|
- .add(CSRF, csrf)
|
|
|
- .build()
|
|
|
+ .add("user_name", username)
|
|
|
+ .add("password", password)
|
|
|
+ .add("cookie", "1")
|
|
|
+ .add("sublogin", "Login")
|
|
|
+ .add("submit", "1")
|
|
|
+ .add(CSRF, csrf)
|
|
|
+ .build()
|
|
|
}
|
|
|
|
|
|
private fun exportPostBody(): RequestBody {
|
|
|
return FormBody.Builder()
|
|
|
- .add("type", "2")
|
|
|
- .add("subexport", "Export My List")
|
|
|
- .build()
|
|
|
+ .add("type", "2")
|
|
|
+ .add("subexport", "Export My List")
|
|
|
+ .build()
|
|
|
}
|
|
|
|
|
|
private fun mangaPostPayload(track: Track): RequestBody {
|
|
|
val body = JSONObject()
|
|
|
- .put("manga_id", track.media_id)
|
|
|
- .put("status", track.status)
|
|
|
- .put("score", track.score)
|
|
|
- .put("num_read_chapters", track.last_chapter_read)
|
|
|
+ .put("manga_id", track.media_id)
|
|
|
+ .put("status", track.status)
|
|
|
+ .put("score", track.score)
|
|
|
+ .put("num_read_chapters", track.last_chapter_read)
|
|
|
|
|
|
return body.toString().toRequestBody("application/json; charset=utf-8".toMediaTypeOrNull())
|
|
|
}
|
|
|
|
|
|
private fun mangaEditPostBody(track: MyAnimeListEditData): RequestBody {
|
|
|
return FormBody.Builder()
|
|
|
- .add("entry_id", track.entry_id)
|
|
|
- .add("manga_id", track.manga_id)
|
|
|
- .add("add_manga[status]", track.status)
|
|
|
- .add("add_manga[num_read_volumes]", track.num_read_volumes)
|
|
|
- .add("last_completed_vol", track.last_completed_vol)
|
|
|
- .add("add_manga[num_read_chapters]", track.num_read_chapters)
|
|
|
- .add("add_manga[score]", track.score)
|
|
|
- .add("add_manga[start_date][month]", track.start_date_month)
|
|
|
- .add("add_manga[start_date][day]", track.start_date_day)
|
|
|
- .add("add_manga[start_date][year]", track.start_date_year)
|
|
|
- .add("add_manga[finish_date][month]", track.finish_date_month)
|
|
|
- .add("add_manga[finish_date][day]", track.finish_date_day)
|
|
|
- .add("add_manga[finish_date][year]", track.finish_date_year)
|
|
|
- .add("add_manga[tags]", track.tags)
|
|
|
- .add("add_manga[priority]", track.priority)
|
|
|
- .add("add_manga[storage_type]", track.storage_type)
|
|
|
- .add("add_manga[num_retail_volumes]", track.num_retail_volumes)
|
|
|
- .add("add_manga[num_read_times]", track.num_read_chapters)
|
|
|
- .add("add_manga[reread_value]", track.reread_value)
|
|
|
- .add("add_manga[comments]", track.comments)
|
|
|
- .add("add_manga[is_asked_to_discuss]", track.is_asked_to_discuss)
|
|
|
- .add("add_manga[sns_post_type]", track.sns_post_type)
|
|
|
- .add("submitIt", track.submitIt)
|
|
|
- .build()
|
|
|
+ .add("entry_id", track.entry_id)
|
|
|
+ .add("manga_id", track.manga_id)
|
|
|
+ .add("add_manga[status]", track.status)
|
|
|
+ .add("add_manga[num_read_volumes]", track.num_read_volumes)
|
|
|
+ .add("last_completed_vol", track.last_completed_vol)
|
|
|
+ .add("add_manga[num_read_chapters]", track.num_read_chapters)
|
|
|
+ .add("add_manga[score]", track.score)
|
|
|
+ .add("add_manga[start_date][month]", track.start_date_month)
|
|
|
+ .add("add_manga[start_date][day]", track.start_date_day)
|
|
|
+ .add("add_manga[start_date][year]", track.start_date_year)
|
|
|
+ .add("add_manga[finish_date][month]", track.finish_date_month)
|
|
|
+ .add("add_manga[finish_date][day]", track.finish_date_day)
|
|
|
+ .add("add_manga[finish_date][year]", track.finish_date_year)
|
|
|
+ .add("add_manga[tags]", track.tags)
|
|
|
+ .add("add_manga[priority]", track.priority)
|
|
|
+ .add("add_manga[storage_type]", track.storage_type)
|
|
|
+ .add("add_manga[num_retail_volumes]", track.num_retail_volumes)
|
|
|
+ .add("add_manga[num_read_times]", track.num_read_chapters)
|
|
|
+ .add("add_manga[reread_value]", track.reread_value)
|
|
|
+ .add("add_manga[comments]", track.comments)
|
|
|
+ .add("add_manga[is_asked_to_discuss]", track.is_asked_to_discuss)
|
|
|
+ .add("add_manga[sns_post_type]", track.sns_post_type)
|
|
|
+ .add("submitIt", track.submitIt)
|
|
|
+ .build()
|
|
|
}
|
|
|
|
|
|
private fun Element.searchDateXml(field: String): Long {
|
|
|
val text = selectText(field, "0000-00-00")!!
|
|
|
// MAL sets the data to 0000-00-00 when date is invalid or missing
|
|
|
- if (text == "0000-00-00")
|
|
|
+ if (text == "0000-00-00") {
|
|
|
return 0L
|
|
|
+ }
|
|
|
|
|
|
return SimpleDateFormat("yyyy-MM-dd", Locale.US).parse(text)?.time ?: 0L
|
|
|
}
|
|
@@ -359,8 +362,9 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
|
|
|
val month = select(id + "_month > option[selected]").`val`().toIntOrNull()
|
|
|
val day = select(id + "_day > option[selected]").`val`().toIntOrNull()
|
|
|
val year = select(id + "_year > option[selected]").`val`().toIntOrNull()
|
|
|
- if (year == null || month == null || day == null)
|
|
|
+ if (year == null || month == null || day == null) {
|
|
|
return 0L
|
|
|
+ }
|
|
|
|
|
|
return GregorianCalendar(year, month - 1, day).timeInMillis
|
|
|
}
|
|
@@ -370,18 +374,18 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
|
|
|
private fun Element.searchTotalChapters() = if (select(TD)[4].text() == "-") 0 else select(TD)[4].text().toInt()
|
|
|
|
|
|
private fun Element.searchCoverUrl() = select("img")
|
|
|
- .attr("data-src")
|
|
|
- .split("\\?")[0]
|
|
|
- .replace("/r/50x70/", "/")
|
|
|
+ .attr("data-src")
|
|
|
+ .split("\\?")[0]
|
|
|
+ .replace("/r/50x70/", "/")
|
|
|
|
|
|
private fun Element.searchMediaId() = select("div.picSurround")
|
|
|
- .select("a").attr("id")
|
|
|
- .replace("sarea", "")
|
|
|
- .toInt()
|
|
|
+ .select("a").attr("id")
|
|
|
+ .replace("sarea", "")
|
|
|
+ .toInt()
|
|
|
|
|
|
private fun Element.searchSummary() = select("div.pt4")
|
|
|
- .first()
|
|
|
- .ownText()!!
|
|
|
+ .first()
|
|
|
+ .ownText()!!
|
|
|
|
|
|
private fun Element.searchPublishingStatus() = if (select(TD).last().text() == "-") "Publishing" else "Finished"
|
|
|
|
|
@@ -472,8 +476,9 @@ class MyAnimeListApi(private val client: OkHttpClient, interceptor: MyAnimeListI
|
|
|
fun copyPersonalFrom(track: Track) {
|
|
|
num_read_chapters = track.last_chapter_read.toString()
|
|
|
val numScore = track.score.toInt()
|
|
|
- if (numScore in 1..9)
|
|
|
+ if (numScore in 1..9) {
|
|
|
score = numScore.toString()
|
|
|
+ }
|
|
|
status = track.status.toString()
|
|
|
if (track.started_reading_date == 0L) {
|
|
|
start_date_month = ""
|