Replace fragile Niadd patch with patch script
Build Futon with Niadd patch / Build debug APK (push) Successful in 12m49s
Build Futon with Niadd patch / Build debug APK (push) Successful in 12m49s
This commit is contained in:
3 files changed
+128
-48
No files matched your search
@@ -6,7 +6,7 @@ on:
|
|||||||
- main
|
- main
|
||||||
paths:
|
paths:
|
||||||
- ".gitea/workflows/build.yml"
|
- ".gitea/workflows/build.yml"
|
||||||
- "patches/**"
|
- "scripts/**"
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
@@ -62,21 +62,34 @@ jobs:
|
|||||||
git -C work/Futon rev-parse HEAD
|
git -C work/Futon rev-parse HEAD
|
||||||
git -C work/kotatsu-parsers-redo rev-parse HEAD
|
git -C work/kotatsu-parsers-redo rev-parse HEAD
|
||||||
|
|
||||||
- name: Check and apply Niadd parser patch
|
- name: Apply Niadd parser modifications
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euxo pipefail
|
set -euxo pipefail
|
||||||
|
|
||||||
PATCH_FILE="${PWD}/patches/ninemanga-niadd.patch"
|
python3 scripts/patch_ninemanga_niadd.py \
|
||||||
|
work/kotatsu-parsers-redo
|
||||||
|
|
||||||
git -C work/kotatsu-parsers-redo apply --check "${PATCH_FILE}"
|
PARSER_FILE="work/kotatsu-parsers-redo/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/NineMangaParser.kt"
|
||||||
git -C work/kotatsu-parsers-redo apply "${PATCH_FILE}"
|
|
||||||
|
|
||||||
grep -F '"ru.niadd.com"' \
|
echo "=== Verify Niadd domain ==="
|
||||||
work/kotatsu-parsers-redo/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/NineMangaParser.kt
|
grep -F '"ru.niadd.com"' "${PARSER_FILE}"
|
||||||
|
|
||||||
grep -F '@MangaSourceParser("NINEMANGA_RU", "Niadd Русский", "ru")' \
|
echo "=== Verify source annotation ==="
|
||||||
work/kotatsu-parsers-redo/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/NineMangaParser.kt
|
grep -F '@MangaSourceParser("NINEMANGA_RU", "Niadd Русский", "ru")' "${PARSER_FILE}"
|
||||||
|
|
||||||
|
echo "=== Verify Niadd pagination ==="
|
||||||
|
grep -F 'domain.endsWith("niadd.com")' "${PARSER_FILE}"
|
||||||
|
|
||||||
|
echo "=== Ensure old Russian domain is gone ==="
|
||||||
|
if grep -F '"ru.ninemanga.com"' "${PARSER_FILE}"; then
|
||||||
|
echo "ERROR: old ru.ninemanga.com domain is still present"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "=== Resulting diff ==="
|
||||||
|
git -C work/kotatsu-parsers-redo diff -- \
|
||||||
|
src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/NineMangaParser.kt
|
||||||
|
|
||||||
- name: Connect Futon to patched local parsers
|
- name: Connect Futon to patched local parsers
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
diff --git a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/NineMangaParser.kt b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/NineMangaParser.kt
|
|
||||||
--- a/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/NineMangaParser.kt
|
|
||||||
+++ b/src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/NineMangaParser.kt
|
|
||||||
@@ -89,6 +89,14 @@
|
|
||||||
}
|
|
||||||
- } else {
|
|
||||||
- append("/category/index_")
|
|
||||||
- append(page.toString())
|
|
||||||
- }
|
|
||||||
+ } else if (domain.endsWith("niadd.com")) {
|
|
||||||
+ if (page == 1) {
|
|
||||||
+ append("/category/")
|
|
||||||
+ } else {
|
|
||||||
+ append("/category/index_")
|
|
||||||
+ append(page.toString())
|
|
||||||
+ append(".html")
|
|
||||||
+ }
|
|
||||||
+ } else {
|
|
||||||
+ append("/category/index_")
|
|
||||||
+ append(page.toString())
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
@@ -199,4 +199,4 @@
|
|
||||||
//ru
|
|
||||||
- status.contains("постоянный") -> MangaState.ONGOING
|
|
||||||
- status.contains("завершенный") -> MangaState.FINISHED
|
|
||||||
+ status.contains("постоянный", ignoreCase = true) -> MangaState.ONGOING
|
|
||||||
+ status.contains("завершенный", ignoreCase = true) -> MangaState.FINISHED
|
|
||||||
//de
|
|
||||||
@@ -265,7 +265,6 @@
|
|
||||||
- @Broken
|
|
||||||
- @MangaSourceParser("NINEMANGA_RU", "NineManga Русский", "ru")
|
|
||||||
+ @MangaSourceParser("NINEMANGA_RU", "Niadd Русский", "ru")
|
|
||||||
class Russian(context: MangaLoaderContext) : NineMangaParser(
|
|
||||||
context,
|
|
||||||
MangaParserSource.NINEMANGA_RU,
|
|
||||||
- "ru.ninemanga.com",
|
|
||||||
+ "ru.niadd.com",
|
|
||||||
)
|
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print(f"Usage: {sys.argv[0]} <kotatsu-parsers-redo-dir>", file=sys.stderr)
|
||||||
|
sys.exit(2)
|
||||||
|
|
||||||
|
|
||||||
|
repo_dir = Path(sys.argv[1]).resolve()
|
||||||
|
|
||||||
|
parser_file = (
|
||||||
|
repo_dir
|
||||||
|
/ "src/main/kotlin/org/koitharu/kotatsu/parsers/site/all/NineMangaParser.kt"
|
||||||
|
)
|
||||||
|
|
||||||
|
if not parser_file.is_file():
|
||||||
|
print(f"ERROR: parser file not found: {parser_file}", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
text = parser_file.read_text(encoding="utf-8")
|
||||||
|
|
||||||
|
|
||||||
|
def replace_exact(name: str, old: str, new: str) -> None:
|
||||||
|
global text
|
||||||
|
|
||||||
|
count = text.count(old)
|
||||||
|
|
||||||
|
if count != 1:
|
||||||
|
print(
|
||||||
|
f"ERROR: patch '{name}' expected exactly 1 match, found {count}",
|
||||||
|
file=sys.stderr,
|
||||||
|
)
|
||||||
|
print(
|
||||||
|
"Upstream NineMangaParser.kt has probably changed.",
|
||||||
|
file=sys.stderr,
|
||||||
|
)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
text = text.replace(old, new, 1)
|
||||||
|
print(f"[OK] {name}")
|
||||||
|
|
||||||
|
|
||||||
|
replace_exact(
|
||||||
|
"Niadd category pagination",
|
||||||
|
''' } else {
|
||||||
|
append("/category/index_")
|
||||||
|
append(page.toString())
|
||||||
|
}
|
||||||
|
''',
|
||||||
|
''' } else if (domain.endsWith("niadd.com")) {
|
||||||
|
if (page == 1) {
|
||||||
|
append("/category/")
|
||||||
|
} else {
|
||||||
|
append("/category/index_")
|
||||||
|
append(page.toString())
|
||||||
|
append(".html")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
append("/category/index_")
|
||||||
|
append(page.toString())
|
||||||
|
}
|
||||||
|
''',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
replace_exact(
|
||||||
|
"Russian status parsing",
|
||||||
|
''' //ru
|
||||||
|
status.contains("постоянный") -> MangaState.ONGOING
|
||||||
|
status.contains("завершенный") -> MangaState.FINISHED
|
||||||
|
''',
|
||||||
|
''' //ru
|
||||||
|
status.contains("постоянный", ignoreCase = true) -> MangaState.ONGOING
|
||||||
|
status.contains("завершенный", ignoreCase = true) -> MangaState.FINISHED
|
||||||
|
''',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
replace_exact(
|
||||||
|
"NineManga RU to Niadd RU",
|
||||||
|
''' @Broken
|
||||||
|
@MangaSourceParser("NINEMANGA_RU", "NineManga Русский", "ru")
|
||||||
|
class Russian(context: MangaLoaderContext) : NineMangaParser(
|
||||||
|
context,
|
||||||
|
MangaParserSource.NINEMANGA_RU,
|
||||||
|
"ru.ninemanga.com",
|
||||||
|
)
|
||||||
|
''',
|
||||||
|
''' @MangaSourceParser("NINEMANGA_RU", "Niadd Русский", "ru")
|
||||||
|
class Russian(context: MangaLoaderContext) : NineMangaParser(
|
||||||
|
context,
|
||||||
|
MangaParserSource.NINEMANGA_RU,
|
||||||
|
"ru.niadd.com",
|
||||||
|
)
|
||||||
|
''',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
parser_file.write_text(text, encoding="utf-8")
|
||||||
|
|
||||||
|
print()
|
||||||
|
print(f"[OK] Patched: {parser_file}")
|
||||||
Reference in new issue
Block a user