mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-28 17:19:00 +03:00
Allow custom parsing of chapter number on sources
This commit is contained in:
parent
f73f0cc341
commit
d4bb092543
4 changed files with 12 additions and 4 deletions
|
@ -40,6 +40,7 @@ import eu.kanade.tachiyomi.data.database.tables.MangaCategoryTable;
|
||||||
import eu.kanade.tachiyomi.data.database.tables.MangaSyncTable;
|
import eu.kanade.tachiyomi.data.database.tables.MangaSyncTable;
|
||||||
import eu.kanade.tachiyomi.data.database.tables.MangaTable;
|
import eu.kanade.tachiyomi.data.database.tables.MangaTable;
|
||||||
import eu.kanade.tachiyomi.data.mangasync.base.MangaSyncService;
|
import eu.kanade.tachiyomi.data.mangasync.base.MangaSyncService;
|
||||||
|
import eu.kanade.tachiyomi.data.source.base.Source;
|
||||||
import eu.kanade.tachiyomi.util.ChapterRecognition;
|
import eu.kanade.tachiyomi.util.ChapterRecognition;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
|
|
||||||
|
@ -240,13 +241,14 @@ public class DatabaseHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new chapters or delete if the source deletes them
|
// Add new chapters or delete if the source deletes them
|
||||||
public Observable<Pair<Integer, Integer>> insertOrRemoveChapters(Manga manga, List<Chapter> sourceChapters) {
|
public Observable<Pair<Integer, Integer>> insertOrRemoveChapters(Manga manga, List<Chapter> sourceChapters, Source source) {
|
||||||
List<Chapter> dbChapters = getChapters(manga).executeAsBlocking();
|
List<Chapter> dbChapters = getChapters(manga).executeAsBlocking();
|
||||||
|
|
||||||
Observable<List<Chapter>> newChapters = Observable.from(sourceChapters)
|
Observable<List<Chapter>> newChapters = Observable.from(sourceChapters)
|
||||||
.filter(c -> !dbChapters.contains(c))
|
.filter(c -> !dbChapters.contains(c))
|
||||||
.doOnNext(c -> {
|
.doOnNext(c -> {
|
||||||
c.manga_id = manga.id;
|
c.manga_id = manga.id;
|
||||||
|
source.parseChapterNumber(c);
|
||||||
ChapterRecognition.parseChapterNumber(c, manga);
|
ChapterRecognition.parseChapterNumber(c, manga);
|
||||||
})
|
})
|
||||||
.toList();
|
.toList();
|
||||||
|
|
|
@ -201,9 +201,10 @@ class LibraryUpdateService : Service() {
|
||||||
* @return a pair of the inserted and removed chapters.
|
* @return a pair of the inserted and removed chapters.
|
||||||
*/
|
*/
|
||||||
fun updateManga(manga: Manga): Observable<Pair<Int, Int>> {
|
fun updateManga(manga: Manga): Observable<Pair<Int, Int>> {
|
||||||
return sourceManager.get(manga.source)!!
|
val source = sourceManager.get(manga.source)
|
||||||
|
return source!!
|
||||||
.pullChaptersFromNetwork(manga.url)
|
.pullChaptersFromNetwork(manga.url)
|
||||||
.flatMap { db.insertOrRemoveChapters(manga, it) }
|
.flatMap { db.insertOrRemoveChapters(manga, it, source) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -235,6 +235,11 @@ public abstract class Source extends BaseSource {
|
||||||
return getId() + chapterUrl;
|
return getId() + chapterUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Overridable method to allow custom parsing.
|
||||||
|
public void parseChapterNumber(Chapter chapter) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected LazyHeaders.Builder glideHeadersBuilder() {
|
protected LazyHeaders.Builder glideHeadersBuilder() {
|
||||||
LazyHeaders.Builder builder = new LazyHeaders.Builder();
|
LazyHeaders.Builder builder = new LazyHeaders.Builder();
|
||||||
for (Map.Entry<String, List<String>> entry : requestHeaders.toMultimap().entrySet()) {
|
for (Map.Entry<String, List<String>> entry : requestHeaders.toMultimap().entrySet()) {
|
||||||
|
|
|
@ -119,7 +119,7 @@ public class ChaptersPresenter extends BasePresenter<ChaptersFragment> {
|
||||||
private Observable<Pair<Integer, Integer>> getOnlineChaptersObs() {
|
private Observable<Pair<Integer, Integer>> getOnlineChaptersObs() {
|
||||||
return source.pullChaptersFromNetwork(manga.url)
|
return source.pullChaptersFromNetwork(manga.url)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.flatMap(chapters -> db.insertOrRemoveChapters(manga, chapters))
|
.flatMap(chapters -> db.insertOrRemoveChapters(manga, chapters, source))
|
||||||
.observeOn(AndroidSchedulers.mainThread());
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue