mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-10 10:17:48 +01:00
License manga update and Manga Fox Title Update (#937)
* update mangafox parsing to read chapter title also if it exists. * updated chapterImpl to force update chapters if chapter name changes. This allows for chapter name changes from the source to update in app * switched from : to - since other sites that already have title use - so it provides consistency across sources. * fixed spacing for - * fixes license status for manga fox if manga is licensed no chapters will be shown. * 1. changed equality in chapterImp back to just the url (removed scanlator, and name comparison) 2. Removed extra line of code assigning mangaFox title twice 3. Modified ChapterSourceSync for scanlator/title/url comparison. * cleaned spaces, added comment, incorporated toChange code from other pull request * throw exception instead of returning empty list when licensed * space fix
This commit is contained in:
parent
71fc6fc257
commit
5ae0589547
3 changed files with 19 additions and 11 deletions
|
@ -13,6 +13,7 @@ import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
import java.lang.Exception
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import java.net.URISyntaxException
|
import java.net.URISyntaxException
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
|
@ -51,7 +52,7 @@ abstract class HttpSource : CatalogueSource {
|
||||||
override val id by lazy {
|
override val id by lazy {
|
||||||
val key = "${name.toLowerCase()}/$lang/$versionId"
|
val key = "${name.toLowerCase()}/$lang/$versionId"
|
||||||
val bytes = MessageDigest.getInstance("MD5").digest(key.toByteArray())
|
val bytes = MessageDigest.getInstance("MD5").digest(key.toByteArray())
|
||||||
(0..7).map { bytes[it].toLong() and 0xff shl 8*(7-it) }.reduce(Long::or) and Long.MAX_VALUE
|
(0..7).map { bytes[it].toLong() and 0xff shl 8 * (7 - it) }.reduce(Long::or) and Long.MAX_VALUE
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -197,16 +198,20 @@ abstract class HttpSource : CatalogueSource {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an observable with the updated chapter list for a manga. Normally it's not needed to
|
* Returns an observable with the updated chapter list for a manga. Normally it's not needed to
|
||||||
* override this method.
|
* override this method. If a manga is licensed an empty chapter list observable is returned
|
||||||
*
|
*
|
||||||
* @param manga the manga to look for chapters.
|
* @param manga the manga to look for chapters.
|
||||||
*/
|
*/
|
||||||
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
|
override fun fetchChapterList(manga: SManga): Observable<List<SChapter>> {
|
||||||
|
if (manga.status != SManga.LICENSED) {
|
||||||
return client.newCall(chapterListRequest(manga))
|
return client.newCall(chapterListRequest(manga))
|
||||||
.asObservableSuccess()
|
.asObservableSuccess()
|
||||||
.map { response ->
|
.map { response ->
|
||||||
chapterListParse(response)
|
chapterListParse(response)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return Observable.error(Exception("Licensed - No chapters to show"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -61,7 +61,7 @@ class Mangafox : ParsedHttpSource() {
|
||||||
is Status -> url.addQueryParameter(filter.id, filter.state.toString())
|
is Status -> url.addQueryParameter(filter.id, filter.state.toString())
|
||||||
is GenreList -> filter.state.forEach { genre -> url.addQueryParameter(genre.id, genre.state.toString()) }
|
is GenreList -> filter.state.forEach { genre -> url.addQueryParameter(genre.id, genre.state.toString()) }
|
||||||
is TextField -> url.addQueryParameter(filter.key, filter.state)
|
is TextField -> url.addQueryParameter(filter.key, filter.state)
|
||||||
is Type -> url.addQueryParameter("type", if(filter.state == 0) "" else filter.state.toString())
|
is Type -> url.addQueryParameter("type", if (filter.state == 0) "" else filter.state.toString())
|
||||||
is OrderBy -> {
|
is OrderBy -> {
|
||||||
url.addQueryParameter("sort", arrayOf("name", "rating", "views", "total_chapters", "last_chapter_time")[filter.state!!.index])
|
url.addQueryParameter("sort", arrayOf("name", "rating", "views", "total_chapters", "last_chapter_time")[filter.state!!.index])
|
||||||
url.addQueryParameter("order", if (filter.state?.ascending == true) "az" else "za")
|
url.addQueryParameter("order", if (filter.state?.ascending == true) "az" else "za")
|
||||||
|
@ -89,13 +89,14 @@ class Mangafox : ParsedHttpSource() {
|
||||||
val infoElement = document.select("div#title").first()
|
val infoElement = document.select("div#title").first()
|
||||||
val rowElement = infoElement.select("table > tbody > tr:eq(1)").first()
|
val rowElement = infoElement.select("table > tbody > tr:eq(1)").first()
|
||||||
val sideInfoElement = document.select("#series_info").first()
|
val sideInfoElement = document.select("#series_info").first()
|
||||||
|
val licensedElement = document.select("div.warning").first()
|
||||||
|
|
||||||
val manga = SManga.create()
|
val manga = SManga.create()
|
||||||
manga.author = rowElement.select("td:eq(1)").first()?.text()
|
manga.author = rowElement.select("td:eq(1)").first()?.text()
|
||||||
manga.artist = rowElement.select("td:eq(2)").first()?.text()
|
manga.artist = rowElement.select("td:eq(2)").first()?.text()
|
||||||
manga.genre = rowElement.select("td:eq(3)").first()?.text()
|
manga.genre = rowElement.select("td:eq(3)").first()?.text()
|
||||||
manga.description = infoElement.select("p.summary").first()?.text()
|
manga.description = infoElement.select("p.summary").first()?.text()
|
||||||
manga.status = sideInfoElement.select(".data").first()?.text().orEmpty().let { parseStatus(it) }
|
manga.status = licensedElement?.let { SManga.LICENSED } ?: sideInfoElement.select(".data").first()?.text().orEmpty().let { parseStatus(it) }
|
||||||
manga.thumbnail_url = sideInfoElement.select("div.cover > img").first()?.attr("src")
|
manga.thumbnail_url = sideInfoElement.select("div.cover > img").first()?.attr("src")
|
||||||
return manga
|
return manga
|
||||||
}
|
}
|
||||||
|
@ -113,7 +114,7 @@ class Mangafox : ParsedHttpSource() {
|
||||||
|
|
||||||
val chapter = SChapter.create()
|
val chapter = SChapter.create()
|
||||||
chapter.setUrlWithoutDomain(urlElement.attr("href"))
|
chapter.setUrlWithoutDomain(urlElement.attr("href"))
|
||||||
chapter.name = urlElement.text()
|
chapter.name = element.select("span.title.nowrap").first()?.text()?.let { urlElement.text() + " - " + it } ?: urlElement.text()
|
||||||
chapter.date_upload = element.select("span.date").first()?.text()?.let { parseChapterDate(it) } ?: 0
|
chapter.date_upload = element.select("span.date").first()?.text()?.let { parseChapterDate(it) } ?: 0
|
||||||
return chapter
|
return chapter
|
||||||
}
|
}
|
||||||
|
@ -169,6 +170,7 @@ class Mangafox : ParsedHttpSource() {
|
||||||
private class OrderBy : Filter.Sort("Order by",
|
private class OrderBy : Filter.Sort("Order by",
|
||||||
arrayOf("Series name", "Rating", "Views", "Total chapters", "Last chapter"),
|
arrayOf("Series name", "Rating", "Views", "Total chapters", "Last chapter"),
|
||||||
Filter.Sort.Selection(2, false))
|
Filter.Sort.Selection(2, false))
|
||||||
|
|
||||||
private class GenreList(genres: List<Genre>) : Filter.Group<Genre>("Genres", genres)
|
private class GenreList(genres: List<Genre>) : Filter.Group<Genre>("Genres", genres)
|
||||||
|
|
||||||
override fun getFilterList() = FilterList(
|
override fun getFilterList() = FilterList(
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.util.*
|
||||||
fun syncChaptersWithSource(db: DatabaseHelper,
|
fun syncChaptersWithSource(db: DatabaseHelper,
|
||||||
rawSourceChapters: List<SChapter>,
|
rawSourceChapters: List<SChapter>,
|
||||||
manga: Manga,
|
manga: Manga,
|
||||||
source: Source) : Pair<List<Chapter>, List<Chapter>> {
|
source: Source): Pair<List<Chapter>, List<Chapter>> {
|
||||||
|
|
||||||
if (rawSourceChapters.isEmpty()) {
|
if (rawSourceChapters.isEmpty()) {
|
||||||
throw Exception("No chapters found")
|
throw Exception("No chapters found")
|
||||||
|
@ -121,4 +121,5 @@ fun syncChaptersWithSource(db: DatabaseHelper,
|
||||||
db.fixChaptersSourceOrder(sourceChapters).executeAsBlocking()
|
db.fixChaptersSourceOrder(sourceChapters).executeAsBlocking()
|
||||||
}
|
}
|
||||||
return Pair(toAdd.subtract(readded).toList(), toDelete.subtract(readded).toList())
|
return Pair(toAdd.subtract(readded).toList(), toDelete.subtract(readded).toList())
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue