@@ -1,12 +1,14 @@
|
||||
# Editor configuration, see https://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
insert_final_newline = true
|
||||
end_of_line = lf
|
||||
|
||||
[*.kt]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
ij_kotlin_allow_trailing_comma = true
|
||||
ij_kotlin_allow_trailing_comma_on_call_site = true
|
||||
@@ -15,5 +17,3 @@ ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
|
||||
|
||||
[*.properties]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
|
||||
5
.gitattributes
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/gradlew linguist-generated
|
||||
/gradlew.bat linguist-generated
|
||||
|
||||
* text=auto eol=lf
|
||||
*.bat text eol=crlf
|
||||
4
.github/ISSUE_TEMPLATE.md
vendored
@@ -2,11 +2,11 @@
|
||||
|
||||
I acknowledge that:
|
||||
|
||||
- I have updated to the latest version of the app (stable is v0.14.7)
|
||||
- I have updated to the latest version of the app (stable is v0.15.1)
|
||||
- I have updated all extensions
|
||||
- If this is an issue with the app itself, that I should be opening an issue in https://github.com/tachiyomiorg/tachiyomi
|
||||
- I have searched the existing issues for duplicates
|
||||
- For source requests, I have checked the list of existing extensions including the multi-source spreadsheet: https://tachiyomi.org/extensions/
|
||||
|
||||
|
||||
**DELETE THIS SECTION IF YOU HAVE READ AND ACKNOWLEDGED IT**
|
||||
|
||||
|
||||
4
.github/always_build.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
[
|
||||
"ko.newtoki",
|
||||
"ko.wolfdotcom"
|
||||
]
|
||||
11
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
1
.github/pull_request_template.md
vendored
@@ -7,3 +7,4 @@ Checklist:
|
||||
- [ ] Have not changed source names
|
||||
- [ ] Have explicitly kept the `id` if a source's name or language were changed
|
||||
- [ ] Have tested the modifications by compiling and running the extension through Android Studio
|
||||
- [ ] Have removed `web_hi_res_512.png` when adding a new extension
|
||||
|
||||
38
.github/renovate.json
vendored
@@ -1,8 +1,44 @@
|
||||
{
|
||||
"labels": [
|
||||
"Dependencies"
|
||||
],
|
||||
"rebaseWhen": "conflicted",
|
||||
"automerge": true,
|
||||
"semanticCommits": "enabled",
|
||||
"extends": [
|
||||
"config:base"
|
||||
"config:best-practices"
|
||||
],
|
||||
"schedule": [
|
||||
"on sunday"
|
||||
],
|
||||
"includePaths": [
|
||||
"buildSrc/gradle/**",
|
||||
"gradle/**",
|
||||
".github/**"
|
||||
],
|
||||
"ignoreDeps": [
|
||||
"keiyoushi/issue-moderator-action"
|
||||
],
|
||||
"packageRules": [
|
||||
{
|
||||
"matchManagers": [
|
||||
"github-actions"
|
||||
],
|
||||
"groupName": "{{manager}} dependencies"
|
||||
},
|
||||
{
|
||||
"matchManagers": [
|
||||
"gradle"
|
||||
],
|
||||
"enabled": false
|
||||
},
|
||||
{
|
||||
"matchPackageNames": [
|
||||
"com.android.tools.build:gradle",
|
||||
"gradle"
|
||||
],
|
||||
"draftPR": true,
|
||||
"enabled": true
|
||||
}
|
||||
]
|
||||
}
|
||||
17
.github/scripts/commit-repo.sh
vendored
@@ -1,17 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
rsync -a --delete --exclude .git --exclude .gitignore ../master/repo/ .
|
||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git status
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
git add .
|
||||
git commit -m "Update extensions repo"
|
||||
git push
|
||||
|
||||
# Purge cached index on jsDelivr
|
||||
curl https://purge.jsdelivr.net/gh/tachiyomiorg/tachiyomi-extensions@repo/index.min.json
|
||||
else
|
||||
echo "No changes to commit"
|
||||
fi
|
||||
88
.github/scripts/create-repo.py
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from zipfile import ZipFile
|
||||
|
||||
PACKAGE_NAME_REGEX = re.compile(r"package: name='([^']+)'")
|
||||
VERSION_CODE_REGEX = re.compile(r"versionCode='([^']+)'")
|
||||
VERSION_NAME_REGEX = re.compile(r"versionName='([^']+)'")
|
||||
IS_NSFW_REGEX = re.compile(r"'tachiyomi.extension.nsfw' value='([^']+)'")
|
||||
APPLICATION_LABEL_REGEX = re.compile(r"^application-label:'([^']+)'", re.MULTILINE)
|
||||
APPLICATION_ICON_320_REGEX = re.compile(r"^application-icon-320:'([^']+)'", re.MULTILINE)
|
||||
LANGUAGE_REGEX = re.compile(r"tachiyomi-([^.]+)")
|
||||
|
||||
*_, ANDROID_BUILD_TOOLS = (Path(os.environ["ANDROID_HOME"]) / "build-tools").iterdir()
|
||||
REPO_DIR = Path("repo")
|
||||
REPO_APK_DIR = REPO_DIR / "apk"
|
||||
REPO_ICON_DIR = REPO_DIR / "icon"
|
||||
|
||||
REPO_ICON_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with open("output.json", encoding="utf-8") as f:
|
||||
inspector_data = json.load(f)
|
||||
|
||||
index_min_data = []
|
||||
|
||||
for apk in REPO_APK_DIR.iterdir():
|
||||
badging = subprocess.check_output(
|
||||
[
|
||||
ANDROID_BUILD_TOOLS / "aapt",
|
||||
"dump",
|
||||
"--include-meta-data",
|
||||
"badging",
|
||||
apk,
|
||||
]
|
||||
).decode()
|
||||
|
||||
package_info = next(x for x in badging.splitlines() if x.startswith("package: "))
|
||||
package_name = PACKAGE_NAME_REGEX.search(package_info).group(1)
|
||||
application_icon = APPLICATION_ICON_320_REGEX.search(badging).group(1)
|
||||
|
||||
with ZipFile(apk) as z, z.open(application_icon) as i, (
|
||||
REPO_ICON_DIR / f"{package_name}.png"
|
||||
).open("wb") as f:
|
||||
f.write(i.read())
|
||||
|
||||
language = LANGUAGE_REGEX.search(apk.name).group(1)
|
||||
sources = inspector_data[package_name]
|
||||
|
||||
if len(sources) == 1:
|
||||
source_language = sources[0]["lang"]
|
||||
|
||||
if (
|
||||
source_language != language
|
||||
and source_language not in {"all", "other"}
|
||||
and language not in {"all", "other"}
|
||||
):
|
||||
language = source_language
|
||||
|
||||
common_data = {
|
||||
"name": APPLICATION_LABEL_REGEX.search(badging).group(1),
|
||||
"pkg": package_name,
|
||||
"apk": apk.name,
|
||||
"lang": language,
|
||||
"code": int(VERSION_CODE_REGEX.search(package_info).group(1)),
|
||||
"version": VERSION_NAME_REGEX.search(package_info).group(1),
|
||||
"nsfw": int(IS_NSFW_REGEX.search(badging).group(1)),
|
||||
}
|
||||
min_data = {
|
||||
**common_data,
|
||||
"sources": [],
|
||||
}
|
||||
|
||||
for source in sources:
|
||||
min_data["sources"].append(
|
||||
{
|
||||
"name": source["name"],
|
||||
"lang": source["lang"],
|
||||
"id": source["id"],
|
||||
"baseUrl": source["baseUrl"],
|
||||
}
|
||||
)
|
||||
|
||||
index_min_data.append(min_data)
|
||||
|
||||
with REPO_DIR.joinpath("index.min.json").open("w", encoding="utf-8") as index_file:
|
||||
json.dump(index_min_data, index_file, ensure_ascii=False, separators=(",", ":"))
|
||||
69
.github/scripts/create-repo.sh
vendored
@@ -1,69 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
TOOLS="$(ls -d ${ANDROID_HOME}/build-tools/* | tail -1)"
|
||||
|
||||
mkdir -p repo/apk
|
||||
mkdir -p repo/icon
|
||||
|
||||
cp -f apk/* repo/apk
|
||||
|
||||
cd repo
|
||||
|
||||
APKS=( ../apk/*".apk" )
|
||||
|
||||
for APK in ${APKS[@]}; do
|
||||
FILENAME=$(basename ${APK})
|
||||
BADGING="$(${TOOLS}/aapt dump --include-meta-data badging $APK)"
|
||||
|
||||
PACKAGE=$(echo "$BADGING" | grep package:)
|
||||
PKGNAME=$(echo $PACKAGE | grep -Po "package: name='\K[^']+")
|
||||
VCODE=$(echo $PACKAGE | grep -Po "versionCode='\K[^']+")
|
||||
VNAME=$(echo $PACKAGE | grep -Po "versionName='\K[^']+")
|
||||
NSFW=$(echo $BADGING | grep -Po "tachiyomi.extension.nsfw' value='\K[^']+")
|
||||
HASREADME=$(echo $BADGING | grep -Po "tachiyomi.extension.hasReadme' value='\K[^']+")
|
||||
HASCHANGELOG=$(echo $BADGING | grep -Po "tachiyomi.extension.hasChangelog' value='\K[^']+")
|
||||
|
||||
APPLICATION=$(echo "$BADGING" | grep application:)
|
||||
LABEL=$(echo $APPLICATION | grep -Po "label='\K[^']+")
|
||||
|
||||
LANG=$(echo $APK | grep -Po "tachiyomi-\K[^\.]+")
|
||||
|
||||
ICON=$(echo "$BADGING" | grep -Po "application-icon-320.*'\K[^']+")
|
||||
unzip -p $APK $ICON > icon/${PKGNAME}.png
|
||||
|
||||
# TODO: legacy icons; remove after a while
|
||||
cp icon/${PKGNAME}.png icon/${FILENAME%.*}.png
|
||||
|
||||
SOURCE_INFO=$(jq ".[\"$PKGNAME\"]" < ../output.json)
|
||||
|
||||
# Fixes the language code without needing to update the packages.
|
||||
SOURCE_LEN=$(echo $SOURCE_INFO | jq length)
|
||||
|
||||
if [ $SOURCE_LEN = "1" ]; then
|
||||
SOURCE_LANG=$(echo $SOURCE_INFO | jq -r '.[0].lang')
|
||||
|
||||
if [ $SOURCE_LANG != $LANG ] && [ $SOURCE_LANG != "all" ] && [ $SOURCE_LANG != "other" ] && [ $LANG != "all" ] && [ $LANG != "other" ]; then
|
||||
LANG=$SOURCE_LANG
|
||||
fi
|
||||
fi
|
||||
|
||||
jq -n \
|
||||
--arg name "$LABEL" \
|
||||
--arg pkg "$PKGNAME" \
|
||||
--arg apk "$FILENAME" \
|
||||
--arg lang "$LANG" \
|
||||
--argjson code $VCODE \
|
||||
--arg version "$VNAME" \
|
||||
--argjson nsfw $NSFW \
|
||||
--argjson hasReadme $HASREADME \
|
||||
--argjson hasChangelog $HASCHANGELOG \
|
||||
--argjson sources "$SOURCE_INFO" \
|
||||
'{name:$name, pkg:$pkg, apk:$apk, lang:$lang, code:$code, version:$version, nsfw:$nsfw, hasReadme:$hasReadme, hasChangelog:$hasChangelog, sources:$sources}'
|
||||
|
||||
done | jq -sr '[.[]]' > index.json
|
||||
|
||||
# Alternate minified copy
|
||||
jq -c '.' < index.json > index.min.json
|
||||
|
||||
cat index.json
|
||||
113
.github/scripts/generate-build-matrices.py
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
import itertools
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import NoReturn
|
||||
|
||||
EXTENSION_REGEX = re.compile(r"^src/(?P<lang>\w+)/(?P<extension>\w+)")
|
||||
MULTISRC_LIB_REGEX = re.compile(r"^lib-multisrc/(?P<multisrc>\w+)")
|
||||
LIB_REGEX = re.compile(r"^lib/(?P<lib>\w+)")
|
||||
MODULE_REGEX = re.compile(r"^:src:(?P<lang>\w+):(?P<extension>\w+)$")
|
||||
CORE_FILES_REGEX = re.compile(
|
||||
r"^(buildSrc/|core/|gradle/|build\.gradle\.kts|common\.gradle|gradle\.properties|settings\.gradle\.kts|utils/)"
|
||||
)
|
||||
|
||||
def run_command(command: str) -> str:
|
||||
result = subprocess.run(command, capture_output=True, text=True, shell=True)
|
||||
if result.returncode != 0:
|
||||
print(result.stderr.strip())
|
||||
sys.exit(result.returncode)
|
||||
return result.stdout.strip()
|
||||
|
||||
def get_module_list(ref: str) -> tuple[list[str], list[str]]:
|
||||
changed_files = run_command(f"git diff --name-only {ref}").splitlines()
|
||||
|
||||
modules = set()
|
||||
libs = set()
|
||||
deleted = set()
|
||||
core_files_changed = False
|
||||
|
||||
for file in map(lambda x: Path(x).as_posix(), changed_files):
|
||||
if CORE_FILES_REGEX.search(file):
|
||||
core_files_changed = True
|
||||
elif match := EXTENSION_REGEX.search(file):
|
||||
lang = match.group("lang")
|
||||
extension = match.group("extension")
|
||||
if Path("src", lang, extension).is_dir():
|
||||
modules.add(f':src:{lang}:{extension}')
|
||||
deleted.add(f"{lang}.{extension}")
|
||||
elif match := MULTISRC_LIB_REGEX.search(file):
|
||||
multisrc = match.group("multisrc")
|
||||
if Path("lib-multisrc", multisrc).is_dir():
|
||||
libs.add(f":lib-multisrc:{multisrc}:printDependentExtensions")
|
||||
elif match := LIB_REGEX.search(file):
|
||||
lib = match.group("lib")
|
||||
if Path("lib", lib).is_dir():
|
||||
libs.add(f":lib:{lib}:printDependentExtensions")
|
||||
|
||||
def is_extension_module(module: str) -> bool:
|
||||
if not (match := MODULE_REGEX.search(module)):
|
||||
return False
|
||||
lang = match.group("lang")
|
||||
extension = match.group("extension")
|
||||
deleted.add(f"{lang}.{extension}")
|
||||
return True
|
||||
|
||||
if len(libs) != 0 and not core_files_changed:
|
||||
modules.update([
|
||||
module for module in
|
||||
run_command("./gradlew -q " + " ".join(libs)).splitlines()
|
||||
if is_extension_module(module)
|
||||
])
|
||||
|
||||
if os.getenv("IS_PR_CHECK") != "true" and not core_files_changed:
|
||||
with Path(".github/always_build.json").open() as always_build_file:
|
||||
always_build = json.load(always_build_file)
|
||||
for extension in always_build:
|
||||
modules.add(":src:" + extension.replace(".", ":"))
|
||||
deleted.add(extension)
|
||||
|
||||
if core_files_changed:
|
||||
(all_modules, all_deleted) = get_all_modules()
|
||||
|
||||
modules.update(all_modules)
|
||||
deleted.update(all_deleted)
|
||||
|
||||
return list(modules), list(deleted)
|
||||
|
||||
def get_all_modules() -> tuple[list[str], list[str]]:
|
||||
modules = []
|
||||
deleted = []
|
||||
for lang in Path("src").iterdir():
|
||||
for extension in lang.iterdir():
|
||||
modules.append(f":src:{lang.name}:{extension.name}")
|
||||
deleted.append(f"{lang.name}.{extension.name}")
|
||||
return modules, deleted
|
||||
|
||||
def main() -> NoReturn:
|
||||
_, ref, build_type = sys.argv
|
||||
modules, deleted = get_module_list(ref)
|
||||
|
||||
chunked = {
|
||||
"chunk": [
|
||||
{"number": i + 1, "modules": modules}
|
||||
for i, modules in
|
||||
enumerate(itertools.batched(
|
||||
map(lambda x: f"{x}:assemble{build_type}", modules),
|
||||
int(os.getenv("CI_CHUNK_SIZE", 65))
|
||||
))
|
||||
]
|
||||
}
|
||||
|
||||
print(f"Module chunks to build:\n{json.dumps(chunked, indent=2)}\n\nModule to delete:\n{json.dumps(deleted, indent=2)}")
|
||||
|
||||
if os.getenv("CI") == "true":
|
||||
with open(os.getenv("GITHUB_OUTPUT"), 'a') as out_file:
|
||||
out_file.write(f"matrix={json.dumps(chunked)}\n")
|
||||
out_file.write(f"delete={json.dumps(deleted)}\n")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
50
.github/scripts/merge-repo.py
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import html
|
||||
import sys
|
||||
import json
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
|
||||
REMOTE_REPO: Path = Path.cwd()
|
||||
LOCAL_REPO: Path = REMOTE_REPO.parent.joinpath(sys.argv[2])
|
||||
|
||||
to_delete: list[str] = json.loads(sys.argv[1])
|
||||
|
||||
for module in to_delete:
|
||||
apk_name = f"tachiyomi-{module}-v*.*.*.apk"
|
||||
icon_name = f"eu.kanade.tachiyomi.extension.{module}.png"
|
||||
for file in REMOTE_REPO.joinpath("apk").glob(apk_name):
|
||||
print(file.name)
|
||||
file.unlink(missing_ok=True)
|
||||
for file in REMOTE_REPO.joinpath("icon").glob(icon_name):
|
||||
print(file.name)
|
||||
file.unlink(missing_ok=True)
|
||||
|
||||
shutil.copytree(src=LOCAL_REPO.joinpath("apk"), dst=REMOTE_REPO.joinpath("apk"), dirs_exist_ok = True)
|
||||
shutil.copytree(src=LOCAL_REPO.joinpath("icon"), dst=REMOTE_REPO.joinpath("icon"), dirs_exist_ok = True)
|
||||
|
||||
with REMOTE_REPO.joinpath("index.min.json").open() as remote_index_file:
|
||||
remote_index = json.load(remote_index_file)
|
||||
|
||||
with LOCAL_REPO.joinpath("index.min.json").open() as local_index_file:
|
||||
local_index = json.load(local_index_file)
|
||||
|
||||
index = [
|
||||
item for item in remote_index
|
||||
if not any([item["pkg"].endswith(f".{module}") for module in to_delete])
|
||||
]
|
||||
index.extend(local_index)
|
||||
index.sort(key=lambda x: x["pkg"])
|
||||
|
||||
with REMOTE_REPO.joinpath("index.json").open("w", encoding="utf-8") as index_file:
|
||||
json.dump(index, index_file, ensure_ascii=False, indent=2)
|
||||
|
||||
with REMOTE_REPO.joinpath("index.min.json").open("w", encoding="utf-8") as index_min_file:
|
||||
json.dump(index, index_min_file, ensure_ascii=False, separators=(",", ":"))
|
||||
|
||||
with REMOTE_REPO.joinpath("index.html").open("w", encoding="utf-8") as index_html_file:
|
||||
index_html_file.write('<!DOCTYPE html>\n<html>\n<head>\n<meta charset="UTF-8">\n<title>apks</title>\n</head>\n<body>\n<pre>\n')
|
||||
for entry in index:
|
||||
apk_escaped = 'apk/' + html.escape(entry["apk"])
|
||||
name_escaped = html.escape(entry["name"])
|
||||
index_html_file.write(f'<a href="{apk_escaped}">{name_escaped}</a>\n')
|
||||
index_html_file.write('</pre>\n</body>\n</html>\n')
|
||||
26
.github/scripts/move-apks.sh
vendored
@@ -1,26 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
shopt -s globstar nullglob extglob
|
||||
|
||||
# Get APKs from previous jobs' artifacts
|
||||
cp -R ~/apk-artifacts/ $PWD
|
||||
APKS=( **/*".apk" )
|
||||
|
||||
# Fail if too little extensions seem to have been built
|
||||
#if [ "${#APKS[@]}" -le "100" ]; then
|
||||
# echo "Insufficient amount of APKs found. Please check the project configuration."
|
||||
# exit 1
|
||||
#else
|
||||
echo "Moving ${#APKS[@]} APKs"
|
||||
#fi
|
||||
|
||||
DEST=$PWD/apk
|
||||
rm -rf $DEST && mkdir -p $DEST
|
||||
|
||||
for APK in ${APKS[@]}; do
|
||||
BASENAME=$(basename $APK)
|
||||
APKNAME="${BASENAME%%+(-release*)}.apk"
|
||||
APKDEST="$DEST/$APKNAME"
|
||||
|
||||
cp $APK $APKDEST
|
||||
done
|
||||
12
.github/scripts/move-built-apks.py
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
|
||||
REPO_APK_DIR = Path("repo/apk")
|
||||
|
||||
shutil.rmtree(REPO_APK_DIR, ignore_errors=True)
|
||||
REPO_APK_DIR.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
for apk in Path.home().joinpath("apk-artifacts").glob("**/*.apk"):
|
||||
apk_name = apk.name.replace("-release.apk", ".apk")
|
||||
|
||||
shutil.move(apk, REPO_APK_DIR.joinpath(apk_name))
|
||||
25
.github/workflows/batch_close_issues.yml
vendored
@@ -1,25 +0,0 @@
|
||||
name: "Batch close stale issues"
|
||||
|
||||
on:
|
||||
# Monthly
|
||||
schedule:
|
||||
- cron: '0 0 1 * *'
|
||||
# Manual trigger
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v9
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# Close everything older than a year
|
||||
days-before-issue-stale: 365
|
||||
days-before-issue-close: 0
|
||||
exempt-issue-labels: "do-not-autoclose,Meta request"
|
||||
close-issue-message: "In an effort to have a more manageable issue backlog, we're closing older requests that weren't addressed since there's a low chance of it being addressed if it hasn't already. If your request is still relevant, please [open a new request](https://github.com/tachiyomiorg/tachiyomi-extensions/issues/new/choose)."
|
||||
close-issue-reason: not_planned
|
||||
ascending: true
|
||||
operations-per-run: 250
|
||||
163
.github/workflows/build_pull_request.yml
vendored
@@ -1,10 +1,12 @@
|
||||
name: PR build check
|
||||
name: PR check
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- '.github/workflows/issue_moderator.yml'
|
||||
paths:
|
||||
- '**'
|
||||
- '!**.md'
|
||||
- '!.github/**'
|
||||
- '.github/workflows/build_pull_request.yml'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
||||
@@ -12,146 +14,59 @@ concurrency:
|
||||
|
||||
env:
|
||||
CI_CHUNK_SIZE: 65
|
||||
IS_PR_CHECK: true
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
name: Prepare job
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: 'ubuntu-24.04'
|
||||
outputs:
|
||||
individualMatrix: ${{ steps.generate-matrices.outputs.individualMatrix }}
|
||||
multisrcMatrix: ${{ steps.generate-matrices.outputs.multisrcMatrix }}
|
||||
isIndividualChanged: ${{ steps.parse-changed-files.outputs.isIndividualChanged }}
|
||||
isMultisrcChanged: ${{ steps.parse-changed-files.outputs.isMultisrcChanged }}
|
||||
env:
|
||||
CI_MODULE_GEN: true
|
||||
matrix: ${{ steps.generate-matrices.outputs.matrix }}
|
||||
delete: ${{ steps.generate-matrices.outputs.delete }}
|
||||
steps:
|
||||
- name: Clone repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v4
|
||||
- name: Checkout PR
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
java-version: 11
|
||||
distribution: adopt
|
||||
fetch-depth: 0
|
||||
|
||||
- id: get-changed-files
|
||||
name: Get changed files
|
||||
uses: Ana06/get-changed-files@v2.2.0
|
||||
|
||||
- id: parse-changed-files
|
||||
name: Parse changed files
|
||||
run: |
|
||||
isIndividualChanged=0
|
||||
isMultisrcChanged=0
|
||||
for changedFile in ${{ steps.get-changed-files.outputs.all }}; do
|
||||
if [[ ${changedFile} == src/* ]]; then
|
||||
isIndividualChanged=1
|
||||
elif [[ ${changedFile} == multisrc/* ]]; then
|
||||
isMultisrcChanged=1
|
||||
elif [[ ${changedFile} == .github/workflows/issue_moderator.yml ]]; then
|
||||
true
|
||||
elif [[ ${changedFile} == *.md ]]; then
|
||||
true
|
||||
else
|
||||
isIndividualChanged=1
|
||||
isMultisrcChanged=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
echo "isIndividualChanged=$isIndividualChanged" >> $GITHUB_OUTPUT
|
||||
echo "isMultisrcChanged=$isMultisrcChanged" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Generate multisrc sources
|
||||
if: ${{ steps.parse-changed-files.outputs.isMultisrcChanged == '1' }}
|
||||
uses: gradle/gradle-build-action@v2
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||
with:
|
||||
arguments: :multisrc:generateExtensions
|
||||
java-version: 17
|
||||
distribution: temurin
|
||||
|
||||
- name: Get number of modules
|
||||
run: |
|
||||
set -x
|
||||
./gradlew -q projects | grep '.*extensions\:\(individual\|multisrc\)\:.*\:.*' > projects.txt
|
||||
|
||||
echo "NUM_INDIVIDUAL_MODULES=$(cat projects.txt | grep '.*\:individual\:.*' | wc -l)" >> $GITHUB_ENV
|
||||
echo "NUM_MULTISRC_MODULES=$(cat projects.txt | grep '.*\:multisrc\:.*' | wc -l)" >> $GITHUB_ENV
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 # v4.3.1
|
||||
with:
|
||||
cache-read-only: true
|
||||
|
||||
- id: generate-matrices
|
||||
name: Create output matrices
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const numIndividualModules = process.env.NUM_INDIVIDUAL_MODULES;
|
||||
const numMultisrcModules = process.env.NUM_MULTISRC_MODULES;
|
||||
const chunkSize = process.env.CI_CHUNK_SIZE;
|
||||
name: Generate build matrices
|
||||
run: |
|
||||
python ./.github/scripts/generate-build-matrices.py origin/master Debug
|
||||
|
||||
const numIndividualChunks = Math.ceil(numIndividualModules / chunkSize);
|
||||
const numMultisrcChunks = Math.ceil(numMultisrcModules / chunkSize);
|
||||
|
||||
console.log(`Individual modules: ${numIndividualModules} (${numIndividualChunks} chunks of ${chunkSize})`);
|
||||
console.log(`Multi-source modules: ${numMultisrcModules} (${numMultisrcChunks} chunks of ${chunkSize})`);
|
||||
|
||||
core.setOutput('individualMatrix', { 'chunk': [...Array(numIndividualChunks).keys()] });
|
||||
core.setOutput('multisrcMatrix', { 'chunk': [...Array(numMultisrcChunks).keys()] });
|
||||
|
||||
build_multisrc:
|
||||
name: Build multisrc modules
|
||||
build:
|
||||
name: Build extensions (${{ matrix.chunk.number }})
|
||||
needs: prepare
|
||||
if: ${{ needs.prepare.outputs.isMultisrcChanged == '1' }}
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: 'ubuntu-24.04'
|
||||
if: ${{ toJson(fromJson(needs.prepare.outputs.matrix).chunk) != '[]' }}
|
||||
strategy:
|
||||
matrix: ${{ fromJSON(needs.prepare.outputs.multisrcMatrix) }}
|
||||
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
|
||||
steps:
|
||||
- name: Checkout PR
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v4
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||
with:
|
||||
java-version: 11
|
||||
distribution: adopt
|
||||
java-version: 17
|
||||
distribution: temurin
|
||||
|
||||
- name: Generate sources from the multi-source library
|
||||
uses: gradle/gradle-build-action@v2
|
||||
env:
|
||||
CI_MODULE_GEN: "true"
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 # v4.3.1
|
||||
with:
|
||||
arguments: :multisrc:generateExtensions
|
||||
cache-read-only: true
|
||||
|
||||
- name: Build extensions (chunk ${{ matrix.chunk }})
|
||||
uses: gradle/gradle-build-action@v2
|
||||
env:
|
||||
CI_MULTISRC: "true"
|
||||
CI_CHUNK_NUM: ${{ matrix.chunk }}
|
||||
with:
|
||||
arguments: assembleDebug
|
||||
cache-read-only: true
|
||||
|
||||
build_individual:
|
||||
name: Build individual modules
|
||||
needs: prepare
|
||||
if: ${{ needs.prepare.outputs.isIndividualChanged == '1' }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix: ${{ fromJSON(needs.prepare.outputs.individualMatrix) }}
|
||||
steps:
|
||||
- name: Checkout PR
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: 11
|
||||
distribution: adopt
|
||||
|
||||
- name: Build extensions (chunk ${{ matrix.chunk }})
|
||||
uses: gradle/gradle-build-action@v2
|
||||
env:
|
||||
CI_MULTISRC: "false"
|
||||
CI_CHUNK_NUM: ${{ matrix.chunk }}
|
||||
with:
|
||||
arguments: assembleDebug
|
||||
cache-read-only: true
|
||||
- name: Build extensions (${{ matrix.chunk.number }})
|
||||
run: |
|
||||
./gradlew $(echo '${{ toJson(matrix.chunk.modules) }}' | jq -r 'join(" ")')
|
||||
|
||||
171
.github/workflows/build_push.yml
vendored
@@ -3,10 +3,16 @@ name: CI
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
# - main
|
||||
- master
|
||||
paths-ignore:
|
||||
- '**.md'
|
||||
- '.github/workflows/issue_moderator.yml'
|
||||
paths:
|
||||
- '**'
|
||||
- '!**.md'
|
||||
- '!.github/**'
|
||||
- '.github/scripts/**'
|
||||
- '.github/workflows/build_push.yml'
|
||||
# Manual trigger
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}
|
||||
@@ -14,132 +20,149 @@ concurrency:
|
||||
|
||||
env:
|
||||
CI_CHUNK_SIZE: 65
|
||||
IS_PR_CHECK: false
|
||||
|
||||
jobs:
|
||||
prepare:
|
||||
name: Prepare job
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: 'ubuntu-24.04'
|
||||
outputs:
|
||||
individualMatrix: ${{ steps.generate-matrices.outputs.individualMatrix }}
|
||||
env:
|
||||
CI_MODULE_GEN: true
|
||||
latestCommitMessage: ${{ steps.set-env.outputs.LATEST_COMMIT_MESSAGE }}
|
||||
matrix: ${{ steps.generate-matrices.outputs.matrix }}
|
||||
delete: ${{ steps.generate-matrices.outputs.delete }}
|
||||
steps:
|
||||
- name: Clone repo
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v4
|
||||
- name: Checkout ${{ github.ref_name }} branch
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
java-version: 11
|
||||
distribution: adopt
|
||||
fetch-depth: 0
|
||||
|
||||
|
||||
- name: Get number of modules
|
||||
- name: Set env
|
||||
id: set-env
|
||||
run: |
|
||||
set -x
|
||||
./gradlew -q projects | grep '.*extensions\:\(individual\)\:.*\:.*' > projects.txt
|
||||
echo "LATEST_COMMIT_MESSAGE<<{delimiter}
|
||||
$(git log -1 --pretty=%B)
|
||||
{delimiter}" >> $GITHUB_OUTPUT
|
||||
|
||||
echo "NUM_INDIVIDUAL_MODULES=$(cat projects.txt | grep '.*\:individual\:.*' | wc -l)" >> $GITHUB_ENV
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||
with:
|
||||
java-version: 17
|
||||
distribution: temurin
|
||||
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 # v4.3.1
|
||||
with:
|
||||
cache-read-only: true
|
||||
|
||||
- name: Get last successful CI commit
|
||||
id: last_successful_ci_commit
|
||||
uses: nrwl/nx-set-shas@dbe0650947e5f2c81f59190a38512cf49126fe6b # v4.3.0
|
||||
with:
|
||||
main-branch-name: ${{ github.ref_name }}
|
||||
|
||||
- id: generate-matrices
|
||||
name: Create output matrices
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const numIndividualModules = process.env.NUM_INDIVIDUAL_MODULES;
|
||||
const chunkSize = process.env.CI_CHUNK_SIZE;
|
||||
run: |
|
||||
python ./.github/scripts/generate-build-matrices.py ${{ steps.last_successful_ci_commit.outputs.base }} Release
|
||||
|
||||
const numIndividualChunks = Math.ceil(numIndividualModules / chunkSize);
|
||||
|
||||
console.log(`Individual modules: ${numIndividualModules} (${numIndividualChunks} chunks of ${chunkSize})`);
|
||||
|
||||
core.setOutput('individualMatrix', { 'chunk': [...Array(numIndividualChunks).keys()] });
|
||||
|
||||
build_individual:
|
||||
name: Build individual modules
|
||||
build:
|
||||
name: Build extensions (${{ matrix.chunk.number }})
|
||||
needs: prepare
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: 'ubuntu-24.04'
|
||||
if: ${{ toJson(fromJson(needs.prepare.outputs.matrix).chunk) != '[]' }}
|
||||
strategy:
|
||||
matrix: ${{ fromJSON(needs.prepare.outputs.individualMatrix) }}
|
||||
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
|
||||
steps:
|
||||
- name: Checkout master branch
|
||||
uses: actions/checkout@v4
|
||||
- name: Checkout ${{ github.ref_name }} branch
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v4
|
||||
- name: Set up Java
|
||||
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||
with:
|
||||
java-version: 11
|
||||
distribution: adopt
|
||||
java-version: 17
|
||||
distribution: temurin
|
||||
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@06832c7b30a0129d7fb559bcc6e43d26f6374244 # v4.3.1
|
||||
with:
|
||||
cache-read-only: ${{ matrix.chunk.number > 1 }}
|
||||
|
||||
- name: Prepare signing key
|
||||
run: |
|
||||
echo ${{ secrets.SIGNING_KEY }} | base64 -d > signingkey.jks
|
||||
|
||||
- name: Build extensions (chunk ${{ matrix.chunk }})
|
||||
uses: gradle/gradle-build-action@v2
|
||||
- name: Build extensions (${{ matrix.chunk.number }})
|
||||
env:
|
||||
CI_MULTISRC: "false"
|
||||
CI_CHUNK_NUM: ${{ matrix.chunk }}
|
||||
ALIAS: ${{ secrets.ALIAS }}
|
||||
KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
|
||||
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
|
||||
with:
|
||||
arguments: assembleRelease
|
||||
run: |
|
||||
./gradlew $(echo '${{ toJson(matrix.chunk.modules) }}' | jq -r 'join(" ")')
|
||||
|
||||
- name: Upload APKs (chunk ${{ matrix.chunk }})
|
||||
uses: actions/upload-artifact@v4
|
||||
if: "github.repository == 'Kareadita/tach-extension'"
|
||||
- name: Upload APKs (${{ matrix.chunk.number }})
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: github.repository == 'Kareadita/tach-extension'
|
||||
with:
|
||||
name: "individual-apks-${{ matrix.chunk }}"
|
||||
name: "individual-apks-${{ matrix.chunk.number }}"
|
||||
path: "**/*.apk"
|
||||
retention-days: 1
|
||||
|
||||
- name: Clean up CI files
|
||||
run: rm signingkey.jks
|
||||
|
||||
publish_repo:
|
||||
name: Publish repo
|
||||
needs:
|
||||
- build_individual
|
||||
if: "github.repository == 'Kareadita/tach-extension'"
|
||||
runs-on: ubuntu-latest
|
||||
publish:
|
||||
name: Publish extension repo
|
||||
needs: [prepare, build]
|
||||
if: github.repository == 'Kareadita/tach-extension'
|
||||
runs-on: 'ubuntu-24.04'
|
||||
steps:
|
||||
- name: Download APK artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
path: ~/apk-artifacts
|
||||
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v4
|
||||
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
|
||||
with:
|
||||
java-version: 17
|
||||
distribution: adopt
|
||||
distribution: temurin
|
||||
|
||||
- name: Checkout master branch
|
||||
uses: actions/checkout@v4
|
||||
- name: Checkout ${{ github.ref_name }} branch
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
ref: master
|
||||
path: master
|
||||
ref: ${{ github.ref_name }}
|
||||
path: ${{ github.ref_name }}
|
||||
|
||||
- name: Create repo artifacts
|
||||
run: |
|
||||
cd master
|
||||
./.github/scripts/move-apks.sh
|
||||
INSPECTOR_LINK="$(curl -s "https://api.github.com/repos/tachiyomiorg/tachiyomi-extensions-inspector/releases/latest" | jq -r '.assets[0].browser_download_url')"
|
||||
cd ${{ github.ref_name }}
|
||||
python ./.github/scripts/move-built-apks.py
|
||||
INSPECTOR_LINK="$(curl -s "https://api.github.com/repos/keiyoushi/extensions-inspector/releases/latest" | jq -r '.assets[0].browser_download_url')"
|
||||
curl -L "$INSPECTOR_LINK" -o ./Inspector.jar
|
||||
java -jar ./Inspector.jar "apk" "output.json" "tmp"
|
||||
./.github/scripts/create-repo.sh
|
||||
java -jar ./Inspector.jar "repo/apk" "output.json" "tmp"
|
||||
python ./.github/scripts/create-repo.py
|
||||
|
||||
- name: Checkout repo branch
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: Kareadita/tach-extension
|
||||
token: ${{ secrets.BOT_PAT }}
|
||||
ref: repo
|
||||
path: repo
|
||||
|
||||
- name: Deploy repo
|
||||
- name: Merge repo
|
||||
run: |
|
||||
cd repo
|
||||
../master/.github/scripts/commit-repo.sh
|
||||
python ../${{ github.ref_name }}/.github/scripts/merge-repo.py '${{ needs.prepare.outputs.delete }}' '${{ github.ref_name }}/repo'
|
||||
|
||||
- name: Deploy repo
|
||||
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9
|
||||
with:
|
||||
message: "${{ needs.prepare.outputs.latestCommitMessage }}"
|
||||
cwd: "./repo"
|
||||
committer_name: github-actions[bot]
|
||||
committer_email: github-actions[bot]@users.noreply.github.com
|
||||
|
||||
- name: Purge cached index on jsDelivr
|
||||
run: |
|
||||
curl https://purge.jsdelivr.net/gh/Kareadita/tach-extension@repo/index.min.json
|
||||
|
||||
22
.github/workflows/codeberg_mirror.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
# Sync repo to the Codeberg mirror
|
||||
name: Mirror Sync
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
workflow_dispatch: # Manual dispatch
|
||||
schedule:
|
||||
- cron: "0 */8 * * *"
|
||||
|
||||
jobs:
|
||||
codeberg:
|
||||
if: github.repository == 'yuzono/tachiyomi-extensions'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: pixta-dev/repository-mirroring-action@674e65a7d483ca28dafaacba0d07351bdcc8bd75 # v1.1.1
|
||||
with:
|
||||
target_repo_url: "git@codeberg.org:cuong-tran/komikku-extensions.git"
|
||||
ssh_private_key: ${{ secrets.CODEBERG_SSH }}
|
||||
70
.github/workflows/issue_moderator.yml
vendored
@@ -2,20 +2,32 @@ name: Issue moderator
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [opened, edited, reopened]
|
||||
types: [ opened, edited, reopened ]
|
||||
issue_comment:
|
||||
types: [created]
|
||||
types: [ created ]
|
||||
|
||||
jobs:
|
||||
autoclose:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Moderate issues
|
||||
uses: tachiyomiorg/issue-moderator-action@v2
|
||||
uses: keiyoushi/issue-moderator-action@a017be83547db6e107431ce7575f53c1dfa3296a
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
duplicate-label: Duplicate
|
||||
|
||||
blurbs: |
|
||||
[
|
||||
{
|
||||
"keywords": ["cf", "cloudflare"],
|
||||
"message": "Refer to the **Solving Cloudflare issues** section at https://yuzono.github.io/docs/guides/troubleshooting#cloudflare. If it doesn't work, migrate to other sources or wait until they lower their protection."
|
||||
},
|
||||
{
|
||||
"keywords": ["uninstall"],
|
||||
"message": "Uninstall the extension before updating. If that does not work, uninstall it from your device's settings by navigating to your device's Settings -> Apps and uninstall it from there by looking for `Tachiyomi: <extension name>`.\n\nThis is usually caused your previous extension having a different signature from the updated extension, making Android refuse to update it."
|
||||
}
|
||||
]
|
||||
|
||||
duplicate-check-enabled: true
|
||||
duplicate-check-labels: |
|
||||
["Source request", "Domain changed"]
|
||||
@@ -23,51 +35,37 @@ jobs:
|
||||
existing-check-enabled: true
|
||||
existing-check-labels: |
|
||||
["Source request", "Domain changed"]
|
||||
existing-check-repo-url: https://raw.githubusercontent.com/yuzono/manga-repo/repo/index.min.json
|
||||
|
||||
auto-close-rules: |
|
||||
[
|
||||
{
|
||||
"type": "body",
|
||||
"regex": ".*DELETE THIS SECTION IF YOU HAVE READ AND ACKNOWLEDGED IT.*",
|
||||
"message": "The acknowledgment section was not removed."
|
||||
},
|
||||
{
|
||||
"type": "body",
|
||||
"regex": ".*\\* (Tachiyomi version|Android version|Device): \\?.*",
|
||||
"message": "Requested information in the template was not filled out."
|
||||
},
|
||||
{
|
||||
"type": "title",
|
||||
"regex": ".*(Source name|Short description).*",
|
||||
"message": "You did not fill out the description in the title."
|
||||
},
|
||||
{
|
||||
"type": "both",
|
||||
"regex": ".*(hq\\s*dragon|manga\\s*host|supermangas|superhentais|union\\s*mangas|yes\\s*mangas|manhuascan|manhwahot|leitor\\.?net|manga\\s*livre|tsuki\\s*mangas|manga\\s*yabu|mangas\\.in|mangas\\.pw|hentaikai|toptoon\\+?|colamanhua|mangadig|hitomi\\.la|copymanga|neox|1manga\\.co|mangafox\\.fun|mangahere\\.onl|mangakakalot\\.fun|manganel(?!o)|mangaonline\\.fun|mangatoday|manga\\.town|onemanga\\.info|koushoku|ksk\\.moe|comikey|leercapitulo|c[uứ]u\\s*truy[eệ]n|day\\s*comics?|reaper\\s*scans|constellar\\s*scans|mode\\s*scanlator|bakai|japscan|izakaya|blackout\\s*comics|anchira).*",
|
||||
"ignoreCase": true,
|
||||
"labels": ["invalid"],
|
||||
"message": "{match} will not be added back as it is too difficult to maintain. Read [this](https://github.com/tachiyomiorg/tachiyomi-extensions/blob/master/REMOVED_SOURCES.md) for more information."
|
||||
},
|
||||
{
|
||||
"type": "both",
|
||||
"regex": ".*(komiktap|gourmet\\s*scans|mangawow|hikari\\s*scans|knightnoscanlations|mangasy|nartag|xxx\\s*yaoi|luminous|hunters\\s*scan|reset(?:\\s*|-)scan|astra\\s*scans|manga(?:-|\\s*)pro|shinobiscans|plot ?twist ?no ?fansub(?: ?scans?)?|plot-twistnf-scans(?:\\.com)?|mhscans|aresmanga|realm ?scans?|mono ?manga|dat(?:\\s*|-)?gar\\s*scan|remangas|moon ?daisy(?: scans?)?).*",
|
||||
"ignoreCase": true,
|
||||
"labels": ["invalid"],
|
||||
"message": "{match} will not be added back as the scanlator team has requested it to be removed. Read [this](https://github.com/tachiyomiorg/tachiyomi-extensions/blob/master/REMOVED_SOURCES.md) for more information."
|
||||
},
|
||||
{
|
||||
"type": "both",
|
||||
"regex": ".*(?:fail(?:ed|ure|s)?|can\\s*(?:no|')?t|(?:not|un).*able|(?<!n[o']?t )blocked by|error) (?:to )?(?:get past|by ?pass|penetrate)?.*cloud ?fl?are.*",
|
||||
"regex": ".*(?:fail(?:ed|ure|s)?|can\\s*(?:no|')?t|(?:not|un).*able|(?<!n[o']?t )blocked by|error) (?:to )?(?:get past|by ?pass|penetrate)?.*cl[oa]ud ?fl?[ai]re.*",
|
||||
"ignoreCase": true,
|
||||
"labels": ["Cloudflare protected"],
|
||||
"message": "Refer to the **Solving Cloudflare issues** section at https://tachiyomi.org/docs/guides/troubleshooting/#cloudflare. If it doesn't work, migrate to other sources or wait until they lower their protection."
|
||||
"message": "Refer to the **Solving Cloudflare issues** section at https://yuzono.github.io/docs/guides/troubleshooting#cloudflare. If it doesn't work, migrate to other sources or wait until they lower their protection."
|
||||
},
|
||||
{
|
||||
"type": "both",
|
||||
"regex": ".*(slime\\s*read).*",
|
||||
"regex": "remanga\\.org",
|
||||
"ignoreCase": true,
|
||||
"labels": ["invalid"],
|
||||
"message": "{match} will not be added as they have relations to the Mangá Livre team. Read [this](https://github.com/tachiyomiorg/tachiyomi-extensions/blob/master/REMOVED_SOURCES.md) for more information."
|
||||
"message": "ReManga (Russian) will not be added back as it has been removed [due to legal reasons](https://github.com/github/dmca)."
|
||||
},
|
||||
{
|
||||
"type": "both",
|
||||
"regex": "(kumanga\\.com)",
|
||||
"ignoreCase": true,
|
||||
"labels": ["invalid"],
|
||||
"message": "{match} will not be added back as it is too difficult to maintain."
|
||||
},
|
||||
{
|
||||
"type": "both",
|
||||
"regex": "(centralnovel\\.com)",
|
||||
"ignoreCase": true,
|
||||
"labels": ["invalid"],
|
||||
"message": "Novels aren't supported"
|
||||
}
|
||||
]
|
||||
auto-close-ignore-label: do-not-autoclose
|
||||
|
||||
3
.github/workflows/lock.yml
vendored
@@ -8,11 +8,12 @@ on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
|
||||
|
||||
jobs:
|
||||
lock:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: dessant/lock-threads@v5
|
||||
- uses: dessant/lock-threads@1bf7ec25051fe7c00bdd17e6a7cf3d7bfb7dc771 # v5.0.1
|
||||
with:
|
||||
github-token: ${{ github.token }}
|
||||
issue-inactive-days: '2'
|
||||
|
||||
1
.gitignore
vendored
@@ -10,3 +10,4 @@ repo/
|
||||
apk/
|
||||
gen
|
||||
generated-src/
|
||||
.kotlin
|
||||
|
||||
6
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,6 @@
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v5.0.0 # Use the latest stable version
|
||||
hooks:
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
382
CONTRIBUTING.md
@@ -1,40 +1,68 @@
|
||||
# Contributing
|
||||
|
||||
This guide have some instructions and tips on how to create a new Tachiyomi extension. Please **read it carefully** if you're a new contributor or don't have any experience on the required languages and knowledges.
|
||||
This guide have some instructions and tips on how to create a new Tachiyomi extension. Please **read
|
||||
it carefully** if you're a new contributor or don't have any experience on the required languages
|
||||
and knowledges.
|
||||
|
||||
This guide is not definitive and it's being updated over time. If you find any issue on it, feel free to report it through a [Meta Issue](https://github.com/tachiyomiorg/tachiyomi-extensions/issues/new?assignees=&labels=Meta+request&template=request_meta.yml) or fixing it directly by submitting a Pull Request.
|
||||
This guide is not definitive and it's being updated over time. If you find any issue on it, feel
|
||||
free to report it through a [Meta Issue](https://github.com/yuzono/tachiyomi-extensions/issues/new?assignees=&labels=Meta+request&template=06_request_meta.yml)
|
||||
or fixing it directly by submitting a Pull Request.
|
||||
|
||||
## Table of Contents
|
||||
|
||||
1. [Prerequisites](#prerequisites)
|
||||
1. [Tools](#tools)
|
||||
2. [Cloning the repository](#cloning-the-repository)
|
||||
2. [Getting help](#getting-help)
|
||||
3. [Writing an extension](#writing-an-extension)
|
||||
1. [Setting up a new Gradle module](#setting-up-a-new-gradle-module)
|
||||
2. [Core dependencies](#core-dependencies)
|
||||
3. [Extension main class](#extension-main-class)
|
||||
4. [Extension call flow](#extension-call-flow)
|
||||
5. [Misc notes](#misc-notes)
|
||||
6. [Advanced extension features](#advanced-extension-features)
|
||||
4. [Multi-source themes](#multi-source-themes)
|
||||
1. [The directory structure](#the-directory-structure)
|
||||
2. [Development workflow](#development-workflow)
|
||||
3. [Scaffolding overrides](#scaffolding-overrides)
|
||||
4. [Additional Notes](#additional-notes)
|
||||
5. [Running](#running)
|
||||
6. [Debugging](#debugging)
|
||||
1. [Android Debugger](#android-debugger)
|
||||
2. [Logs](#logs)
|
||||
3. [Inspecting network calls](#inspecting-network-calls)
|
||||
4. [Using external network inspecting tools](#using-external-network-inspecting-tools)
|
||||
7. [Building](#building)
|
||||
8. [Submitting the changes](#submitting-the-changes)
|
||||
1. [Pull Request checklist](#pull-request-checklist)
|
||||
- [Contributing](#contributing)
|
||||
- [Table of Contents](#table-of-contents)
|
||||
- [Prerequisites](#prerequisites)
|
||||
- [Tools](#tools)
|
||||
- [Cloning the repository](#cloning-the-repository)
|
||||
- [Getting help](#getting-help)
|
||||
- [Writing an extension](#writing-an-extension)
|
||||
- [Setting up a new Gradle module](#setting-up-a-new-gradle-module)
|
||||
- [Loading a subset of Gradle modules](#loading-a-subset-of-gradle-modules)
|
||||
- [Extension file structure](#extension-file-structure)
|
||||
- [AndroidManifest.xml (optional)](#androidmanifestxml-optional)
|
||||
- [build.gradle](#buildgradle)
|
||||
- [Core dependencies](#core-dependencies)
|
||||
- [Extension API](#extension-api)
|
||||
- [DataImage library](#dataimage-library)
|
||||
- [i18n library](#i18n-library)
|
||||
- [Additional dependencies](#additional-dependencies)
|
||||
- [Extension main class](#extension-main-class)
|
||||
- [Main class key variables](#main-class-key-variables)
|
||||
- [Extension call flow](#extension-call-flow)
|
||||
- [Popular Manga](#popular-manga)
|
||||
- [Latest Manga](#latest-manga)
|
||||
- [Manga Search](#manga-search)
|
||||
- [Filters](#filters)
|
||||
- [Manga Details](#manga-details)
|
||||
- [Chapter](#chapter)
|
||||
- [Chapter Pages](#chapter-pages)
|
||||
- [Misc notes](#misc-notes)
|
||||
- [Advanced Extension features](#advanced-extension-features)
|
||||
- [URL intent filter](#url-intent-filter)
|
||||
- [Update strategy](#update-strategy)
|
||||
- [Renaming existing sources](#renaming-existing-sources)
|
||||
- [Multi-source themes](#multi-source-themes)
|
||||
- [The directory structure](#the-directory-structure)
|
||||
- [Development workflow](#development-workflow)
|
||||
- [Scaffolding overrides](#scaffolding-overrides)
|
||||
- [Additional Notes](#additional-notes)
|
||||
- [Running](#running)
|
||||
- [Debugging](#debugging)
|
||||
- [Android Debugger](#android-debugger)
|
||||
- [Logs](#logs)
|
||||
- [Inspecting network calls](#inspecting-network-calls)
|
||||
- [Using external network inspecting tools](#using-external-network-inspecting-tools)
|
||||
- [Setup your proxy server](#setup-your-proxy-server)
|
||||
- [OkHttp proxy setup](#okhttp-proxy-setup)
|
||||
- [Building](#building)
|
||||
- [Submitting the changes](#submitting-the-changes)
|
||||
- [Pull Request checklist](#pull-request-checklist)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Before you start, please note that the ability to use following technologies is **required** and that existing contributors will not actively teach them to you.
|
||||
Before you start, please note that the ability to use following technologies is **required** and
|
||||
that existing contributors will not actively teach them to you.
|
||||
|
||||
- Basic [Android development](https://developer.android.com/)
|
||||
- [Kotlin](https://kotlinlang.org/)
|
||||
@@ -47,13 +75,15 @@ Before you start, please note that the ability to use following technologies is
|
||||
### Tools
|
||||
|
||||
- [Android Studio](https://developer.android.com/studio)
|
||||
- Emulator or phone with developer options enabled and a recent version of Tachiyomi installed
|
||||
- Emulator or phone with developer options enabled and a recent version of Komikku installed
|
||||
- [Icon Generator](https://as280093.github.io/AndroidAssetStudio/icons-launcher.html)
|
||||
|
||||
### Cloning the repository
|
||||
|
||||
Some alternative steps can be followed to ignore "repo" branch and skip unrelated sources, which will make it faster to pull, navigate and build. This will also reduce disk usage and network traffic.
|
||||
|
||||
**These steps are only needed when the repo is huge and contains a lot of sources. If the repo is small, just do a normal full clone instead.**
|
||||
|
||||
<details><summary>Steps</summary>
|
||||
|
||||
1. Make sure to delete "repo" branch in your fork. You may also want to disable Actions in the repo settings.
|
||||
@@ -81,12 +111,9 @@ Some alternative steps can be followed to ignore "repo" branch and skip unrelate
|
||||
```bash
|
||||
git sparse-checkout set --cone --sparse-index
|
||||
# add project folders
|
||||
git sparse-checkout add .run buildSrc core gradle lib multisrc/src/main/java/generator
|
||||
git sparse-checkout add buildSrc core gradle lib lib-multisrc utils
|
||||
# add a single source
|
||||
git sparse-checkout add src/<lang>/<source>
|
||||
# add a multisrc theme
|
||||
git sparse-checkout add multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/<source>
|
||||
git sparse-checkout add multisrc/overrides/<source>
|
||||
```
|
||||
|
||||
To remove a source, open `.git/info/sparse-checkout` and delete the exact
|
||||
@@ -103,17 +130,17 @@ Some alternative steps can be followed to ignore "repo" branch and skip unrelate
|
||||
# alternatively, if you have VS Code installed
|
||||
code .git/info/sparse-checkout
|
||||
```
|
||||
|
||||
Here's an example:
|
||||
|
||||
```bash
|
||||
/*
|
||||
!/src/*
|
||||
!/multisrc/overrides/*
|
||||
!/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/*
|
||||
!/multisrc-lib/*
|
||||
# allow a single source
|
||||
/src/<lang>/<source>
|
||||
# allow a multisrc theme
|
||||
/multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/<source>
|
||||
/multisrc/overrides/<source>
|
||||
/lib-multisrc/<source>
|
||||
# or type the source name directly
|
||||
<source>
|
||||
```
|
||||
@@ -124,7 +151,7 @@ Some alternative steps can be followed to ignore "repo" branch and skip unrelate
|
||||
4. Configure remotes.
|
||||
```bash
|
||||
# add upstream
|
||||
git remote add upstream <tachiyomiorg-repo-url>
|
||||
git remote add upstream <yuzono-url>
|
||||
# optionally disable push to upstream
|
||||
git remote set-url --push upstream no_pushing
|
||||
# ignore 'repo' branch of upstream
|
||||
@@ -159,22 +186,27 @@ Read more on
|
||||
[sparse checkout](https://github.blog/2020-01-17-bring-your-monorepo-down-to-size-with-sparse-checkout/),
|
||||
[sparse index](https://github.blog/2021-11-10-make-your-monorepo-feel-small-with-gits-sparse-index/),
|
||||
and [negative refspecs](https://github.blog/2020-10-19-git-2-29-released/#user-content-negative-refspecs).
|
||||
|
||||
</details>
|
||||
|
||||
## Getting help
|
||||
|
||||
- Join [the Discord server](https://discord.gg/tachiyomi) for online help and to ask questions while developing your extension. When doing so, please ask it in the `#programming` channel.
|
||||
- There are some features and tricks that are not explored in this document. Refer to existing extension code for examples.
|
||||
- There are some features and tricks that are not explored in this document. Refer to existing
|
||||
extension code for examples.
|
||||
|
||||
## Writing an extension
|
||||
|
||||
The quickest way to get started is to copy an existing extension's folder structure and renaming it as needed. We also recommend reading through a few existing extensions' code before you start.
|
||||
The quickest way to get started is to copy an existing extension's folder structure and renaming it
|
||||
as needed. We also recommend reading through a few existing extensions' code before you start.
|
||||
|
||||
### Setting up a new Gradle module
|
||||
|
||||
Each extension should reside in `src/<lang>/<mysourcename>`. Use `all` as `<lang>` if your target source supports multiple languages or if it could support multiple sources.
|
||||
Each extension should reside in `src/<lang>/<mysourcename>`. Use `all` as `<lang>` if your target
|
||||
source supports multiple languages or if it could support multiple sources.
|
||||
|
||||
The `<lang>` used in the folder inside `src` should be the major `language` part. For example, if you will be creating a `pt-BR` source, use `<lang>` here as `pt` only. Inside the source class, use the full locale string instead.
|
||||
The `<lang>` used in the folder inside `src` should be the major `language` part. For example, if
|
||||
you will be creating a `pt-BR` source, use `<lang>` here as `pt` only. Inside the source class, use
|
||||
the full locale string instead.
|
||||
|
||||
### Loading a subset of Gradle modules
|
||||
|
||||
@@ -190,7 +222,7 @@ The simplest extension structure looks like this:
|
||||
```console
|
||||
$ tree src/<lang>/<mysourcename>/
|
||||
src/<lang>/<mysourcename>/
|
||||
├── AndroidManifest.xml
|
||||
├── AndroidManifest.xml (optional)
|
||||
├── build.gradle
|
||||
├── res
|
||||
│ ├── mipmap-hdpi
|
||||
@@ -201,9 +233,8 @@ src/<lang>/<mysourcename>/
|
||||
│ │ └── ic_launcher.png
|
||||
│ ├── mipmap-xxhdpi
|
||||
│ │ └── ic_launcher.png
|
||||
│ ├── mipmap-xxxhdpi
|
||||
│ │ └── ic_launcher.png
|
||||
│ └── web_hi_res_512.png
|
||||
│ └── mipmap-xxxhdpi
|
||||
│ └── ic_launcher.png
|
||||
└── src
|
||||
└── eu
|
||||
└── kanade
|
||||
@@ -216,19 +247,22 @@ src/<lang>/<mysourcename>/
|
||||
13 directories, 9 files
|
||||
```
|
||||
|
||||
#### AndroidManifest.xml
|
||||
A minimal [Android manifest file](https://developer.android.com/guide/topics/manifest/manifest-intro) is needed for Android to recognize a extension when it's compiled into an APK file. You can also add intent filters inside this file (see [URL intent filter](#url-intent-filter) for more information).
|
||||
`<lang>` should be an ISO 639-1 compliant language code (two letters or `all`). `<mysourcename>` should be adapted from the site name, and can only contain lowercase ASCII letters and digits.
|
||||
|
||||
Your extension code must be placed in the package `eu.kanade.tachiyomi.extension.<lang>.<mysourcename>`.
|
||||
|
||||
#### AndroidManifest.xml (optional)
|
||||
|
||||
You only need to create this file if you want to add deep linking to your extension.
|
||||
See [URL intent filter](#url-intent-filter) for more information.
|
||||
|
||||
#### build.gradle
|
||||
|
||||
Make sure that your new extension's `build.gradle` file follows the following structure:
|
||||
|
||||
```gradle
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
|
||||
```groovy
|
||||
ext {
|
||||
extName = '<My source name>'
|
||||
pkgNameSuffix = '<lang>.<mysourcename>'
|
||||
extClass = '.<MySourceName>'
|
||||
extVersionCode = 1
|
||||
isNsfw = true
|
||||
@@ -238,27 +272,29 @@ apply from: "$rootDir/common.gradle"
|
||||
```
|
||||
|
||||
| Field | Description |
|
||||
| ----- | ----------- |
|
||||
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `extName` | The name of the extension. |
|
||||
| `pkgNameSuffix` | A unique suffix added to `eu.kanade.tachiyomi.extension`. The language and the site name should be enough. Remember your extension code implementation must be placed in this package. |
|
||||
| `extClass` | Points to the class that implements `Source`. You can use a relative path starting with a dot (the package name is the base path). This is used to find and instantiate the source(s). |
|
||||
| `extVersionCode` | The extension version code. This must be a positive integer and incremented with any change to the code. |
|
||||
| `libVersion` | (Optional, defaults to `1.4`) The version of the [extensions library](https://github.com/tachiyomiorg/extensions-lib) used. |
|
||||
| `isNsfw` | (Optional, defaults to `false`) Flag to indicate that a source contains NSFW content. |
|
||||
|
||||
The extension's version name is generated automatically by concatenating `libVersion` and `extVersionCode`. With the example used above, the version would be `1.4.1`.
|
||||
The extension's version name is generated automatically by concatenating `1.4` and `extVersionCode`.
|
||||
With the example used above, the version would be `1.4.1`.
|
||||
|
||||
### Core dependencies
|
||||
|
||||
#### Extension API
|
||||
|
||||
Extensions rely on [extensions-lib](https://github.com/tachiyomiorg/extensions-lib), which provides some interfaces and stubs from the [app](https://github.com/tachiyomiorg/tachiyomi) for compilation purposes. The actual implementations can be found [here](https://github.com/tachiyomiorg/tachiyomi/tree/master/app/src/main/java/eu/kanade/tachiyomi/source). Referencing the actual implementation will help with understanding extensions' call flow.
|
||||
Extensions rely on [extensions-lib](https://github.com/komikku-app/extensions-lib), which provides some interfaces and stubs from the [app](https://github.com/komikku-app/komikku) for compilation purposes. The actual implementations can be found [here](https://github.com/komikku-app/komikku/tree/master/app/src/main/java/eu/kanade/tachiyomi/source). Referencing the actual implementation will help with understanding extensions' call flow.
|
||||
|
||||
#### DataImage library
|
||||
|
||||
[`lib-dataimage`](https://github.com/tachiyomiorg/tachiyomi-extensions/tree/master/lib/dataimage) is a library for handling [base 64 encoded image data](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) using an [OkHttp interceptor](https://square.github.io/okhttp/interceptors/).
|
||||
[`lib-dataimage`](https://github.com/yuzono/tachiyomi-extensions/tree/master/lib/dataimage) is a library
|
||||
or handling [base 64 encoded image data](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs)
|
||||
using an [OkHttp interceptor](https://square.github.io/okhttp/interceptors/).
|
||||
|
||||
```gradle
|
||||
```groovy
|
||||
dependencies {
|
||||
implementation(project(':lib-dataimage'))
|
||||
}
|
||||
@@ -266,9 +302,9 @@ dependencies {
|
||||
|
||||
#### i18n library
|
||||
|
||||
[`lib-i18n`](https://github.com/tachiyomiorg/tachiyomi-extensions/tree/master/lib/i18n) is a library for handling internationalization in the sources. It allows loading `.properties` files with messages located under the `assets/i18n` folder of each extension, that can be used to translate strings under the source.
|
||||
[`lib-i18n`](https://github.com/yuzono/tachiyomi-extensions/tree/master/lib/i18n) is a library for handling internationalization in the sources. It allows loading `.properties` files with messages located under the `assets/i18n` folder of each extension, that can be used to translate strings under the source.
|
||||
|
||||
```gradle
|
||||
```groovy
|
||||
dependencies {
|
||||
implementation(project(':lib-i18n'))
|
||||
}
|
||||
@@ -276,31 +312,37 @@ dependencies {
|
||||
|
||||
#### Additional dependencies
|
||||
|
||||
If you find yourself needing additional functionality, you can add more dependencies to your `build.gradle` file.
|
||||
Many of [the dependencies](https://github.com/tachiyomiorg/tachiyomi/blob/master/app/build.gradle.kts) from the main Tachiyomi app are exposed to extensions by default.
|
||||
If you find yourself needing additional functionality, you can add more dependencies to your `build.gradle`
|
||||
file. Many of [the dependencies](https://github.com/komikku-app/komikku/blob/master/app/build.gradle.kts)
|
||||
from the main Komikku app are exposed to extensions by default.
|
||||
|
||||
> Note that several dependencies are already exposed to all extensions via Gradle version catalog.
|
||||
> To view which are available view `libs.versions.toml` under the `gradle` folder
|
||||
> [!NOTE]
|
||||
> Several dependencies are already exposed to all extensions via Gradle's version catalog.
|
||||
> To view which are available check the `gradle/libs.versions.toml` file.
|
||||
|
||||
Notice that we're using `compileOnly` instead of `implementation` if the app already contains it. You could use `implementation` instead for a new dependency, or you prefer not to rely on whatever the main app has at the expense of app size.
|
||||
Notice that we're using `compileOnly` instead of `implementation` if the app already contains it.
|
||||
You could use `implementation` instead for a new dependency, or you prefer not to rely on whatever
|
||||
the main app has at the expense of app size.
|
||||
|
||||
Note that using `compileOnly` restricts you to versions that must be compatible with those used in [the latest stable version of Tachiyomi](https://github.com/tachiyomiorg/tachiyomi/releases/latest).
|
||||
> [!IMPORTANT]
|
||||
> Using `compileOnly` restricts you to versions that must be compatible with those used in
|
||||
> [the latest stable version of Komikku](https://github.com/komikku-app/komikku/releases/latest).
|
||||
|
||||
### Extension main class
|
||||
|
||||
The class which is referenced and defined by `extClass` in `build.gradle`. This class should implement either `SourceFactory` or extend one of the `Source` implementations: `HttpSource` or `ParsedHttpSource`.
|
||||
|
||||
| Class | Description |
|
||||
| ----- | ----------- |
|
||||
|`SourceFactory`| Used to expose multiple `Source`s. Use this in case of a source that supports multiple languages or mirrors of the same website. For similar websites use [theme sources](#multi-source-themes). |
|
||||
| `HttpSource`| For online source, where requests are made using HTTP. |
|
||||
| `ParsedHttpSource`| Similar to `HttpSource`, but has methods useful for scraping pages. |
|
||||
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `SourceFactory` | Used to expose multiple `Source`s. Use this in case of a source that supports multiple languages or mirrors of the same website. For similar websites use [theme sources](#multi-source-themes). |
|
||||
| `HttpSource` | For online source, where requests are made using HTTP. |
|
||||
| `ParsedHttpSource` | Similar to `HttpSource`, but has methods useful for scraping pages. |
|
||||
|
||||
#### Main class key variables
|
||||
|
||||
| Field | Description |
|
||||
| ----- | ----------- |
|
||||
| `name` | Name displayed in the "Sources" tab in Tachiyomi. |
|
||||
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `name` | Name displayed in the "Sources" tab in Komikku. |
|
||||
| `baseUrl` | Base URL of the source without any trailing slashes. |
|
||||
| `lang` | An ISO 639-1 compliant language code (two letters in lower case in most cases, but can also include the country/dialect part by using a simple dash character). |
|
||||
| `id` | Identifier of your source, automatically set in `HttpSource`. It should only be manually overriden if you need to copy an existing autogenerated ID. |
|
||||
@@ -311,30 +353,34 @@ The class which is referenced and defined by `extClass` in `build.gradle`. This
|
||||
|
||||
a.k.a. the Browse source entry point in the app (invoked by tapping on the source name).
|
||||
|
||||
- The app calls `fetchPopularManga` which should return a `MangasPage` containing the first batch of found `SManga` entries.
|
||||
- This method supports pagination. When user scrolls the manga list and more results must be fetched, the app calls it again with increasing `page` values (starting with `page=1`). This continues while `MangasPage.hasNextPage` is passed as `true` and `MangasPage.mangas` is not empty.
|
||||
- To show the list properly, the app needs `url`, `title` and `thumbnail_url`. You **must** set them here. The rest of the fields could be filled later (refer to Manga Details below).
|
||||
- You should set `thumbnail_url` if is available, if not, `getMangaDetails` will be **immediately** called (this will increase network calls heavily and should be avoided).
|
||||
- The app calls `fetchPopularManga` which should return a `MangasPage` containing the first batch of
|
||||
found `SManga` entries. - This method supports pagination. When user scrolls the manga list and more results must be fetched,
|
||||
the app calls it again with increasing `page` values (starting with `page=1`). This continues while
|
||||
`MangasPage.hasNextPage` is passed as `true` and `MangasPage.mangas` is not empty.
|
||||
- To show the list properly, the app needs `url`, `title` and `thumbnail_url`. You **must** set them
|
||||
here. The rest of the fields could be filled later (refer to Manga Details below). - You should set `thumbnail_url` if is available, if not, `getMangaDetails` will be **immediately**
|
||||
called (this will increase network calls heavily and should be avoided).
|
||||
|
||||
#### Latest Manga
|
||||
|
||||
a.k.a. the Latest source entry point in the app (invoked by tapping on the "Latest" button beside the source name).
|
||||
a.k.a. the Latest source entry point in the app (invoked by tapping on the "Latest" button beside
|
||||
the source name).
|
||||
|
||||
- Enabled if `supportsLatest` is `true` for a source
|
||||
- Similar to popular manga, but should be fetching the latest entries from a source.
|
||||
|
||||
#### Manga Search
|
||||
|
||||
- When the user searches inside the app, `fetchSearchManga` will be called and the rest of the flow is similar to what happens with `fetchPopularManga`.
|
||||
- If search functionality is not available, return `Observable.just(MangasPage(emptyList(), false))`
|
||||
- When the user searches inside the app, `fetchSearchManga` will be called and the rest of the flow
|
||||
is similar to what happens with `fetchPopularManga`. - If search functionality is not available, return `Observable.just(MangasPage(emptyList(), false))`
|
||||
- `getFilterList` will be called to get all filters and filter types.
|
||||
|
||||
##### Filters
|
||||
|
||||
The search flow have support to filters that can be added to a `FilterList` inside the `getFilterList` method. When the user changes the filters' state, they will be passed to the `searchRequest`, and they can be iterated to create the request (by getting the `filter.state` value, where the type varies depending on the `Filter` used). You can check the filter types available [here](https://github.com/tachiyomiorg/tachiyomi/blob/master/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/model/Filter.kt) and in the table below.
|
||||
The search flow have support to filters that can be added to a `FilterList` inside the `getFilterList` method. When the user changes the filters' state, they will be passed to the `searchRequest`, and they can be iterated to create the request (by getting the `filter.state` value, where the type varies depending on the `Filter` used). You can check the filter types available [here](https://github.com/komikku-app/komikku/blob/master/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/model/Filter.kt) and in the table below.
|
||||
|
||||
| Filter | State type | Description |
|
||||
| ------ | ---------- | ----------- |
|
||||
| ------------------ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `Filter.Header` | None | A simple header. Useful for separating sections in the list or showing any note or warning to the user. |
|
||||
| `Filter.Separator` | None | A line separator. Useful for visual distinction between sections. |
|
||||
| `Filter.Select<V>` | `Int` | A select control, similar to HTML's `<select>`. Only one item can be selected, and the state is the index of the selected one. |
|
||||
@@ -362,7 +408,7 @@ open class UriPartFilter(displayName: String, private val vals: Array<Pair<Strin
|
||||
- `getMangaDetails` is called to update a manga's details from when it was initialized earlier.
|
||||
- `SManga.initialized` tells the app if it should call `getMangaDetails`. If you are overriding `getMangaDetails`, make sure to pass it as `true`.
|
||||
- `SManga.genre` is a string containing list of all genres separated with `", "`.
|
||||
- `SManga.status` is an "enum" value. Refer to [the values in the `SManga` companion object](https://github.com/tachiyomiorg/extensions-lib/blob/master/library/src/main/java/eu/kanade/tachiyomi/source/model/SManga.kt#L24).
|
||||
- `SManga.status` is an "enum" value. Refer to [the values in the `SManga` companion object](https://github.com/komikku-app/extensions-lib/blob/master/library/src/main/java/eu/kanade/tachiyomi/source/model/SManga.kt#L24).
|
||||
- During a backup, only `url` and `title` are stored. To restore the rest of the manga data, the app calls `getMangaDetails`, so all fields should be (re)filled in if possible.
|
||||
- If a `SManga` is cached, `getMangaDetails` will be only called when the user does a manual update (Swipe-to-Refresh).
|
||||
- `getChapterList` is called to display the chapter list.
|
||||
@@ -373,33 +419,43 @@ open class UriPartFilter(displayName: String, private val vals: Array<Pair<Strin
|
||||
|
||||
#### Chapter
|
||||
|
||||
- After a chapter list for the manga is fetched and the app is going to cache the data, `prepareNewChapter` will be called.
|
||||
- `SChapter.date_upload` is the [UNIX Epoch time](https://en.wikipedia.org/wiki/Unix_time) **expressed in milliseconds**.
|
||||
- If you don't pass `SChapter.date_upload` and leave it zero, the app will use the default date instead, but it's recommended to always fill it if it's available.
|
||||
- To get the time in milliseconds from a date string, you can use a `SimpleDateFormat` like in the example below.
|
||||
- After a chapter list for the manga is fetched and the app is going to cache the data,
|
||||
`prepareNewChapter` will be called.
|
||||
- `SChapter.date_upload` is the [UNIX Epoch time](https://en.wikipedia.org/wiki/Unix_time)
|
||||
**expressed in milliseconds**. - If you don't pass `SChapter.date_upload` and leave it zero, the app will use the default date
|
||||
instead, but it's recommended to always fill it if it's available. - To get the time in milliseconds from a date string, you can use a `SimpleDateFormat` like in
|
||||
the example below.
|
||||
|
||||
```kotlin
|
||||
private fun parseDate(dateStr: String): Long {
|
||||
return runCatching { DATE_FORMATTER.parse(dateStr)?.time }
|
||||
.getOrNull() ?: 0L
|
||||
return try {
|
||||
dateFormat.parse(dateStr)!!.time
|
||||
} catch (_: ParseException) {
|
||||
0L
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val DATE_FORMATTER by lazy {
|
||||
private val dateFormat by lazy {
|
||||
SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ENGLISH)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Make sure you make the `SimpleDateFormat` a class constant or variable so it doesn't get recreated for every chapter. If you need to parse or format dates in manga description, create another instance since `SimpleDateFormat` is not thread-safe.
|
||||
- If the parsing have any problem, make sure to return `0L` so the app will use the default date instead.
|
||||
Make sure you make the `SimpleDateFormat` a class constant or variable so it doesn't get
|
||||
recreated for every chapter. If you need to parse or format dates in manga description, create
|
||||
another instance since `SimpleDateFormat` is not thread-safe.
|
||||
- If the parsing have any problem, make sure to return `0L` so the app will use the default date
|
||||
instead.
|
||||
- The app will overwrite dates of existing old chapters **UNLESS** `0L` is returned.
|
||||
- The default date has [changed](https://github.com/tachiyomiorg/tachiyomi/pull/7197) in preview ≥ r4442 or stable > 0.13.4.
|
||||
- The default date has [changed](https://github.com/tachiyomiorg/tachiyomi/pull/7197) in
|
||||
preview ≥ r4442 or stable > 0.13.4.
|
||||
- In older versions, the default date is always the fetch date.
|
||||
- In newer versions, this is the same if every (new) chapter has `0L` returned.
|
||||
- However, if the source only provides the upload date of the latest chapter, you can now set it to the latest chapter and leave other chapters default. The app will automatically set it (instead of fetch date) to every new chapter and leave old chapters' dates untouched.
|
||||
- However, if the source only provides the upload date of the latest chapter, you can now set
|
||||
it to the latest chapter and leave other chapters default. The app will automatically set it (instead of fetch date) to every new chapter and leave old chapters' dates untouched.
|
||||
|
||||
- `getChapterUrl` is called when the user taps "Open in WebView" in the reader.
|
||||
- If the source uses an API to fetch the data, consider overriding this method to return the chapter absolute URL in the website instead.
|
||||
- If the source uses an API to fetch the data, consider overriding this method to return the
|
||||
chapter absolute URL in the website instead.
|
||||
- It defaults to the URL provided to the request in `pageListRequest`.
|
||||
|
||||
#### Chapter Pages
|
||||
@@ -413,30 +469,48 @@ open class UriPartFilter(displayName: String, private val vals: Array<Pair<Strin
|
||||
|
||||
### Misc notes
|
||||
|
||||
- Sometimes you may find no use for some inherited methods. If so just override them and throw exceptions: `throw UnsupportedOperationException("Not used.")`
|
||||
- You probably will find `getUrlWithoutDomain` useful when parsing the target source URLs. Keep in mind there's a current issue with spaces in the URL though, so if you use it, replace all spaces with URL encoded characters (like `%20`).
|
||||
- If possible try to stick to the general workflow from `HttpSource`/`ParsedHttpSource`; breaking them may cause you more headache than necessary.
|
||||
- By implementing `ConfigurableSource` you can add settings to your source, which is backed by [`SharedPreferences`](https://developer.android.com/reference/android/content/SharedPreferences).
|
||||
- Sometimes you may find no use for some inherited methods. If so just override them and throw
|
||||
exceptions: `throw UnsupportedOperationException()`
|
||||
- You probably will find `getUrlWithoutDomain` useful when parsing the target source URLs. Keep in
|
||||
mind there's a current issue with spaces in the URL though, so if you use it, replace all spaces with
|
||||
URL encoded characters (like `%20`).
|
||||
- If possible try to stick to the general workflow from `HttpSource`/`ParsedHttpSource`; breaking
|
||||
them may cause you more headache than necessary.
|
||||
- By implementing `ConfigurableSource` you can add settings to your source, which is backed by
|
||||
[`SharedPreferences`](https://developer.android.com/reference/android/content/SharedPreferences).
|
||||
|
||||
### Advanced Extension features
|
||||
|
||||
#### URL intent filter
|
||||
|
||||
Extensions can define URL intent filters by defining it inside a custom `AndroidManifest.xml` file.
|
||||
For an example, refer to [the NHentai module's `AndroidManifest.xml` file](https://github.com/tachiyomiorg/tachiyomi-extensions/blob/master/src/all/nhentai/AndroidManifest.xml) and [its corresponding `NHUrlActivity` handler](https://github.com/tachiyomiorg/tachiyomi-extensions/blob/master/src/all/nhentai/src/eu/kanade/tachiyomi/extension/all/nhentai/NHUrlActivity.kt).
|
||||
For an example, refer to [the NHentai module's `AndroidManifest.xml` file](https://github.com/yuzono/tachiyomi-extensions/blob/master/src/all/nhentai/AndroidManifest.xml) and [its corresponding `NHUrlActivity` handler](https://github.com/yuzono/tachiyomi-extensions/blob/master/src/all/nhentai/src/eu/kanade/tachiyomi/extension/all/nhentai/NHUrlActivity.kt).
|
||||
|
||||
To test if the URL intent filter is working as expected, you can try opening the website in a browser and navigating to the endpoint that was added as a filter or clicking a hyperlink. Alternatively, you can use the `adb` command below.
|
||||
To test if the URL intent filter is working as expected, you can try opening the website in a browser
|
||||
and navigating to the endpoint that was added as a filter or clicking a hyperlink. Alternatively,
|
||||
you can use the `adb` command below.
|
||||
|
||||
```console
|
||||
$ adb shell am start -d "<your-link>" -a android.intent.action.VIEW
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
> The activity does not support any Kotlin Intrinsics specific methods or calls,
|
||||
> and using them will causes crashes in the activity. Consider using Java's equivalent
|
||||
> methods instead, such as using `String`'s `equals()` instead of using `==`.
|
||||
>
|
||||
> You can use Kotlin Intrinsics in the extension source class, this limitation only
|
||||
> applies to the activity classes.
|
||||
|
||||
#### Update strategy
|
||||
|
||||
There is some cases where titles in a source will always only have the same chapter list (i.e. immutable), and don't need to be included in a global update of the app because of that, saving a lot of requests and preventing causing unnecessary damage to the source servers. To change the update strategy of a `SManga`, use the `update_strategy` field. You can find below a description of the current possible values.
|
||||
|
||||
- `UpdateStrategy.ALWAYS_UPDATE`: Titles marked as always update will be included in the library update if they aren't excluded by additional restrictions.
|
||||
- `UpdateStrategy.ONLY_FETCH_ONCE`: Titles marked as only fetch once will be automatically skipped during library updates. Useful for cases where the series is previously known to be finished and have only a single chapter, for example.
|
||||
- `UpdateStrategy.ALWAYS_UPDATE`: Titles marked as always update will be included in the library
|
||||
update if they aren't excluded by additional restrictions.
|
||||
- `UpdateStrategy.ONLY_FETCH_ONCE`: Titles marked as only fetch once will be automatically skipped
|
||||
during library updates. Useful for cases where the series is previously known to be finished and have
|
||||
only a single chapter, for example.
|
||||
|
||||
If not set, it defaults to `ALWAYS_UPDATE`.
|
||||
|
||||
@@ -444,7 +518,7 @@ If not set, it defaults to `ALWAYS_UPDATE`.
|
||||
|
||||
There is some cases where existing sources changes their name on the website. To correctly reflect these changes in the extension, you need to explicity set the `id` to the same old value, otherwise it will get changed by the new `name` value and users will be forced to migrate back to the source.
|
||||
|
||||
To get the current `id` value before the name change, you can search the source name in the [repository JSON file](https://github.com/tachiyomiorg/tachiyomi-extensions/blob/repo/index.json) by looking into the `sources` attribute of the extension. When you have the `id` copied, you can override it in the source:
|
||||
To get the current `id` value before the name change, you can search the source name in the [repository JSON file](https://github.com/yuzono/tachiyomi-extensions/blob/repo/index.json) by looking into the `sources` attribute of the extension. When you have the `id` copied, you can override it in the source:
|
||||
|
||||
```kotlin
|
||||
override val id: Long = <the-id>
|
||||
@@ -452,16 +526,25 @@ override val id: Long = <the-id>
|
||||
|
||||
Then the class name and the `name` attribute value can be changed. Also don't forget to update the extension name and class name in the individual Gradle file if it is not a multisrc extension.
|
||||
|
||||
**Important:** the package name **needs** to be the same (even if it has the old name), otherwise users will not receive the extension update when it gets published in the repository. If you're changing the name of a multisrc source, you can manually set it in the generator class of the theme by using `pkgName = "oldpackagename"`.
|
||||
> [!IMPORTANT]
|
||||
> The package name **needs** to be the same (even if it has the old name), otherwise users will not
|
||||
> receive the extension update when it gets published in the repository.
|
||||
|
||||
The `id` also needs to be explicity set to the old value if you're changing the `lang` attribute.
|
||||
|
||||
> [!NOTE]
|
||||
> If the source has also changed their theme you can instead just change
|
||||
> the `name` field in the source class and in the Gradle file. By doing so
|
||||
> a new `id` will be generated and users will be forced to migrate.
|
||||
|
||||
## Multi-source themes
|
||||
|
||||
The `multisrc` module houses source code for generating extensions for cases where multiple source sites use the same site generator tool(usually a CMS) for bootsraping their website and this makes them similar enough to prompt code reuse through inheritance/composition; which from now on we will use the general **theme** term to refer to.
|
||||
|
||||
This module contains the *default implementation* for each theme and definitions for each source that builds upon that default implementation and also it's overrides upon that default implementation, all of this becomes a set of source code which then is used to generate individual extensions from.
|
||||
This module contains the _default implementation_ for each theme and definitions for each source that builds upon that default implementation and also it's overrides upon that default implementation, all of this becomes a set of source code which then is used to generate individual extensions from.
|
||||
|
||||
### The directory structure
|
||||
|
||||
```console
|
||||
$ tree multisrc
|
||||
multisrc
|
||||
@@ -479,9 +562,8 @@ multisrc
|
||||
│ │ │ └── ic_launcher.png
|
||||
│ │ ├── mipmap-xxhdpi
|
||||
│ │ │ └── ic_launcher.png
|
||||
│ │ ├── mipmap-xxxhdpi
|
||||
│ │ │ └── ic_launcher.png
|
||||
│ │ └── web_hi_res_512.png
|
||||
│ │ └── mipmap-xxxhdpi
|
||||
│ │ └── ic_launcher.png
|
||||
│ └── <sourcepkg>
|
||||
│ ├── additional.gradle
|
||||
│ ├── AndroidManifest.xml
|
||||
@@ -494,9 +576,8 @@ multisrc
|
||||
│ │ │ └── ic_launcher.png
|
||||
│ │ ├── mipmap-xxhdpi
|
||||
│ │ │ └── ic_launcher.png
|
||||
│ │ ├── mipmap-xxxhdpi
|
||||
│ │ │ └── ic_launcher.png
|
||||
│ │ └── web_hi_res_512.png
|
||||
│ │ └── mipmap-xxxhdpi
|
||||
│ │ └── ic_launcher.png
|
||||
│ └── src
|
||||
│ └── <SourceName>.kt
|
||||
└── src
|
||||
@@ -526,12 +607,12 @@ multisrc
|
||||
- `multisrc/overrides/<themepkg>/<sourcepkg>/additional.gradle` defines additional gradle code, this will be copied at the end of the generated gradle file below the theme's `additional.gradle`.
|
||||
- `multisrc/overrides/<themepkg>/<sourcepkg>/AndroidManifest.xml` is copied as an override to the default `AndroidManifest.xml` generation if it exists.
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> [!NOTE]
|
||||
> Files ending with `Gen.kt` (i.e. `multisrc/src/main/java/eu/kanade/tachiyomi/multisrc/<theme>/XxxGen.kt`)
|
||||
> are considered helper files and won't be copied to generated sources.
|
||||
|
||||
### Development workflow
|
||||
|
||||
There are three steps in running and testing a theme source:
|
||||
|
||||
1. Generate the sources
|
||||
@@ -548,7 +629,9 @@ There are three steps in running and testing a theme source:
|
||||
- It's recommended to make changes here to skip going through step 1 and 2 multiple times, and when you are done, copying the changes back to `multisrc`.
|
||||
|
||||
### Scaffolding overrides
|
||||
|
||||
You can use this python script to generate scaffolds for source overrides. Put it inside `multisrc/overrides/<themepkg>/` as `scaffold.py`.
|
||||
|
||||
```python
|
||||
import os, sys
|
||||
from pathlib import Path
|
||||
@@ -575,6 +658,7 @@ with open(f"{package}/src/{source}.kt", "w") as f:
|
||||
```
|
||||
|
||||
### Additional Notes
|
||||
|
||||
- Generated sources extension version code is calculated as `baseVersionCode + overrideVersionCode + multisrcLibraryVersion`.
|
||||
- Currently `multisrcLibraryVersion` is `0`
|
||||
- When a new source is added, it doesn't need to set `overrideVersionCode` as it's default is `0`.
|
||||
@@ -587,53 +671,67 @@ with open(f"{package}/src/{source}.kt", "w") as f:
|
||||
|
||||
## Running
|
||||
|
||||
To make local development more convenient, you can use the following run configuration to launch Tachiyomi directly at the Browse panel:
|
||||
To make local development more convenient, you can use the following run configuration to launch
|
||||
Komikku directly at the Browse panel:
|
||||
|
||||

|
||||
|
||||
If you're running a Preview or debug build of Tachiyomi:
|
||||
If you're running a Preview or debug build of Komikku:
|
||||
|
||||
```
|
||||
-W -S -n eu.kanade.tachiyomi.debug/eu.kanade.tachiyomi.ui.main.MainActivity -a eu.kanade.tachiyomi.SHOW_CATALOGUES
|
||||
-W -S -n app.komikku.dev/eu.kanade.tachiyomi.ui.main.MainActivity -a eu.kanade.tachiyomi.SHOW_CATALOGUES
|
||||
```
|
||||
|
||||
And for a release build of Tachiyomi:
|
||||
And for a release build of Komikku:
|
||||
|
||||
```
|
||||
-W -S -n eu.kanade.tachiyomi/eu.kanade.tachiyomi.ui.main.MainActivity -a eu.kanade.tachiyomi.SHOW_CATALOGUES
|
||||
-W -S -n app.komikku/eu.kanade.tachiyomi.ui.main.MainActivity -a eu.kanade.tachiyomi.SHOW_CATALOGUES
|
||||
```
|
||||
|
||||
If you're deploying to Android 11 or higher, enable the "Always install with package manager" option in the run configurations.
|
||||
> [!IMPORTANT]
|
||||
> If you're deploying to Android 11 or higher, enable the "Always install with package manager" option in the run configurations. Without this option enabled, you might face issues such as Android Studio running an older version of the extension without the modifications you might have done.
|
||||
|
||||
## Debugging
|
||||
|
||||
### Android Debugger
|
||||
|
||||
> [!IMPORTANT]
|
||||
> If you didn't build the main app from source with debug enabled and are using a release/beta APK, you **need** a rooted device.
|
||||
> If you are using an emulator instead, make sure you choose a profile **without** Google Play.
|
||||
|
||||
You can leverage the Android Debugger to step through your extension while debugging.
|
||||
|
||||
You *cannot* simply use Android Studio's `Debug 'module.name'` -> this will most likely result in an error while launching.
|
||||
You _cannot_ simply use Android Studio's `Debug 'module.name'` -> this will most likely result in an error while launching.
|
||||
|
||||
Instead, once you've built and installed your extension on the target device, use `Attach Debugger to Android Process` to start debugging Tachiyomi.
|
||||
Instead, once you've built and installed your extension on the target device, use
|
||||
`Attach Debugger to Android Process` to start debugging Komikku.
|
||||
|
||||

|
||||
|
||||
|
||||
### Logs
|
||||
|
||||
You can also elect to simply rely on logs printed from your extension, which
|
||||
show up in the [`Logcat`](https://developer.android.com/studio/debug/am-logcat) panel of Android Studio.
|
||||
|
||||
### Inspecting network calls
|
||||
|
||||
One of the easiest way to inspect network issues (such as HTTP errors 404, 429, no chapter found etc.) is to use the [`Logcat`](https://developer.android.com/studio/debug/am-logcat) panel of Android Studio and filtering by the `OkHttpClient` tag.
|
||||
|
||||
To be able to check the calls done by OkHttp, you need to enable verbose logging in the app, that is not enabled by default and is only included in the Preview versions of Tachiyomi. To enable it, go to More -> Settings -> Advanced -> Verbose logging. After enabling it, don't forget to restart the app.
|
||||
To be able to check the calls done by OkHttp, you need to enable verbose logging in the app, that is not enabled by default and is only included in the Preview versions of Komikku. To enable it, go to More -> Settings -> Advanced -> Verbose logging. After enabling it, don't forget to restart the app.
|
||||
|
||||
Inspecting the Logcat allows you to get a good look at the call flow and it's more than enough in most cases where issues occurs. However, alternatively, you can also use an external tool like `mitm-proxy`. For that, refer to the next section.
|
||||
Inspecting the Logcat allows you to get a good look at the call flow and it's more than enough in most cases where issues occurs. However, alternatively, you can also use an external tool like `mitm-proxy`. For that, refer to the subsequent sections.
|
||||
|
||||
On newer Android Studio versions, you can use its built-in Network Inspector inside the
|
||||
App Inspection tool window. This feature provides a nice GUI to inspect the requests made in the app.
|
||||
|
||||
To use it, follow the [official documentation](https://developer.android.com/studio/debug/network-profiler) and select Komikku package name in the process list.
|
||||
|
||||
### Using external network inspecting tools
|
||||
|
||||
If you want to take a deeper look into the network flow, such as taking a look into the request and response bodies, you can use an external tool like `mitm-proxy`.
|
||||
|
||||
#### Setup your proxy server
|
||||
|
||||
We are going to use [mitm-proxy](https://mitmproxy.org/) but you can replace it with any other Web Debugger (i.e. Charles, Burp Suite, Fiddler etc). To install and execute, follow the commands bellow.
|
||||
|
||||
```console
|
||||
@@ -655,8 +753,8 @@ $ docker run --rm -it -p 8080:8080 \
|
||||
After installing and running, open your browser and navigate to http://127.0.0.1:8081.
|
||||
|
||||
#### OkHttp proxy setup
|
||||
Since most of the manga sources are going to use HTTPS, we need to disable SSL verification in order to use the web debugger. For that, add this code to inside your source class:
|
||||
|
||||
Since most of the manga sources are going to use HTTPS, we need to disable SSL verification in order to use the web debugger. For that, add this code to inside your source class:
|
||||
|
||||
```kotlin
|
||||
package eu.kanade.tachiyomi.extension.en.mangasource
|
||||
@@ -702,23 +800,38 @@ class MangaSource : MangaTheme(
|
||||
}
|
||||
```
|
||||
|
||||
Note: `10.0.2.2` is usually the address of your loopback interface in the android emulator. If Tachiyomi tells you that it's unable to connect to 10.0.2.2:8080 you will likely need to change it (the same if you are using hardware device).
|
||||
Note: `10.0.2.2` is usually the address of your loopback interface in the android emulator. If Komikku tells you that it's unable to connect to 10.0.2.2:8080 you will likely need to change it (the same if you are using hardware device).
|
||||
|
||||
If all went well, you should see all requests and responses made by the source in the web interface of `mitmweb`.
|
||||
|
||||
## Building
|
||||
|
||||
APKs can be created in Android Studio via `Build > Build Bundle(s) / APK(s) > Build APK(s)` or `Build > Generate Signed Bundle / APK`.
|
||||
APKs can be created in Android Studio via `Build > Build Bundle(s) / APK(s) > Build APK(s)` or
|
||||
`Build > Generate Signed Bundle / APK`.
|
||||
|
||||
If for some reason you decide to build the APK from the command line, you can use the following
|
||||
command (because you're doing things differently than expected, I assume you have some
|
||||
knowledge of gradlew and your OS):
|
||||
|
||||
```console
|
||||
// For a single apk, use this command
|
||||
$ ./gradlew src:<lang>:<source>:assembleDebug
|
||||
```
|
||||
|
||||
## Submitting the changes
|
||||
|
||||
When you feel confident about your changes, submit a new Pull Request so your code can be reviewed and merged if it's approved. We encourage following a [GitHub Standard Fork & Pull Request Workflow](https://gist.github.com/Chaser324/ce0505fbed06b947d962) and following the good practices of the workflow, such as not commiting directly to `master`: always create a new branch for your changes.
|
||||
|
||||
If you are more comfortable about using Git GUI-based tools, you can refer to [this guide](https://learntodroid.com/how-to-use-git-and-github-in-android-studio/) about the Git integration inside Android Studio, specifically the "How to Contribute to an to Existing Git Repository in Android Studio" section of the guide.
|
||||
If you are more comfortable about using Git GUI-based tools, you can refer to [this guide](https://learntodroid.com/how-to-use-git-and-github-in-android-studio/)
|
||||
about the Git integration inside Android Studio, specifically the "How to Contribute to an to Existing
|
||||
Git Repository in Android Studio" section of the guide.
|
||||
|
||||
Make sure you have generated the extension icon using the linked Icon Generator tool in the [Tools](#tools) section. The icon must follow the pattern adopted by all other extensions: a square with rounded corners.
|
||||
> [!IMPORTANT]
|
||||
> Make sure you have generated the extension icon using the linked Icon Generator tool in the [Tools](#tools)
|
||||
> section. The icon **must follow the pattern** adopted by all other extensions: a square with rounded
|
||||
> corners. Make sure to remove the generated `web_hi_res_512.png`.
|
||||
|
||||
Please **do test your changes by compiling it through Android Studio** before submitting it. Also make sure to follow the PR checklist available in the PR body field when creating a new PR. As a reference, you can find it below.
|
||||
Please **do test your changes by compiling it through Android Studio** before submitting it. Obvious untested PRs will not be merged, such as ones created with the GitHub web interface. Also make sure to follow the PR checklist available in the PR body field when creating a new PR. As a reference, you can find it below.
|
||||
|
||||
### Pull Request checklist
|
||||
|
||||
@@ -728,3 +841,4 @@ Please **do test your changes by compiling it through Android Studio** before su
|
||||
- Add the `isNsfw = true` flag in `build.gradle` when appropriate
|
||||
- Explicitly kept the `id` if a source's name or language were changed
|
||||
- Test the modifications by compiling and running the extension through Android Studio
|
||||
- Have removed `web_hi_res_512.png` when adding a new extension
|
||||
|
||||
43
LICENSE
@@ -2,9 +2,9 @@
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
@@ -63,14 +63,14 @@
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
@@ -86,7 +86,7 @@
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
@@ -127,7 +127,7 @@
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
@@ -135,12 +135,12 @@
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
@@ -150,7 +150,7 @@
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
@@ -162,7 +162,7 @@
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
@@ -173,9 +173,9 @@
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
@@ -186,17 +186,16 @@
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
60
README.md
@@ -1,29 +1,40 @@
|
||||
| Build | Support Server |
|
||||
|-------|---------|
|
||||
| [](https://github.com/tachiyomiorg/tachiyomi-extensions/actions/workflows/build_push.yml) | [](https://discord.gg/tachiyomi) |
|
||||
| Build | Up to date | Install to app |
|
||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| [](https://github.com/Kareadita/tach-extensions/actions/workflows/build_push.yml) | [](https://github.com/Kareadita/tachiyomi-extensions/actions/workflows/auto_cherry_pick.yml) | [](https://intradeus.github.io/http-protocol-redirector/?r=tachiyomi://add-repo?url=https://raw.githubusercontent.com/Kareadita/tach-extensions/repo/index.min.json) |
|
||||
|
||||
# Tachiyomi Extensions
|
||||
Tachiyomi is a free and open source manga reader for Android 6.0 and above.
|
||||
# Kavita Extension
|
||||
|
||||
This repository contains the available extension catalogues for the [Tachiyomi](https://github.com/tachiyomiorg/tachiyomi) app.
|
||||
This repository contains the Kavita extension which is compatible with [Komikku](https://github.com/komikku-app/komikku) and Mihon / Tachiyomi or other forks.
|
||||
|
||||
# Usage
|
||||
## Recommend App
|
||||
|
||||
Extension sources can be downloaded, installed, and uninstalled via the main Tachiyomi app. They are installed and uninstalled like regular apps, in `.apk` format.
|
||||
### [Mihon](https://github.com/mihonapp/mihon)
|
||||
|
||||
## Downloads
|
||||
### [Komikku](https://github.com/komikku-app/komikku)
|
||||
|
||||
If you prefer to directly download the APK files, they are available via https://tachiyomi.org/extensions/ or directly in this GitHub repository in the [`repo` branch](https://github.com/tachiyomiorg/tachiyomi-extensions/tree/repo/apk).
|
||||
## How to add the repo
|
||||
|
||||
[](https://intradeus.github.io/http-protocol-redirector/?r=tachiyomi://add-repo?url=https://raw.githubusercontent.com/Kareadita/tach-extensions/repo/index.min.json)
|
||||
Otherwise, copy & paste the following URL:
|
||||
|
||||
```html
|
||||
https://raw.githubusercontent.com/Kareadita/tach-extensions/repo/index.min.json
|
||||
```
|
||||
|
||||
# Requests
|
||||
|
||||
Source requests here are meant as up-for-grabs for any developer, thus it's impossible to provide a time estimation for any of them. Furthermore, some sites are impossible to do, usually because of various technical reasons.
|
||||
To request a new feature or bug fix, [create an issue](https://github.com/Kareadita/tach-extensions/issues/new/choose).
|
||||
|
||||
Please note that creating an issue does not mean that the feature will be added or fixed in a timely fashion, because the work is volunteer-based. Some features may also be impossible to do or prohibitively difficult to maintain.
|
||||
|
||||
If you would like to see a request fulfilled and have the necessary skills to do so, consider contributing!
|
||||
Issues are up-for-grabs for any developer if there is no assigned user already.
|
||||
|
||||
# Contributing
|
||||
|
||||
Contributions are welcome!
|
||||
|
||||
Check out the repo's [issue backlog](https://github.com/tachiyomiorg/tachiyomi-extensions/issues) for source requests and bug reports.
|
||||
Check out the repo's [issue backlog](https://github.com/Kareadita/tach-extensions/issues) for feature requests and bug reports.
|
||||
|
||||
To get started with development, see [CONTRIBUTING.md](./CONTRIBUTING.md).
|
||||
|
||||
@@ -31,20 +42,25 @@ It might also be good to read our [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md).
|
||||
|
||||
## License
|
||||
|
||||
Copyright 2015 Javier Tomás
|
||||
Copyright 2015 Javier Tomás
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
## Disclaimer
|
||||
|
||||
This project does not have any affiliation with the content providers available.
|
||||
|
||||
This project is not affiliated with Komikku/Mihon/Tachiyomi. Don't ask for help about these extensions at the
|
||||
official support means of Komikku/Mihon/Tachiyomi. All credits to the codebase goes to the original contributors.
|
||||
|
||||
The developer of this application does not have any affiliation with the content providers available.
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
**There is no timetable on when or if a source request may be filled (also applies to bug reports and enhancement requests).**
|
||||
|
||||
### In General the following sources that won't be added as an extension
|
||||
- In general heavily paywalled sites
|
||||
- Sources that require cracking some app's source code (realistically, no one's going to put in the effort to do it)
|
||||
- Sources that are known for filling a lot of DMCA complaints over repositories on GitHub
|
||||
|
||||
Here is a list of known sources that were removed.
|
||||
## Removed sources
|
||||
|
||||
### Too difficult to maintain
|
||||
|
||||
- Anchira https://github.com/tachiyomiorg/tachiyomi-extensions/pull/19149
|
||||
- Bakai https://github.com/tachiyomiorg/tachiyomi-extensions/pull/17890
|
||||
- Blackout Comics and Izakaya https://github.com/tachiyomiorg/tachiyomi-extensions/pull/18500
|
||||
- ColaManhua (COLA漫画) https://github.com/tachiyomiorg/tachiyomi-extensions/pull/11445
|
||||
- Comikey https://github.com/tachiyomiorg/tachiyomi-extensions/pull/11971
|
||||
- Constellar Scans https://github.com/tachiyomiorg/tachiyomi-extensions/pull/17277
|
||||
- CopyManga (拷贝漫画) https://github.com/tachiyomiorg/tachiyomi-extensions/pull/12376
|
||||
- Cứu Truyện https://github.com/tachiyomiorg/tachiyomi-extensions/pull/16654
|
||||
- Hentai Kai https://github.com/tachiyomiorg/tachiyomi-extensions/issues/9999
|
||||
- Hitomi.la https://github.com/tachiyomiorg/tachiyomi-extensions/pull/11613
|
||||
- HQ Dragon https://github.com/tachiyomiorg/tachiyomi-extensions/pull/7065
|
||||
- Japscan https://github.com/tachiyomiorg/tachiyomi-extensions/pull/17892
|
||||
- Koushoku https://github.com/tachiyomiorg/tachiyomi-extensions/pull/13329
|
||||
- LeerCapitulo https://github.com/tachiyomiorg/tachiyomi-extensions/pull/16255
|
||||
- Mangá Host https://github.com/tachiyomiorg/tachiyomi-extensions/pull/7065
|
||||
- Mangá Livre and Leitor.net https://github.com/tachiyomiorg/tachiyomi-extensions/pull/8679
|
||||
- MangaDig https://github.com/tachiyomiorg/tachiyomi-extensions/pull/14974
|
||||
- Mangas.pw (Mangas.in) https://github.com/tachiyomiorg/tachiyomi-extensions/pull/9489
|
||||
- MangaYabu! https://github.com/tachiyomiorg/tachiyomi-extensions/pull/9336
|
||||
- ManhuaScan https://github.com/tachiyomiorg/tachiyomi-extensions/pull/7129
|
||||
- ManhwaHot https://github.com/tachiyomiorg/tachiyomi-extensions/pull/7129
|
||||
- Mode Scanlator https://github.com/tachiyomiorg/tachiyomi-extensions/pull/17865
|
||||
- Neox Scanlator https://github.com/tachiyomiorg/tachiyomi-extensions/pull/12695
|
||||
- Reaper Scans (EN) https://github.com/tachiyomiorg/tachiyomi-extensions/pull/16819
|
||||
- SuperMangás and SuperHentais https://github.com/tachiyomiorg/tachiyomi-extensions/pull/6348
|
||||
- TopToon+/Day Comics https://github.com/tachiyomiorg/tachiyomi-extensions/pull/10851
|
||||
- Tsuki Mangás https://github.com/tachiyomiorg/tachiyomi-extensions/pull/8609
|
||||
- Union Mangás https://github.com/tachiyomiorg/tachiyomi-extensions/pull/7065
|
||||
- YES Mangás https://github.com/tachiyomiorg/tachiyomi-extensions/pull/7065
|
||||
|
||||
### Requested removal by the scanlator team
|
||||
|
||||
- ARES Manga https://github.com/tachiyomiorg/tachiyomi-extensions/issues/15396
|
||||
- Astra Scans https://github.com/tachiyomiorg/tachiyomi-extensions/issues/13845
|
||||
- Dat-Gar Scan https://github.com/tachiyomiorg/tachiyomi-extensions/issues/18441
|
||||
- Gourmet Scans https://github.com/tachiyomiorg/tachiyomi-extensions/issues/6192
|
||||
- Hikari Scans https://github.com/tachiyomiorg/tachiyomi-extensions/issues/6611
|
||||
- Hunter Scans https://github.com/tachiyomiorg/tachiyomi-extensions/issues/12392
|
||||
- JuinJutsuReader https://github.com/tachiyomiorg/tachiyomi-extensions/issues/2958
|
||||
- Knightnoscanlation https://github.com/tachiyomiorg/tachiyomi-extensions/issues/4240
|
||||
- KomikTap/KomikTap.in https://github.com/tachiyomiorg/tachiyomi-extensions/issues/6133
|
||||
- Luminous Scans https://github.com/tachiyomiorg/tachiyomi-extensions/issues/9923
|
||||
- MangaPro https://github.com/tachiyomiorg/tachiyomi-extensions/issues/13989
|
||||
- MangaSY https://github.com/tachiyomiorg/tachiyomi-extensions/issues/12007
|
||||
- Mangawow https://github.com/tachiyomiorg/tachiyomi-extensions/issues/5367
|
||||
- MHScans https://github.com/tachiyomiorg/tachiyomi-extensions/issues/15319
|
||||
- Mono Manga https://github.com/tachiyomiorg/tachiyomi-extensions/issues/17634
|
||||
- Moon Daisy Scans https://github.com/tachiyomiorg/tachiyomi-extensions/issues/17929
|
||||
- NarTag https://github.com/tachiyomiorg/tachiyomi-extensions/issues/8038
|
||||
- Plot-twistnf-scans https://github.com/tachiyomiorg/tachiyomi-extensions/issues/4242
|
||||
- Realm Scans https://github.com/tachiyomiorg/tachiyomi-extensions/issues/15586
|
||||
- Remangas https://github.com/tachiyomiorg/tachiyomi-extensions/issues/18807
|
||||
- Reset Scans https://github.com/tachiyomiorg/tachiyomi-extensions/issues/13168
|
||||
- SetsuScans https://github.com/tachiyomiorg/tachiyomi-extensions/issues/11040
|
||||
- ShinobiScans https://github.com/tachiyomiorg/tachiyomi-extensions/issues/14457
|
||||
- XXX Yaoi https://github.com/tachiyomiorg/tachiyomi-extensions/issues/9535
|
||||
@@ -1,17 +1,3 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
google()
|
||||
maven(url = "https://plugins.gradle.org/m2/")
|
||||
}
|
||||
dependencies {
|
||||
classpath(libs.gradle.agp)
|
||||
classpath(libs.gradle.kotlin)
|
||||
classpath(libs.gradle.serialization)
|
||||
classpath(libs.gradle.kotlinter)
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -19,7 +5,3 @@ allprojects {
|
||||
maven(url = "https://jitpack.io")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register<Delete>("clean") {
|
||||
delete(rootProject.layout.buildDirectory.asFile.get())
|
||||
}
|
||||
|
||||
@@ -3,5 +3,14 @@ plugins {
|
||||
}
|
||||
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
mavenCentral()
|
||||
google()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.gradle.agp)
|
||||
implementation(libs.gradle.kotlin)
|
||||
implementation(libs.gradle.serialization)
|
||||
implementation(libs.gradle.kotlinter)
|
||||
}
|
||||
|
||||
7
buildSrc/settings.gradle.kts
Normal file
@@ -0,0 +1,7 @@
|
||||
dependencyResolutionManagement {
|
||||
versionCatalogs {
|
||||
create("libs") {
|
||||
from(files("../gradle/libs.versions.toml"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
object AndroidConfig {
|
||||
const val compileSdk = 34
|
||||
const val minSdk = 21
|
||||
@Suppress("UNUSED")
|
||||
const val targetSdk = 34
|
||||
}
|
||||
|
||||
47
buildSrc/src/main/kotlin/Extensions.kt
Normal file
@@ -0,0 +1,47 @@
|
||||
import groovy.lang.MissingPropertyException
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.ProjectDependency
|
||||
import org.gradle.api.plugins.ExtensionAware
|
||||
import org.gradle.kotlin.dsl.extra
|
||||
|
||||
var ExtensionAware.baseVersionCode: Int
|
||||
get() = (extra.get("baseVersionCode") as Int) + kmkBaseVersionCode
|
||||
set(value) = extra.set("baseVersionCode", value)
|
||||
|
||||
fun Project.getDependents(): Set<Project> {
|
||||
val dependentProjects = mutableSetOf<Project>()
|
||||
|
||||
rootProject.allprojects.forEach { project ->
|
||||
project.configurations.forEach { configuration ->
|
||||
configuration.dependencies.forEach { dependency ->
|
||||
if (dependency is ProjectDependency && dependency.path == path) {
|
||||
dependentProjects.add(project)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dependentProjects
|
||||
}
|
||||
|
||||
fun Project.printDependentExtensions() {
|
||||
getDependents().forEach { project ->
|
||||
if (project.path.startsWith(":src:")) {
|
||||
println(project.path)
|
||||
} else if (project.path.startsWith(":lib-multisrc:")) {
|
||||
project.getDependents().forEach { println(it.path) }
|
||||
} else if (project.path.startsWith(":lib:")) {
|
||||
project.printDependentExtensions()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var ExtensionAware.kmkBaseVersionCode: Int
|
||||
get() {
|
||||
return try {
|
||||
extra.get("kmkBaseVersionCode") as Int
|
||||
} catch (e: MissingPropertyException) {
|
||||
0
|
||||
}
|
||||
}
|
||||
set(value) = extra.set("kmkBaseVersionCode", value)
|
||||
29
buildSrc/src/main/kotlin/lib-android.gradle.kts
Normal file
@@ -0,0 +1,29 @@
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
kotlin("android")
|
||||
id("kotlinx-serialization")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = AndroidConfig.compileSdk
|
||||
|
||||
defaultConfig {
|
||||
minSdk = AndroidConfig.minSdk
|
||||
}
|
||||
|
||||
namespace = "eu.kanade.tachiyomi.lib.${project.name}"
|
||||
|
||||
buildFeatures {
|
||||
androidResources = false
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(versionCatalogs.named("libs").findBundle("common").get())
|
||||
}
|
||||
|
||||
tasks.register("printDependentExtensions") {
|
||||
doLast {
|
||||
project.printDependentExtensions()
|
||||
}
|
||||
}
|
||||
60
buildSrc/src/main/kotlin/lib-multisrc.gradle.kts
Normal file
@@ -0,0 +1,60 @@
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
kotlin("android")
|
||||
id("kotlinx-serialization")
|
||||
id("org.jmailen.kotlinter")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = AndroidConfig.compileSdk
|
||||
|
||||
defaultConfig {
|
||||
minSdk = AndroidConfig.minSdk
|
||||
}
|
||||
|
||||
namespace = "eu.kanade.tachiyomi.multisrc.${project.name}"
|
||||
|
||||
sourceSets {
|
||||
named("main") {
|
||||
manifest.srcFile("AndroidManifest.xml")
|
||||
java.setSrcDirs(listOf("src"))
|
||||
res.setSrcDirs(listOf("res"))
|
||||
assets.setSrcDirs(listOf("assets"))
|
||||
}
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
freeCompilerArgs += "-opt-in=kotlinx.serialization.ExperimentalSerializationApi"
|
||||
}
|
||||
}
|
||||
|
||||
kotlinter {
|
||||
experimentalRules = true
|
||||
disabledRules = arrayOf(
|
||||
"experimental:argument-list-wrapping", // Doesn't play well with Android Studio
|
||||
"experimental:comment-wrapping",
|
||||
)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(versionCatalogs.named("libs").findBundle("common").get())
|
||||
implementation(project(":utils"))
|
||||
}
|
||||
|
||||
tasks {
|
||||
preBuild {
|
||||
dependsOn(lintKotlin)
|
||||
}
|
||||
|
||||
if (System.getenv("CI") != "true") {
|
||||
lintKotlin {
|
||||
dependsOn(formatKotlin)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("printDependentExtensions") {
|
||||
doLast {
|
||||
project.printDependentExtensions()
|
||||
}
|
||||
}
|
||||
102
common.gradle
@@ -1,7 +1,18 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlinx-serialization'
|
||||
apply plugin: 'org.jmailen.kotlinter'
|
||||
|
||||
assert !ext.has("pkgNameSuffix")
|
||||
assert !ext.has("libVersion")
|
||||
|
||||
assert extName.chars().max().asInt < 0x180 : "Extension name should be romanized"
|
||||
|
||||
Project theme = ext.has("themePkg") ? project(":lib-multisrc:$themePkg") : null
|
||||
if (theme != null) evaluationDependsOn(theme.path)
|
||||
|
||||
android {
|
||||
compileSdkVersion AndroidConfig.compileSdk
|
||||
compileSdk AndroidConfig.compileSdk
|
||||
|
||||
namespace "eu.kanade.tachiyomi.extension"
|
||||
sourceSets {
|
||||
@@ -11,38 +22,35 @@ android {
|
||||
res.srcDirs = ['res']
|
||||
assets.srcDirs = ['assets']
|
||||
}
|
||||
release {
|
||||
manifest.srcFile "AndroidManifest.xml"
|
||||
}
|
||||
debug {
|
||||
manifest.srcFile "AndroidManifest.xml"
|
||||
}
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion AndroidConfig.minSdk
|
||||
targetSdkVersion AndroidConfig.targetSdk
|
||||
applicationIdSuffix pkgNameSuffix
|
||||
versionCode extVersionCode
|
||||
versionName project.ext.properties.getOrDefault("libVersion", "1.4") + ".$extVersionCode"
|
||||
setProperty("archivesBaseName", "tachiyomi-$pkgNameSuffix-v$versionName")
|
||||
def readmes = project.projectDir.listFiles({ File file ->
|
||||
file.name == "README.md" || file.name == "CHANGELOG.md"
|
||||
} as FileFilter)
|
||||
def hasReadme = readmes != null && readmes.any { File file ->
|
||||
file.name.startsWith("README")
|
||||
}
|
||||
def hasChangelog = readmes != null && readmes.any { File file ->
|
||||
file.name.startsWith("CHANGELOG")
|
||||
minSdk AndroidConfig.minSdk
|
||||
targetSdk AndroidConfig.targetSdk
|
||||
applicationIdSuffix project.parent.name + "." + project.name
|
||||
Integer kmkVersionCode = project.ext.find("kmkVersionCode") ?: 0
|
||||
Integer kmkBaseVersionCode = theme == null ? 0 : theme.ext.find("kmkBaseVersionCode") ?: 0
|
||||
versionCode theme == null ? extVersionCode + kmkVersionCode : theme.baseVersionCode + overrideVersionCode + kmkBaseVersionCode + kmkVersionCode
|
||||
versionName "1.4.$versionCode"
|
||||
base {
|
||||
archivesName = "tachiyomi-$applicationIdSuffix-v$versionName"
|
||||
}
|
||||
assert extClass.startsWith(".")
|
||||
manifestPlaceholders = [
|
||||
appName : "Tachiyomi: $extName",
|
||||
extClass: extClass,
|
||||
extFactory: project.ext.properties.getOrDefault("extFactory", ""),
|
||||
nsfw: project.ext.properties.getOrDefault("isNsfw", false) ? 1 : 0,
|
||||
hasReadme: hasReadme ? 1 : 0,
|
||||
hasChangelog: hasChangelog ? 1 : 0,
|
||||
nsfw : project.ext.find("isNsfw") ? 1 : 0,
|
||||
]
|
||||
String baseUrl = project.ext.find("baseUrl") ?: ""
|
||||
if (theme != null && !baseUrl.isEmpty()) {
|
||||
def split = baseUrl.split("://")
|
||||
assert split.length == 2
|
||||
def path = split[1].split("/")
|
||||
manifestPlaceholders += [
|
||||
SOURCEHOST : path[0],
|
||||
SOURCESCHEME: split[0],
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
@@ -58,6 +66,7 @@ android {
|
||||
release {
|
||||
signingConfig signingConfigs.release
|
||||
minifyEnabled false
|
||||
vcsInfo.include false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,20 +75,20 @@ android {
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
// Disable unused AGP features
|
||||
aidl false
|
||||
renderScript false
|
||||
resValues false
|
||||
shaders false
|
||||
buildConfig true
|
||||
}
|
||||
|
||||
packaging {
|
||||
resources.excludes.add("kotlin-tooling-metadata.json")
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
||||
jvmTarget = JavaVersion.VERSION_17.toString()
|
||||
freeCompilerArgs += "-opt-in=kotlinx.serialization.ExperimentalSerializationApi"
|
||||
}
|
||||
|
||||
@@ -92,14 +101,29 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
if (theme != null) implementation(theme) // Overrides core launcher icons
|
||||
implementation(project(":core"))
|
||||
compileOnly(libs.bundles.common)
|
||||
implementation(project(":utils"))
|
||||
}
|
||||
|
||||
preBuild.dependsOn(lintKotlin)
|
||||
lintKotlin.dependsOn(formatKotlin)
|
||||
tasks.register("writeManifestFile") {
|
||||
doLast {
|
||||
def manifest = android.sourceSets.getByName("main").manifest
|
||||
if (!manifest.srcFile.exists()) {
|
||||
File tempFile = layout.buildDirectory.get().file("tempAndroidManifest.xml").getAsFile()
|
||||
if (!tempFile.exists()) {
|
||||
tempFile.withWriter {
|
||||
it.write('<?xml version="1.0" encoding="utf-8"?>\n<manifest />\n')
|
||||
}
|
||||
}
|
||||
manifest.srcFile(tempFile.path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
preBuild.dependsOn(writeManifestFile, lintKotlin)
|
||||
if (System.getenv("CI") != "true") {
|
||||
lintKotlin.dependsOn(formatKotlin)
|
||||
}
|
||||
|
||||
@@ -6,10 +6,7 @@
|
||||
<application android:icon="@mipmap/ic_launcher" android:allowBackup="false" android:label="${appName}">
|
||||
|
||||
<meta-data android:name="tachiyomi.extension.class" android:value="${extClass}" />
|
||||
<meta-data android:name="tachiyomi.extension.factory" android:value="${extFactory}" />
|
||||
<meta-data android:name="tachiyomi.extension.nsfw" android:value="${nsfw}" />
|
||||
<meta-data android:name="tachiyomi.extension.hasReadme" android:value="${hasReadme}" />
|
||||
<meta-data android:name="tachiyomi.extension.hasChangelog" android:value="${hasChangelog}" />
|
||||
|
||||
</application>
|
||||
|
||||
|
||||
@@ -9,9 +9,8 @@ android {
|
||||
minSdk = AndroidConfig.minSdk
|
||||
}
|
||||
|
||||
namespace = "eu.kanade.tachiyomi.extension"
|
||||
namespace = "eu.kanade.tachiyomi.extension.core"
|
||||
|
||||
@Suppress("UnstableApiUsage")
|
||||
sourceSets {
|
||||
named("main") {
|
||||
manifest.srcFile("AndroidManifest.xml")
|
||||
@@ -19,9 +18,8 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
libraryVariants.all {
|
||||
generateBuildConfigProvider?.configure {
|
||||
enabled = false
|
||||
}
|
||||
buildFeatures {
|
||||
resValues = false
|
||||
shaders = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,3 +21,7 @@ org.gradle.caching=true
|
||||
|
||||
# Enable AndroidX dependencies
|
||||
android.useAndroidX=true
|
||||
|
||||
android.enableBuildConfigAsBytecode=true
|
||||
android.defaults.buildfeatures.resvalues=false
|
||||
android.defaults.buildfeatures.shaders=false
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
kotlin_version = "1.7.21"
|
||||
coroutines_version = "1.6.4"
|
||||
serialization_version = "1.4.0"
|
||||
coreVersion = "1.16.0"
|
||||
|
||||
[libraries]
|
||||
gradle-agp = { module = "com.android.tools.build:gradle", version = "7.4.2" }
|
||||
gradle-agp = { module = "com.android.tools.build:gradle", version = "8.10.1" }
|
||||
gradle-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin_version" }
|
||||
gradle-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin_version" }
|
||||
gradle-kotlinter = { module = "org.jmailen.gradle:kotlinter-gradle", version = "3.13.0" }
|
||||
|
||||
tachiyomi-lib = { module = "com.github.tachiyomiorg:extensions-lib", version = "1.4.2" }
|
||||
tachiyomi-lib = { module = "com.github.komikku-app:extensions-lib", version = "1.7.1" }
|
||||
|
||||
kotlin-stdlib = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin_version" }
|
||||
kotlin-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-serialization-protobuf", version.ref = "serialization_version" }
|
||||
@@ -18,11 +19,12 @@ kotlin-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", ver
|
||||
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines_version" }
|
||||
coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines_version" }
|
||||
|
||||
injekt-core = { module = "com.github.inorichi.injekt:injekt-core", version = "65b0440" }
|
||||
injekt-core = { module = "com.github.null2264.injekt:injekt-core", version = "4135455a2a" }
|
||||
rxjava = { module = "io.reactivex:rxjava", version = "1.3.8" }
|
||||
jsoup = { module = "org.jsoup:jsoup", version = "1.15.1" }
|
||||
okhttp = { module = "com.squareup.okhttp3:okhttp", version = "5.0.0-alpha.11" }
|
||||
quickjs = { module = "app.cash.quickjs:quickjs-android", version = "0.9.2" }
|
||||
core = { group = "androidx.core", name = "core", version.ref = "coreVersion" }
|
||||
|
||||
[bundles]
|
||||
common = ["kotlin-stdlib", "coroutines-core", "coroutines-android", "injekt-core", "rxjava", "kotlin-protobuf", "kotlin-json", "jsoup", "okhttp", "tachiyomi-lib", "quickjs"]
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
33
gradlew
generated
vendored
@@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -55,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -83,10 +85,8 @@ done
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -133,10 +133,13 @@ location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
@@ -144,7 +147,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
@@ -152,7 +155,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -197,11 +200,15 @@ if "$cygwin" || "$msys" ; then
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
|
||||
22
gradlew.bat
generated
vendored
@@ -13,6 +13,8 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
|
||||
3
lib/cookieinterceptor/build.gradle.kts
Normal file
@@ -0,0 +1,3 @@
|
||||
plugins {
|
||||
id("lib-android")
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package eu.kanade.tachiyomi.lib.cookieinterceptor
|
||||
|
||||
import android.webkit.CookieManager
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.Response
|
||||
|
||||
class CookieInterceptor(
|
||||
private val domain: String,
|
||||
private val cookies: List<Pair<String, String>>
|
||||
) : Interceptor {
|
||||
constructor(domain: String, cookie: Pair<String, String>) : this(domain, listOf(cookie))
|
||||
|
||||
init {
|
||||
val url = "https://$domain/"
|
||||
cookies.forEach {
|
||||
val cookie = "${it.first}=${it.second}; Domain=$domain; Path=/"
|
||||
setCookie(url, cookie)
|
||||
}
|
||||
}
|
||||
|
||||
override fun intercept(chain: Interceptor.Chain): Response {
|
||||
val request = chain.request()
|
||||
if (!request.url.host.endsWith(domain)) return chain.proceed(request)
|
||||
|
||||
val cookieList = request.header("Cookie")?.split("; ") ?: emptyList()
|
||||
|
||||
if (cookies.all { (key, value) -> "$key=$value" in cookieList })
|
||||
return chain.proceed(request)
|
||||
|
||||
cookies.forEach { (key, value) ->
|
||||
setCookie("https://$domain/", "$key=$value; Domain=$domain; Path=/")
|
||||
}
|
||||
|
||||
val newCookie = buildList(cookieList.size + cookies.size) {
|
||||
cookieList.filterNotTo(this) { existing ->
|
||||
cookies.any { (key, _) ->
|
||||
existing.startsWith("$key=")
|
||||
}
|
||||
}
|
||||
cookies.forEach { (key, value) ->
|
||||
add("$key=$value")
|
||||
}
|
||||
}.joinToString("; ")
|
||||
|
||||
val newRequest = request.newBuilder()
|
||||
.header("Cookie", newCookie)
|
||||
.build()
|
||||
|
||||
return chain.proceed(newRequest)
|
||||
}
|
||||
|
||||
private val cookieManager by lazy { CookieManager.getInstance() }
|
||||
|
||||
private fun setCookie(url: String, value: String) {
|
||||
try {
|
||||
cookieManager.setCookie(url, value)
|
||||
} catch (_: Exception) { }
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,3 @@
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
kotlin("android")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = AndroidConfig.compileSdk
|
||||
|
||||
defaultConfig {
|
||||
minSdk = AndroidConfig.minSdk
|
||||
}
|
||||
|
||||
namespace = "eu.kanade.tachiyomi.lib.cryptoaes"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.kotlin.stdlib)
|
||||
id("lib-android")
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.util.Base64
|
||||
import java.security.MessageDigest
|
||||
import java.util.Arrays
|
||||
import javax.crypto.Cipher
|
||||
import javax.crypto.SecretKey
|
||||
import javax.crypto.spec.IvParameterSpec
|
||||
import javax.crypto.spec.SecretKeySpec
|
||||
|
||||
|
||||
@@ -1,24 +1,3 @@
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
kotlin("android")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = AndroidConfig.compileSdk
|
||||
|
||||
defaultConfig {
|
||||
minSdk = AndroidConfig.minSdk
|
||||
}
|
||||
|
||||
namespace = "eu.kanade.tachiyomi.lib.dataimage"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.kotlin.stdlib)
|
||||
compileOnly(libs.okhttp)
|
||||
compileOnly(libs.jsoup)
|
||||
id("lib-android")
|
||||
}
|
||||
|
||||
@@ -1,22 +1,3 @@
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
kotlin("android")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = AndroidConfig.compileSdk
|
||||
|
||||
defaultConfig {
|
||||
minSdk = AndroidConfig.minSdk
|
||||
}
|
||||
|
||||
namespace = "eu.kanade.tachiyomi.lib.i18n"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.kotlin.stdlib)
|
||||
id("lib-android")
|
||||
}
|
||||
|
||||
3
lib/lzstring/build.gradle.kts
Normal file
@@ -0,0 +1,3 @@
|
||||
plugins {
|
||||
id("lib-android")
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
package eu.kanade.tachiyomi.lib.lzstring
|
||||
|
||||
typealias getCharFromIntFn = (it: Int) -> String
|
||||
typealias getNextValueFn = (it: Int) -> Int
|
||||
|
||||
/**
|
||||
* Reimplementation of [lz-string](https://github.com/pieroxy/lz-string) compression/decompression.
|
||||
*/
|
||||
object LZString {
|
||||
private fun compress(
|
||||
uncompressed: String,
|
||||
bitsPerChar: Int,
|
||||
getCharFromInt: getCharFromIntFn,
|
||||
): String {
|
||||
val context = CompressionContext(uncompressed.length, bitsPerChar, getCharFromInt)
|
||||
|
||||
for (ii in uncompressed.indices) {
|
||||
context.c = uncompressed[ii].toString()
|
||||
|
||||
if (!context.dictionary.containsKey(context.c)) {
|
||||
context.dictionary[context.c] = context.dictSize++
|
||||
context.dictionaryToCreate[context.c] = true
|
||||
}
|
||||
|
||||
context.wc = context.w + context.c
|
||||
|
||||
if (context.dictionary.containsKey(context.wc)) {
|
||||
context.w = context.wc
|
||||
continue
|
||||
}
|
||||
|
||||
context.outputCodeForW()
|
||||
|
||||
context.decrementEnlargeIn()
|
||||
context.dictionary[context.wc] = context.dictSize++
|
||||
context.w = context.c
|
||||
}
|
||||
|
||||
if (context.w.isNotEmpty()) {
|
||||
context.outputCodeForW()
|
||||
context.decrementEnlargeIn()
|
||||
}
|
||||
|
||||
// Mark the end of the stream
|
||||
context.value = 2
|
||||
for (i in 0 until context.numBits) {
|
||||
context.dataVal = (context.dataVal shl 1) or (context.value and 1)
|
||||
context.appendDataOrAdvancePosition()
|
||||
context.value = context.value shr 1
|
||||
}
|
||||
|
||||
while (true) {
|
||||
context.dataVal = context.dataVal shl 1
|
||||
|
||||
if (context.dataPosition == bitsPerChar - 1) {
|
||||
context.data.append(getCharFromInt(context.dataVal))
|
||||
break
|
||||
}
|
||||
|
||||
context.dataPosition++
|
||||
}
|
||||
|
||||
return context.data.toString()
|
||||
}
|
||||
|
||||
private fun decompress(length: Int, resetValue: Int, getNextValue: getNextValueFn): String {
|
||||
val dictionary = mutableListOf<String>()
|
||||
val result = StringBuilder()
|
||||
val data = DecompressionContext(resetValue, getNextValue)
|
||||
var enlargeIn = 4
|
||||
var numBits = 3
|
||||
var entry: String
|
||||
var c: Char? = null
|
||||
|
||||
for (i in 0 until 3) {
|
||||
dictionary.add(i.toString())
|
||||
}
|
||||
|
||||
data.loopUntilMaxPower()
|
||||
|
||||
when (data.bits) {
|
||||
0 -> {
|
||||
data.bits = 0
|
||||
data.maxPower = 1 shl 8
|
||||
data.power = 1
|
||||
data.loopUntilMaxPower()
|
||||
c = data.bits.toChar()
|
||||
}
|
||||
1 -> {
|
||||
data.bits = 0
|
||||
data.maxPower = 1 shl 16
|
||||
data.power = 1
|
||||
data.loopUntilMaxPower()
|
||||
c = data.bits.toChar()
|
||||
}
|
||||
2 -> throw IllegalArgumentException("Invalid LZString")
|
||||
}
|
||||
|
||||
if (c == null) {
|
||||
throw Exception("No character found")
|
||||
}
|
||||
|
||||
dictionary.add(c.toString())
|
||||
var w = c.toString()
|
||||
result.append(c.toString())
|
||||
|
||||
while (true) {
|
||||
if (data.index > length) {
|
||||
throw IllegalArgumentException("Invalid LZString")
|
||||
}
|
||||
|
||||
data.bits = 0
|
||||
data.maxPower = 1 shl numBits
|
||||
data.power = 1
|
||||
data.loopUntilMaxPower()
|
||||
|
||||
var cc = data.bits
|
||||
|
||||
when (data.bits) {
|
||||
0 -> {
|
||||
data.bits = 0
|
||||
data.maxPower = 1 shl 8
|
||||
data.power = 1
|
||||
data.loopUntilMaxPower()
|
||||
dictionary.add(data.bits.toChar().toString())
|
||||
cc = dictionary.size - 1
|
||||
enlargeIn--
|
||||
}
|
||||
1 -> {
|
||||
data.bits = 0
|
||||
data.maxPower = 1 shl 16
|
||||
data.power = 1
|
||||
data.loopUntilMaxPower()
|
||||
dictionary.add(data.bits.toChar().toString())
|
||||
cc = dictionary.size - 1
|
||||
enlargeIn--
|
||||
}
|
||||
2 -> return result.toString()
|
||||
}
|
||||
|
||||
if (enlargeIn == 0) {
|
||||
enlargeIn = 1 shl numBits
|
||||
numBits++
|
||||
}
|
||||
|
||||
entry = if (cc < dictionary.size) {
|
||||
dictionary[cc]
|
||||
} else {
|
||||
if (cc == dictionary.size) {
|
||||
w + w[0]
|
||||
} else {
|
||||
throw Exception("Invalid LZString")
|
||||
}
|
||||
}
|
||||
result.append(entry)
|
||||
dictionary.add(w + entry[0])
|
||||
enlargeIn--
|
||||
w = entry
|
||||
|
||||
if (enlargeIn == 0) {
|
||||
enlargeIn = 1 shl numBits
|
||||
numBits++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private const val base64KeyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
|
||||
|
||||
fun compressToBase64(input: String): String =
|
||||
compress(input, 6) { base64KeyStr[it].toString() }.let {
|
||||
return when (it.length % 4) {
|
||||
0 -> it
|
||||
1 -> "$it==="
|
||||
2 -> "$it=="
|
||||
3 -> "$it="
|
||||
else -> throw IllegalStateException("Modulo of 4 should not exceed 3.")
|
||||
}
|
||||
}
|
||||
|
||||
fun decompressFromBase64(input: String): String =
|
||||
decompress(input.length, 32) {
|
||||
base64KeyStr.indexOf(input[it])
|
||||
}
|
||||
}
|
||||
|
||||
private data class DecompressionContext(
|
||||
val resetValue: Int,
|
||||
val getNextValue: getNextValueFn,
|
||||
var value: Int = getNextValue(0),
|
||||
var position: Int = resetValue,
|
||||
var index: Int = 1,
|
||||
var bits: Int = 0,
|
||||
var maxPower: Int = 1 shl 2,
|
||||
var power: Int = 1,
|
||||
) {
|
||||
fun loopUntilMaxPower() {
|
||||
while (power != maxPower) {
|
||||
val resb = value and position
|
||||
|
||||
position = position shr 1
|
||||
|
||||
if (position == 0) {
|
||||
position = resetValue
|
||||
value = getNextValue(index++)
|
||||
}
|
||||
|
||||
bits = bits or ((if (resb > 0) 1 else 0) * power)
|
||||
power = power shl 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private data class CompressionContext(
|
||||
val uncompressedLength: Int,
|
||||
val bitsPerChar: Int,
|
||||
val getCharFromInt: getCharFromIntFn,
|
||||
var value: Int = 0,
|
||||
val dictionary: MutableMap<String, Int> = HashMap(),
|
||||
val dictionaryToCreate: MutableMap<String, Boolean> = HashMap(),
|
||||
var c: String = "",
|
||||
var wc: String = "",
|
||||
var w: String = "",
|
||||
var enlargeIn: Int = 2, // Compensate for the first entry which should not count
|
||||
var dictSize: Int = 3,
|
||||
var numBits: Int = 2,
|
||||
val data: StringBuilder = StringBuilder(uncompressedLength / 3),
|
||||
var dataVal: Int = 0,
|
||||
var dataPosition: Int = 0,
|
||||
) {
|
||||
fun appendDataOrAdvancePosition() {
|
||||
if (dataPosition == bitsPerChar - 1) {
|
||||
dataPosition = 0
|
||||
data.append(getCharFromInt(dataVal))
|
||||
dataVal = 0
|
||||
} else {
|
||||
dataPosition++
|
||||
}
|
||||
}
|
||||
|
||||
fun decrementEnlargeIn() {
|
||||
enlargeIn--
|
||||
if (enlargeIn == 0) {
|
||||
enlargeIn = 1 shl numBits
|
||||
numBits++
|
||||
}
|
||||
}
|
||||
|
||||
// Output the code for W.
|
||||
fun outputCodeForW() {
|
||||
if (dictionaryToCreate.containsKey(w)) {
|
||||
if (w[0].code < 256) {
|
||||
for (i in 0 until numBits) {
|
||||
dataVal = dataVal shl 1
|
||||
appendDataOrAdvancePosition()
|
||||
}
|
||||
|
||||
value = w[0].code
|
||||
|
||||
for (i in 0 until 8) {
|
||||
dataVal = (dataVal shl 1) or (value and 1)
|
||||
appendDataOrAdvancePosition()
|
||||
value = value shr 1
|
||||
}
|
||||
} else {
|
||||
value = 1
|
||||
|
||||
for (i in 0 until numBits) {
|
||||
dataVal = (dataVal shl 1) or value
|
||||
appendDataOrAdvancePosition()
|
||||
value = 0
|
||||
}
|
||||
|
||||
value = w[0].code
|
||||
|
||||
for (i in 0 until 16) {
|
||||
dataVal = (dataVal shl 1) or (value and 1)
|
||||
appendDataOrAdvancePosition()
|
||||
value = value shr 1
|
||||
}
|
||||
}
|
||||
|
||||
decrementEnlargeIn()
|
||||
dictionaryToCreate.remove(w)
|
||||
} else {
|
||||
value = dictionary[w]!!
|
||||
|
||||
for (i in 0 until numBits) {
|
||||
dataVal = (dataVal shl 1) or (value and 1)
|
||||
appendDataOrAdvancePosition()
|
||||
value = value shr 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,3 @@
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
kotlin("android")
|
||||
id("kotlinx-serialization")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = AndroidConfig.compileSdk
|
||||
|
||||
defaultConfig {
|
||||
minSdk = AndroidConfig.minSdk
|
||||
}
|
||||
|
||||
namespace = "eu.kanade.tachiyomi.lib.randomua"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.bundles.common)
|
||||
id("lib-android")
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ private class RandomUserAgentInterceptor(
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val UA_DB_URL = "https://tachiyomiorg.github.io/user-agents/user-agents.json"
|
||||
private const val UA_DB_URL = "https://keiyoushi.github.io/user-agents/user-agents.json"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import androidx.preference.PreferenceScreen
|
||||
import okhttp3.Headers
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Helper function to return UserAgentType based on SharedPreference value
|
||||
*/
|
||||
fun SharedPreferences.getPrefUAType(): UserAgentType {
|
||||
@@ -34,7 +34,9 @@ fun SharedPreferences.getPrefCustomUA(): String? {
|
||||
fun addRandomUAPreferenceToScreen(
|
||||
screen: PreferenceScreen,
|
||||
) {
|
||||
ListPreference(screen.context).apply {
|
||||
val context = screen.context
|
||||
|
||||
ListPreference(context).apply {
|
||||
key = PREF_KEY_RANDOM_UA
|
||||
title = TITLE_RANDOM_UA
|
||||
entries = RANDOM_UA_ENTRIES
|
||||
@@ -43,28 +45,27 @@ fun addRandomUAPreferenceToScreen(
|
||||
setDefaultValue("off")
|
||||
}.also(screen::addPreference)
|
||||
|
||||
EditTextPreference(screen.context).apply {
|
||||
EditTextPreference(context).apply {
|
||||
key = PREF_KEY_CUSTOM_UA
|
||||
title = TITLE_CUSTOM_UA
|
||||
summary = CUSTOM_UA_SUMMARY
|
||||
setOnPreferenceChangeListener { _, newValue ->
|
||||
try {
|
||||
Headers.Builder().add("User-Agent", newValue as String).build()
|
||||
Headers.headersOf("User-Agent", newValue as String)
|
||||
true
|
||||
} catch (e: IllegalArgumentException) {
|
||||
Toast.makeText(screen.context, "User Agent invalid:${e.message}", Toast.LENGTH_LONG).show()
|
||||
Toast.makeText(context, "Invalid user agent string: ${e.message}", Toast.LENGTH_LONG).show()
|
||||
false
|
||||
}
|
||||
}
|
||||
}.also(screen::addPreference)
|
||||
}
|
||||
|
||||
const val TITLE_RANDOM_UA = "Random User-Agent (Requires Restart)"
|
||||
const val TITLE_RANDOM_UA = "Random user agent string (requires restart)"
|
||||
const val PREF_KEY_RANDOM_UA = "pref_key_random_ua_"
|
||||
val RANDOM_UA_ENTRIES = arrayOf("OFF", "Desktop", "Mobile")
|
||||
val RANDOM_UA_VALUES = arrayOf("off", "desktop", "mobile")
|
||||
|
||||
const val TITLE_CUSTOM_UA = "Custom User-Agent (Requires Restart)"
|
||||
const val TITLE_CUSTOM_UA = "Custom user agent string (requires restart)"
|
||||
const val PREF_KEY_CUSTOM_UA = "pref_key_custom_ua_"
|
||||
const val CUSTOM_UA_SUMMARY = "Leave blank to use application default user-agent (IGNORED if Random User-Agent is enabled)"
|
||||
|
||||
const val CUSTOM_UA_SUMMARY = "Leave blank to use the default user agent string (ignored if random user agent string is enabled)"
|
||||
|
||||
7
lib/speedbinb/build.gradle.kts
Normal file
@@ -0,0 +1,7 @@
|
||||
plugins {
|
||||
id("lib-android")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":lib:textinterceptor"))
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package eu.kanade.tachiyomi.lib.speedbinb
|
||||
|
||||
private const val URLSAFE_BASE64_LOOKUP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||
|
||||
internal fun determineKeyPair(src: String?, ptbl: List<String>, ctbl: List<String>): Pair<String, String> {
|
||||
val i = mutableListOf(0, 0)
|
||||
|
||||
if (src != null) {
|
||||
val filename = src.substringAfterLast("/")
|
||||
|
||||
for (e in filename.indices) {
|
||||
i[e % 2] = i[e % 2] + filename[e].code
|
||||
}
|
||||
|
||||
i[0] = i[0] % 8
|
||||
i[1] = i[1] % 8
|
||||
}
|
||||
|
||||
return Pair(ptbl[i[0]], ctbl[i[1]])
|
||||
}
|
||||
|
||||
internal fun decodeScrambleTable(cid: String, sharedKey: String, table: String): String {
|
||||
val r = "$cid:$sharedKey"
|
||||
var e = r.toCharArray()
|
||||
.map { it.code }
|
||||
.reduceIndexed { index, acc, i -> acc + (i shl index % 16) } and 2147483647
|
||||
|
||||
if (e == 0) {
|
||||
e = 0x12345678
|
||||
}
|
||||
|
||||
return buildString(table.length) {
|
||||
for (s in table.indices) {
|
||||
e = e ushr 1 xor (1210056708 and -(1 and e))
|
||||
append(((table[s].code - 32 + e) % 94 + 32).toChar())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal fun generateSharedKey(cid: String): String {
|
||||
val randomChars = randomChars(16)
|
||||
val cidRepeatCount = (16 + cid.length - 1) / cid.length
|
||||
val unk1 = buildString(cid.length * cidRepeatCount) {
|
||||
for (i in 0 until cidRepeatCount) {
|
||||
append(cid)
|
||||
}
|
||||
}
|
||||
val unk2 = unk1.substring(0, 16)
|
||||
val unk3 = unk1.substring(unk1.length - 16, unk1.length)
|
||||
var s = 0
|
||||
var h = 0
|
||||
var u = 0
|
||||
|
||||
return buildString(randomChars.length * 2) {
|
||||
for (i in randomChars.indices) {
|
||||
s = s xor randomChars[i].code
|
||||
h = h xor unk2[i].code
|
||||
u = u xor unk3[i].code
|
||||
|
||||
append(randomChars[i])
|
||||
append(URLSAFE_BASE64_LOOKUP[(s + h + u) and 63])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun randomChars(length: Int) = buildString(length) {
|
||||
for (i in 0 until length) {
|
||||
append(URLSAFE_BASE64_LOOKUP.random())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package eu.kanade.tachiyomi.lib.speedbinb
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
|
||||
private val COORD_REGEX = Regex("""^i:(\d+),(\d+)\+(\d+),(\d+)>(\d+),(\d+)$""")
|
||||
|
||||
@Serializable
|
||||
class BibContentInfo(
|
||||
val result: Int,
|
||||
val items: List<BibContentItem>,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
class BibContentItem(
|
||||
@SerialName("ContentID") val contentId: String,
|
||||
@SerialName("ContentsServer") val contentServer: String,
|
||||
@SerialName("ServerType") val serverType: Int,
|
||||
val stbl: String,
|
||||
val ttbl: String,
|
||||
val ptbl: String,
|
||||
val ctbl: String,
|
||||
@SerialName("p") val requestToken: String? = null,
|
||||
@SerialName("ViewMode") val viewMode: Int,
|
||||
@SerialName("ContentDate") val contentDate: String? = null,
|
||||
@SerialName("ShopURL") val shopUrl: String? = null,
|
||||
) {
|
||||
fun getSbcUrl(readerUrl: HttpUrl, cid: String) =
|
||||
contentServer.toHttpUrl().newBuilder().apply {
|
||||
when (serverType) {
|
||||
ServerType.DIRECT -> addPathSegment("content.js")
|
||||
ServerType.REST -> addPathSegment("content")
|
||||
ServerType.SBC -> {
|
||||
addPathSegment("sbcGetCntnt.php")
|
||||
setQueryParameter("cid", cid)
|
||||
requestToken?.let { setQueryParameter("p", it) }
|
||||
setQueryParameter("q", "1")
|
||||
setQueryParameter("vm", viewMode.toString())
|
||||
setQueryParameter("dmytime", contentDate ?: System.currentTimeMillis().toString())
|
||||
copyKeyParametersFrom(readerUrl)
|
||||
}
|
||||
else -> throw UnsupportedOperationException("Unsupported ServerType value $serverType")
|
||||
}
|
||||
}.toString()
|
||||
}
|
||||
|
||||
object ServerType {
|
||||
const val SBC = 0
|
||||
const val DIRECT = 1
|
||||
const val REST = 2
|
||||
}
|
||||
|
||||
object ViewMode {
|
||||
const val COMMERCIAL = 1
|
||||
const val NON_MEMBER_TRIAL = 2
|
||||
const val MEMBER_TRIAL = 3
|
||||
}
|
||||
|
||||
@Serializable
|
||||
class PtImg(
|
||||
@SerialName("ptimg-version") val ptImgVersion: Int,
|
||||
val resources: PtImgResources,
|
||||
val views: List<PtImgViews>,
|
||||
) {
|
||||
val translations by lazy {
|
||||
views[0].coords.map { coord ->
|
||||
val v = COORD_REGEX.matchEntire(coord)!!.groupValues.drop(1).map { it.toInt() }
|
||||
PtImgTranslation(v[0], v[1], v[2], v[3], v[4], v[5])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
class PtImgResources(
|
||||
val i: PtImgImage,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
class PtImgImage(
|
||||
val src: String,
|
||||
val width: Int,
|
||||
val height: Int,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
class PtImgViews(
|
||||
val width: Int,
|
||||
val height: Int,
|
||||
val coords: Array<String>,
|
||||
)
|
||||
|
||||
class PtImgTranslation(val xsrc: Int, val ysrc: Int, val width: Int, val height: Int, val xdest: Int, val ydest: Int)
|
||||
|
||||
@Serializable
|
||||
class SBCContent(
|
||||
@SerialName("SBCVersion") val sbcVersion: String,
|
||||
val result: Int,
|
||||
val ttx: String,
|
||||
@SerialName("ImageClass") val imageClass: String? = null,
|
||||
)
|
||||
@@ -0,0 +1,85 @@
|
||||
package eu.kanade.tachiyomi.lib.speedbinb
|
||||
|
||||
import android.graphics.BitmapFactory
|
||||
import eu.kanade.tachiyomi.lib.speedbinb.descrambler.PtBinbDescramblerA
|
||||
import eu.kanade.tachiyomi.lib.speedbinb.descrambler.PtBinbDescramblerF
|
||||
import eu.kanade.tachiyomi.lib.speedbinb.descrambler.PtImgDescrambler
|
||||
import eu.kanade.tachiyomi.lib.textinterceptor.TextInterceptor
|
||||
import eu.kanade.tachiyomi.lib.textinterceptor.TextInterceptorHelper
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import okhttp3.ResponseBody.Companion.toResponseBody
|
||||
import java.io.IOException
|
||||
|
||||
class SpeedBinbInterceptor(private val json: Json) : Interceptor {
|
||||
|
||||
private val textInterceptor by lazy { TextInterceptor() }
|
||||
|
||||
override fun intercept(chain: Interceptor.Chain): Response {
|
||||
val request = chain.request()
|
||||
val host = request.url.host
|
||||
val filename = request.url.pathSegments.last()
|
||||
val fragment = request.url.fragment
|
||||
|
||||
return when {
|
||||
host == TextInterceptorHelper.HOST -> textInterceptor.intercept(chain)
|
||||
filename.endsWith(".ptimg.json") -> interceptPtImg(chain, request)
|
||||
fragment == null -> chain.proceed(request)
|
||||
fragment.startsWith("ptbinb,") -> interceptPtBinB(chain, request)
|
||||
else -> chain.proceed(request)
|
||||
}
|
||||
}
|
||||
|
||||
private fun interceptPtImg(chain: Interceptor.Chain, request: Request): Response {
|
||||
val response = chain.proceed(request)
|
||||
val metadata = json.decodeFromString<PtImg>(response.body.string())
|
||||
val imageUrl = request.url.newBuilder()
|
||||
.setPathSegment(request.url.pathSize - 1, metadata.resources.i.src)
|
||||
.build()
|
||||
val imageResponse = chain.proceed(
|
||||
request.newBuilder().url(imageUrl).build(),
|
||||
)
|
||||
|
||||
if (metadata.translations.isEmpty()) {
|
||||
return imageResponse
|
||||
}
|
||||
|
||||
val image = BitmapFactory.decodeStream(imageResponse.body.byteStream())
|
||||
val descrambler = PtImgDescrambler(metadata)
|
||||
return imageResponse.newBuilder()
|
||||
.body(descrambler.descrambleImage(image)!!.toResponseBody(JPEG_MEDIA_TYPE))
|
||||
.build()
|
||||
}
|
||||
|
||||
private fun interceptPtBinB(chain: Interceptor.Chain, request: Request): Response {
|
||||
val response = chain.proceed(request)
|
||||
val fragment = request.url.fragment!!
|
||||
val (s, u) = fragment.removePrefix("ptbinb,").split(",", limit = 2)
|
||||
|
||||
if (s.isEmpty() && u.isEmpty()) {
|
||||
return response
|
||||
}
|
||||
|
||||
val imageData = response.body.bytes()
|
||||
val image = BitmapFactory.decodeByteArray(imageData, 0, imageData.size)
|
||||
val descrambler = if (s[0] == '=' && u[0] == '=') {
|
||||
PtBinbDescramblerF(s, u, image.width, image.height)
|
||||
} else if (NUMERIC_CHARACTERS.contains(s[0]) && NUMERIC_CHARACTERS.contains(u[0])) {
|
||||
PtBinbDescramblerA(s, u, image.width, image.height)
|
||||
} else {
|
||||
throw IOException("Cannot select descrambler for key pair s=$s, u=$u")
|
||||
}
|
||||
val descrambled = descrambler.descrambleImage(image) ?: imageData
|
||||
|
||||
return response.newBuilder()
|
||||
.body(descrambled.toResponseBody(JPEG_MEDIA_TYPE))
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
private const val NUMERIC_CHARACTERS = "0123456789"
|
||||
private val JPEG_MEDIA_TYPE = "image/jpeg".toMediaType()
|
||||
@@ -0,0 +1,197 @@
|
||||
package eu.kanade.tachiyomi.lib.speedbinb
|
||||
|
||||
import eu.kanade.tachiyomi.lib.textinterceptor.TextInterceptorHelper
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.Headers
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Response
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Document
|
||||
|
||||
/**
|
||||
* SpeedBinb is a reader for various Japanese manga sites.
|
||||
*
|
||||
* Versions (`SpeedBinb.VERSION` in DevTools console):
|
||||
* - Minimum version tested: `1.6650.0001`
|
||||
* - Maximum version tested: `1.6930.1101`
|
||||
*
|
||||
* These versions are only for reference purposes, and does not reflect the actual range
|
||||
* of versions this class can scrape.
|
||||
*/
|
||||
class SpeedBinbReader(
|
||||
private val client: OkHttpClient,
|
||||
private val headers: Headers,
|
||||
private val json: Json,
|
||||
private val highQualityMode: Boolean = false,
|
||||
) {
|
||||
private val isInterceptorAdded by lazy {
|
||||
client.interceptors.filterIsInstance<SpeedBinbInterceptor>().isNotEmpty()
|
||||
}
|
||||
|
||||
fun pageListParse(response: Response): List<Page> =
|
||||
pageListParse(response.asJsoup())
|
||||
|
||||
fun pageListParse(document: Document): List<Page> {
|
||||
// We throw here instead of in the `init {}` block because extensions that fail
|
||||
// to load just mysteriously disappears from the extension list, no errors no nothing.
|
||||
if (!isInterceptorAdded) {
|
||||
throw Exception("SpeedBinbInterceptor was not added to the client.")
|
||||
}
|
||||
|
||||
val readerUrl = document.location().toHttpUrl()
|
||||
val content = document.selectFirst("#content")!!
|
||||
|
||||
if (!content.hasAttr("data-ptbinb")) {
|
||||
return content.select("[data-ptimg]").mapIndexed { i, it ->
|
||||
Page(i, imageUrl = it.absUrl("data-ptimg"))
|
||||
}
|
||||
}
|
||||
|
||||
val cid = content.attr("data-ptbinb-cid")
|
||||
.ifEmpty { readerUrl.queryParameter("cid") }
|
||||
?: throw Exception("Could not find chapter ID")
|
||||
val sharedKey = generateSharedKey(cid)
|
||||
val contentInfoUrl = content.absUrl("data-ptbinb").toHttpUrl().newBuilder()
|
||||
.copyKeyParametersFrom(readerUrl)
|
||||
.setQueryParameter("cid", cid)
|
||||
.setQueryParameter("k", sharedKey)
|
||||
.setQueryParameter("dmytime", System.currentTimeMillis().toString())
|
||||
.build()
|
||||
val contentInfo = client.newCall(GET(contentInfoUrl, headers)).execute().parseAs<BibContentInfo>()
|
||||
|
||||
if (contentInfo.result != 1) {
|
||||
throw Exception("Failed to execute bibGetCntntInfo API.")
|
||||
}
|
||||
|
||||
if (contentInfo.items.isEmpty()) {
|
||||
throw Exception("There is no item.")
|
||||
}
|
||||
|
||||
val contentItem = contentInfo.items[0]
|
||||
val ctbl = json.decodeFromString<List<String>>(decodeScrambleTable(cid, sharedKey, contentItem.ctbl))
|
||||
val ptbl = json.decodeFromString<List<String>>(decodeScrambleTable(cid, sharedKey, contentItem.ptbl))
|
||||
val sbcUrl = contentItem.getSbcUrl(readerUrl, cid)
|
||||
val sbcData = client.newCall(GET(sbcUrl, headers)).execute().body.string().let {
|
||||
val raw = if (contentItem.serverType == ServerType.DIRECT) {
|
||||
it.substringAfter("DataGet_Content(").substringBeforeLast(")")
|
||||
} else {
|
||||
it
|
||||
}
|
||||
|
||||
json.decodeFromString<SBCContent>(raw)
|
||||
}
|
||||
|
||||
if (sbcData.result != 1) {
|
||||
throw Exception("Failed to fetch content")
|
||||
}
|
||||
|
||||
val isSingleQuality = sbcData.imageClass == "singlequality"
|
||||
val ttx = Jsoup.parseBodyFragment(sbcData.ttx, document.location())
|
||||
val pageBaseUrl = when (contentItem.serverType) {
|
||||
ServerType.DIRECT, ServerType.REST -> contentItem.contentServer
|
||||
ServerType.SBC -> sbcUrl.replaceFirst("/sbcGetCntnt.php", "/sbcGetImg.php")
|
||||
else -> throw UnsupportedOperationException("Unsupported ServerType value ${contentItem.serverType}")
|
||||
}.toHttpUrl()
|
||||
val pages = ttx.select("t-case:first-of-type t-img").mapIndexed { i, it ->
|
||||
val src = it.attr("src")
|
||||
val keyPair = determineKeyPair(src, ptbl, ctbl)
|
||||
val fragment = "ptbinb,${keyPair.first},${keyPair.second}"
|
||||
val imageUrl = pageBaseUrl.newBuilder()
|
||||
.buildImageUrl(
|
||||
readerUrl,
|
||||
src,
|
||||
contentItem,
|
||||
isSingleQuality,
|
||||
highQualityMode,
|
||||
)
|
||||
.fragment(fragment)
|
||||
.toString()
|
||||
|
||||
Page(i, imageUrl = imageUrl)
|
||||
}.toMutableList()
|
||||
|
||||
// This is probably the silliest use of TextInterceptor ever.
|
||||
//
|
||||
// If chapter purchases are enabled, and there's a link to purchase the current chapter,
|
||||
// we add in the purchase URL as the last page.
|
||||
val buyIconPosition = document.selectFirst("script:containsData(Config.LoginBuyIconPosition)")
|
||||
?.data()
|
||||
?.substringAfter("Config.LoginBuyIconPosition=")
|
||||
?.substringBefore(";")
|
||||
?.trim()
|
||||
?: "-1"
|
||||
val enableBuying = buyIconPosition != "-1"
|
||||
|
||||
if (enableBuying && contentItem.viewMode != ViewMode.COMMERCIAL && !contentItem.shopUrl.isNullOrEmpty()) {
|
||||
pages.add(
|
||||
Page(pages.size, imageUrl = TextInterceptorHelper.createUrl("", "購入: ${contentItem.shopUrl}")),
|
||||
)
|
||||
}
|
||||
|
||||
return pages
|
||||
}
|
||||
|
||||
private inline fun <reified T> Response.parseAs(): T =
|
||||
json.decodeFromString(body.string())
|
||||
}
|
||||
|
||||
private fun HttpUrl.Builder.buildImageUrl(
|
||||
readerUrl: HttpUrl,
|
||||
src: String,
|
||||
contentItem: BibContentItem,
|
||||
isSingleQuality: Boolean,
|
||||
highQualityMode: Boolean,
|
||||
) = apply {
|
||||
when (contentItem.serverType) {
|
||||
ServerType.DIRECT -> {
|
||||
val filename = when {
|
||||
isSingleQuality -> "M.jpg"
|
||||
highQualityMode -> "M_H.jpg"
|
||||
else -> "M_L.jpg"
|
||||
}
|
||||
|
||||
addPathSegments(src)
|
||||
addPathSegment(filename)
|
||||
contentItem.contentDate?.let { setQueryParameter("dmytime", it) }
|
||||
}
|
||||
ServerType.REST -> {
|
||||
addPathSegment("img")
|
||||
addPathSegments(src)
|
||||
if (!isSingleQuality && !highQualityMode) {
|
||||
setQueryParameter("q", "1")
|
||||
}
|
||||
|
||||
contentItem.contentDate?.let { setQueryParameter("dmytime", it) }
|
||||
copyKeyParametersFrom(readerUrl)
|
||||
}
|
||||
ServerType.SBC -> {
|
||||
setQueryParameter("src", src)
|
||||
contentItem.requestToken?.let { setQueryParameter("p", it) }
|
||||
|
||||
if (!isSingleQuality) {
|
||||
setQueryParameter("q", if (highQualityMode) "0" else "1")
|
||||
}
|
||||
|
||||
setQueryParameter("vm", contentItem.viewMode.toString())
|
||||
contentItem.contentDate?.let { setQueryParameter("dmytime", it) }
|
||||
copyKeyParametersFrom(readerUrl)
|
||||
}
|
||||
else -> throw UnsupportedOperationException("Unsupported ServerType value ${contentItem.serverType}")
|
||||
}
|
||||
}
|
||||
|
||||
internal fun HttpUrl.Builder.copyKeyParametersFrom(url: HttpUrl): HttpUrl.Builder {
|
||||
for (i in 0..9) {
|
||||
url.queryParameter("u$i")?.let {
|
||||
setQueryParameter("u$i", it)
|
||||
}
|
||||
}
|
||||
|
||||
return this
|
||||
}
|
||||
@@ -0,0 +1,301 @@
|
||||
package eu.kanade.tachiyomi.lib.speedbinb.descrambler
|
||||
|
||||
import eu.kanade.tachiyomi.lib.speedbinb.PtImgTranslation
|
||||
|
||||
private val PTBINBF_REGEX = Regex("""^=([0-9]+)-([0-9]+)([-+])([0-9]+)-([-_0-9A-Za-z]+)$""")
|
||||
private const val PTBINBF_CHAR_LOOKUP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||
private const val PTBINBA_CHAR_LOOKUP = "aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ"
|
||||
|
||||
abstract class PtBinbDescrambler(
|
||||
val s: String,
|
||||
val u: String,
|
||||
val width: Int,
|
||||
val height: Int,
|
||||
) : SpeedBinbDescrambler()
|
||||
|
||||
class PtBinbDescramblerF(s: String, u: String, width: Int, height: Int) : PtBinbDescrambler(s, u, width, height) {
|
||||
|
||||
private var widthPieces: Int = 0
|
||||
private var heightPieces: Int = 0
|
||||
private var piecePadding: Int = 0
|
||||
private lateinit var hDstPosLookup: List<Int>
|
||||
private lateinit var wDstPosLookup: List<Int>
|
||||
private lateinit var hPosLookup: List<Int>
|
||||
private lateinit var wPosLookup: List<Int>
|
||||
private var pieceDest: List<Int>? = null
|
||||
|
||||
init {
|
||||
// Kotlin init blocks don't allow early returns...
|
||||
init()
|
||||
}
|
||||
|
||||
private fun init() {
|
||||
val srcData = PTBINBF_REGEX.matchEntire(s)?.groupValues
|
||||
val dstData = PTBINBF_REGEX.matchEntire(u)?.groupValues
|
||||
|
||||
if (
|
||||
dstData == null ||
|
||||
srcData == null ||
|
||||
dstData[1] != srcData[1] ||
|
||||
dstData[2] != srcData[2] ||
|
||||
dstData[4] != srcData[4] ||
|
||||
dstData[3] != "+" ||
|
||||
srcData[3] != "-"
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
widthPieces = dstData[1].toInt()
|
||||
heightPieces = dstData[2].toInt()
|
||||
piecePadding = dstData[4].toInt()
|
||||
|
||||
if (widthPieces < 8 || heightPieces < 8 || widthPieces * heightPieces < 64) {
|
||||
return
|
||||
}
|
||||
|
||||
val e = widthPieces + heightPieces + widthPieces * heightPieces
|
||||
|
||||
if (dstData[5].length != e || srcData[5].length != e) {
|
||||
return
|
||||
}
|
||||
|
||||
val srcTnp = decodePieceData(srcData[5])
|
||||
val dstTnp = decodePieceData(dstData[5])
|
||||
|
||||
hDstPosLookup = dstTnp.hPos
|
||||
wDstPosLookup = dstTnp.wPos
|
||||
hPosLookup = srcTnp.hPos
|
||||
wPosLookup = srcTnp.wPos
|
||||
pieceDest = buildList(widthPieces * heightPieces) {
|
||||
for (i in 0 until widthPieces * heightPieces) {
|
||||
add(dstTnp.pieces[srcTnp.pieces[i]])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun isScrambled() =
|
||||
pieceDest != null
|
||||
|
||||
override fun canDescramble(): Boolean {
|
||||
val i = 2 * widthPieces * piecePadding
|
||||
val n = 2 * heightPieces * piecePadding
|
||||
|
||||
return width >= 64 + i && height >= 64 + n && width * height >= (320 + i) * (320 + n)
|
||||
}
|
||||
|
||||
override fun getCanvasDimensions(): Pair<Int, Int> {
|
||||
return if (canDescramble()) {
|
||||
Pair(
|
||||
width - 2 * widthPieces * piecePadding,
|
||||
height - 2 * heightPieces * piecePadding,
|
||||
)
|
||||
} else {
|
||||
Pair(width, height)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getDescrambleCoords(): List<PtImgTranslation> {
|
||||
val pieceDest = this.pieceDest
|
||||
|
||||
if (!isScrambled() || pieceDest == null) {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
if (!canDescramble()) {
|
||||
return listOf(
|
||||
PtImgTranslation(0, 0, width, height, 0, 0),
|
||||
)
|
||||
}
|
||||
|
||||
val canvasWidth = width - 2 * widthPieces * piecePadding
|
||||
val canvasHeight = height - 2 * heightPieces * piecePadding
|
||||
val pieceWidth = (canvasWidth + widthPieces - 1).div(widthPieces)
|
||||
val remainderWidth = canvasWidth - (widthPieces - 1) * pieceWidth
|
||||
val pieceHeight = (canvasHeight + heightPieces - 1).div(heightPieces)
|
||||
val remainderHeight = canvasHeight - (heightPieces - 1) * pieceHeight
|
||||
|
||||
return buildList(widthPieces * heightPieces) {
|
||||
for (o in 0 until widthPieces * heightPieces) {
|
||||
val hPos = o % widthPieces
|
||||
val wPos = o.div(widthPieces)
|
||||
val hDstPos = pieceDest[o] % widthPieces
|
||||
val wDstPos = pieceDest[o].div(widthPieces)
|
||||
|
||||
add(
|
||||
PtImgTranslation(
|
||||
xsrc = piecePadding + hPos * (pieceWidth + 2 * piecePadding) + if (hPosLookup[wPos] < hPos) remainderWidth - pieceWidth else 0,
|
||||
ysrc = piecePadding + wPos * (pieceHeight + 2 * piecePadding) + if (wPosLookup[hPos] < wPos) remainderHeight - pieceHeight else 0,
|
||||
width = if (hPosLookup[wPos] == hPos) remainderWidth else pieceWidth,
|
||||
height = if (wPosLookup[hPos] == wPos) remainderHeight else pieceHeight,
|
||||
xdest = hDstPos * pieceWidth + if (hDstPosLookup[wDstPos] < hDstPos) remainderWidth - pieceWidth else 0,
|
||||
ydest = wDstPos * pieceHeight + if (wDstPosLookup[hDstPos] < wDstPos) remainderHeight - pieceHeight else 0,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun decodePieceData(key: String): TNP {
|
||||
val wPos = buildList(widthPieces) {
|
||||
for (i in 0 until widthPieces) {
|
||||
add(PTBINBF_CHAR_LOOKUP.indexOf(key[i]))
|
||||
}
|
||||
}
|
||||
val hPos = buildList(heightPieces) {
|
||||
for (i in 0 until heightPieces) {
|
||||
add(PTBINBF_CHAR_LOOKUP.indexOf(key[widthPieces + i]))
|
||||
}
|
||||
}
|
||||
val pieces = buildList(widthPieces * heightPieces) {
|
||||
for (i in 0 until widthPieces * heightPieces) {
|
||||
add(PTBINBF_CHAR_LOOKUP.indexOf(key[widthPieces + heightPieces + i]))
|
||||
}
|
||||
}
|
||||
|
||||
return TNP(wPos, hPos, pieces)
|
||||
}
|
||||
|
||||
private class TNP(val wPos: List<Int>, val hPos: List<Int>, val pieces: List<Int>)
|
||||
}
|
||||
|
||||
class PtBinbDescramblerA(s: String, u: String, width: Int, height: Int) : PtBinbDescrambler(s, u, width, height) {
|
||||
|
||||
private var srcPieces: PieceCollection? = null
|
||||
|
||||
private var dstPieces: PieceCollection? = null
|
||||
|
||||
init {
|
||||
val srcPieces = calculatePieces(u)
|
||||
val dstPieces = calculatePieces(s)
|
||||
|
||||
if (
|
||||
srcPieces != null &&
|
||||
dstPieces != null &&
|
||||
srcPieces.ndx == dstPieces.ndx &&
|
||||
srcPieces.ndy == dstPieces.ndy
|
||||
) {
|
||||
this.srcPieces = srcPieces
|
||||
this.dstPieces = dstPieces
|
||||
}
|
||||
}
|
||||
|
||||
override fun isScrambled() =
|
||||
srcPieces != null && dstPieces != null
|
||||
|
||||
override fun canDescramble(): Boolean =
|
||||
width >= 64 && height >= 64 && width * height >= 102400
|
||||
|
||||
override fun getCanvasDimensions(): Pair<Int, Int> =
|
||||
Pair(width, height)
|
||||
|
||||
override fun getDescrambleCoords(): List<PtImgTranslation> {
|
||||
if (!isScrambled()) {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
if (!canDescramble()) {
|
||||
return listOf(
|
||||
PtImgTranslation(0, 0, width, height, 0, 0),
|
||||
)
|
||||
}
|
||||
|
||||
val srcPieces = this.srcPieces!!
|
||||
val dstPieces = this.dstPieces!!
|
||||
|
||||
return buildList(srcPieces.piece.size + 2) {
|
||||
val n = width - width % 8
|
||||
val pieceWidth = (n - 1).div(7) - (n - 1).div(7) % 8
|
||||
val e = n - 7 * pieceWidth
|
||||
val s = height - height % 8
|
||||
val pieceHeight = (s - 1).div(7) - (s - 1).div(7) % 8
|
||||
val u = s - 7 * pieceHeight
|
||||
|
||||
for (i in srcPieces.piece.indices) {
|
||||
val src = srcPieces.piece[i]
|
||||
val dst = dstPieces.piece[i]
|
||||
|
||||
add(
|
||||
PtImgTranslation(
|
||||
xsrc = src.x.div(2) * pieceWidth + src.x % 2 * e,
|
||||
ysrc = src.y.div(2) * pieceHeight + src.y % 2 * u,
|
||||
width = src.w.div(2) * pieceWidth + src.w % 2 * e,
|
||||
height = src.h.div(2) * pieceHeight + src.h % 2 * u,
|
||||
xdest = dst.x.div(2) * pieceWidth + dst.x % 2 * e,
|
||||
ydest = dst.y.div(2) * pieceHeight + dst.y % 2 * u,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
val l = pieceWidth * (srcPieces.ndx - 1) + e
|
||||
val v = pieceHeight * (srcPieces.ndy - 1) + u
|
||||
|
||||
if (l < width) {
|
||||
add(
|
||||
PtImgTranslation(l, 0, width - l, v, l, 0),
|
||||
)
|
||||
}
|
||||
|
||||
if (v < height) {
|
||||
add(
|
||||
PtImgTranslation(0, v, width, height - v, 0, v),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun calculatePieces(key: String): PieceCollection? {
|
||||
if (key.isEmpty()) {
|
||||
return null
|
||||
}
|
||||
|
||||
val parts = key.split("-")
|
||||
|
||||
if (parts.size != 3) {
|
||||
return null
|
||||
}
|
||||
|
||||
val ndx = parts[0].toInt()
|
||||
val ndy = parts[1].toInt()
|
||||
val e = parts[2]
|
||||
|
||||
if (ndx * ndy * 2 != e.length) {
|
||||
return null
|
||||
}
|
||||
|
||||
val pieces = buildList(ndx * ndy) {
|
||||
val a = (ndx - 1) * (ndy - 1) - 1
|
||||
val f = ndx - 1 + a
|
||||
val c = ndy - 1 + f
|
||||
val l = 1 + c
|
||||
var w = 0
|
||||
var h = 0
|
||||
|
||||
for (d in 0 until ndx * ndy) {
|
||||
val x = PTBINBA_CHAR_LOOKUP.indexOf(e[2 * d])
|
||||
val y = PTBINBA_CHAR_LOOKUP.indexOf(e[2 * d + 1])
|
||||
|
||||
if (d <= a) {
|
||||
h = 2
|
||||
w = 2
|
||||
} else if (d <= f) {
|
||||
h = 1
|
||||
w = 2
|
||||
} else if (d <= c) {
|
||||
h = 2
|
||||
w = 1
|
||||
} else if (d <= l) {
|
||||
h = 1
|
||||
w = 1
|
||||
}
|
||||
|
||||
add(Piece(x, y, w, h))
|
||||
}
|
||||
}
|
||||
|
||||
return PieceCollection(ndx, ndy, pieces)
|
||||
}
|
||||
|
||||
private class Piece(val x: Int, val y: Int, val w: Int, val h: Int)
|
||||
|
||||
private class PieceCollection(val ndx: Int, val ndy: Int, val piece: List<Piece>)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package eu.kanade.tachiyomi.lib.speedbinb.descrambler
|
||||
|
||||
import eu.kanade.tachiyomi.lib.speedbinb.PtImg
|
||||
|
||||
class PtImgDescrambler(private val metadata: PtImg) : SpeedBinbDescrambler() {
|
||||
override fun isScrambled() = metadata.translations.isNotEmpty()
|
||||
|
||||
override fun canDescramble() = metadata.translations.isNotEmpty()
|
||||
|
||||
override fun getCanvasDimensions() = Pair(metadata.views[0].width, metadata.views[0].height)
|
||||
|
||||
override fun getDescrambleCoords() = metadata.translations
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package eu.kanade.tachiyomi.lib.speedbinb.descrambler
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Rect
|
||||
import eu.kanade.tachiyomi.lib.speedbinb.PtImgTranslation
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
abstract class SpeedBinbDescrambler {
|
||||
abstract fun isScrambled(): Boolean
|
||||
abstract fun canDescramble(): Boolean
|
||||
abstract fun getCanvasDimensions(): Pair<Int, Int>
|
||||
abstract fun getDescrambleCoords(): List<PtImgTranslation>
|
||||
|
||||
open fun descrambleImage(image: Bitmap): ByteArray? {
|
||||
if (!isScrambled()) {
|
||||
return null
|
||||
}
|
||||
|
||||
val (width, height) = getCanvasDimensions()
|
||||
val result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
|
||||
val canvas = Canvas(result)
|
||||
|
||||
getDescrambleCoords().forEach {
|
||||
val src = Rect(it.xsrc, it.ysrc, it.xsrc + it.width, it.ysrc + it.height)
|
||||
val dst = Rect(it.xdest, it.ydest, it.xdest + it.width, it.ydest + it.height)
|
||||
|
||||
canvas.drawBitmap(image, src, dst, null)
|
||||
}
|
||||
|
||||
return ByteArrayOutputStream()
|
||||
.also {
|
||||
result.compress(Bitmap.CompressFormat.JPEG, 90, it)
|
||||
}
|
||||
.toByteArray()
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,3 @@
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
kotlin("android")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = AndroidConfig.compileSdk
|
||||
|
||||
defaultConfig {
|
||||
minSdk = AndroidConfig.minSdk
|
||||
}
|
||||
|
||||
namespace = "eu.kanade.tachiyomi.lib.synchrony"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.bundles.common)
|
||||
id("lib-android")
|
||||
}
|
||||
|
||||
117
lib/synchrony/src/main/assets/synchrony-v2.4.5.1.js
Normal file
@@ -39,4 +39,4 @@ object Deobfuscator {
|
||||
}
|
||||
|
||||
// Update this when the script is updated!
|
||||
private const val SCRIPT_NAME = "synchrony-v2.4.2.1.js"
|
||||
private const val SCRIPT_NAME = "synchrony-v2.4.5.1.js"
|
||||
|
||||
@@ -1,23 +1,3 @@
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
kotlin("android")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = AndroidConfig.compileSdk
|
||||
|
||||
defaultConfig {
|
||||
minSdk = AndroidConfig.minSdk
|
||||
}
|
||||
|
||||
namespace = "eu.kanade.tachiyomi.lib.textinterceptor"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.kotlin.stdlib)
|
||||
compileOnly(libs.okhttp)
|
||||
id("lib-android")
|
||||
}
|
||||
|
||||
@@ -18,32 +18,29 @@ import okhttp3.Response
|
||||
import okhttp3.ResponseBody.Companion.toResponseBody
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
// Designer values:
|
||||
private const val WIDTH: Int = 1000
|
||||
private const val X_PADDING: Float = 50f
|
||||
private const val Y_PADDING: Float = 25f
|
||||
private const val HEADING_FONT_SIZE: Float = 36f
|
||||
private const val BODY_FONT_SIZE: Float = 30f
|
||||
private const val SPACING_MULT: Float = 1.1f
|
||||
private const val SPACING_ADD: Float = 2f
|
||||
|
||||
// No need to touch this one:
|
||||
private const val HOST = TextInterceptorHelper.HOST
|
||||
|
||||
class TextInterceptor : Interceptor {
|
||||
// With help from:
|
||||
// https://github.com/tachiyomiorg/tachiyomi-extensions/pull/13304#issuecomment-1234532897
|
||||
// https://medium.com/over-engineering/drawing-multiline-text-to-canvas-on-android-9b98f0bfa16a
|
||||
|
||||
companion object {
|
||||
// Designer values:
|
||||
private const val WIDTH: Int = 1000
|
||||
private const val X_PADDING: Float = 50f
|
||||
private const val Y_PADDING: Float = 25f
|
||||
private const val HEADING_FONT_SIZE: Float = 36f
|
||||
private const val BODY_FONT_SIZE: Float = 30f
|
||||
private const val SPACING_MULT: Float = 1.1f
|
||||
private const val SPACING_ADD: Float = 2f
|
||||
|
||||
// No need to touch this one:
|
||||
private const val HOST = TextInterceptorHelper.HOST
|
||||
}
|
||||
|
||||
override fun intercept(chain: Interceptor.Chain): Response {
|
||||
val request = chain.request()
|
||||
val url = request.url
|
||||
if (url.host != HOST) return chain.proceed(request)
|
||||
|
||||
val creator = textFixer("Author's Notes from ${url.pathSegments[0]}")
|
||||
val story = textFixer(url.pathSegments[1])
|
||||
val heading = url.pathSegments[0].takeIf { it.isNotEmpty() }?.let {
|
||||
val title = textFixer(url.pathSegments[0])
|
||||
|
||||
// Heading
|
||||
val paintHeading = TextPaint().apply {
|
||||
@@ -54,10 +51,14 @@ class TextInterceptor : Interceptor {
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
val heading = StaticLayout(
|
||||
creator, paintHeading, (WIDTH - 2 * X_PADDING).toInt(),
|
||||
StaticLayout(
|
||||
title, paintHeading, (WIDTH - 2 * X_PADDING).toInt(),
|
||||
Layout.Alignment.ALIGN_NORMAL, SPACING_MULT, SPACING_ADD, true
|
||||
)
|
||||
}
|
||||
|
||||
val body = url.pathSegments[1].takeIf { it.isNotEmpty() }?.let {
|
||||
val story = textFixer(it)
|
||||
|
||||
// Body
|
||||
val paintBody = TextPaint().apply {
|
||||
@@ -68,19 +69,22 @@ class TextInterceptor : Interceptor {
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
val body = StaticLayout(
|
||||
StaticLayout(
|
||||
story, paintBody, (WIDTH - 2 * X_PADDING).toInt(),
|
||||
Layout.Alignment.ALIGN_NORMAL, SPACING_MULT, SPACING_ADD, true
|
||||
)
|
||||
}
|
||||
|
||||
// Image building
|
||||
val imgHeight: Int = (heading.height + body.height + 2 * Y_PADDING).toInt()
|
||||
val headingHeight = heading?.height ?: 0
|
||||
val bodyHeight = body?.height ?: 0
|
||||
val imgHeight: Int = (headingHeight + bodyHeight + 2 * Y_PADDING).toInt()
|
||||
val bitmap: Bitmap = Bitmap.createBitmap(WIDTH, imgHeight, Bitmap.Config.ARGB_8888)
|
||||
|
||||
Canvas(bitmap).apply {
|
||||
drawColor(Color.WHITE)
|
||||
heading.draw(this, X_PADDING, Y_PADDING)
|
||||
body.draw(this, X_PADDING, Y_PADDING + heading.height.toFloat())
|
||||
heading?.draw(this, X_PADDING, Y_PADDING)
|
||||
body?.draw(this, X_PADDING, Y_PADDING + headingHeight.toFloat())
|
||||
}
|
||||
|
||||
// Image converting & returning
|
||||
@@ -119,7 +123,7 @@ object TextInterceptorHelper {
|
||||
|
||||
const val HOST = "tachiyomi-lib-textinterceptor"
|
||||
|
||||
fun createUrl(creator: String, text: String): String {
|
||||
return "http://$HOST/" + Uri.encode(creator) + "/" + Uri.encode(text)
|
||||
fun createUrl(title: String, text: String): String {
|
||||
return "http://$HOST/" + Uri.encode(title) + "/" + Uri.encode(text)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
kotlin("jvm")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.kotlin.stdlib)
|
||||
id("lib-android")
|
||||
}
|
||||
|
||||
7
lib/zipinterceptor/build.gradle.kts
Normal file
@@ -0,0 +1,7 @@
|
||||
plugins {
|
||||
id("lib-android")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.github.tachiyomiorg:image-decoder:e08e9be535")
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
package eu.kanade.tachiyomi.lib.zipinterceptor
|
||||
|
||||
import android.app.ActivityManager
|
||||
import android.app.Application
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Rect
|
||||
import android.util.Base64
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import okhttp3.ResponseBody.Companion.toResponseBody
|
||||
import tachiyomi.decoder.ImageDecoder
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.lang.reflect.Method
|
||||
import java.util.zip.ZipInputStream
|
||||
|
||||
object ImageDecoderWrapper {
|
||||
private var decodeMethod: Method
|
||||
private var newInstanceMethod: Method
|
||||
private var classSignature = ClassSignature.Newest
|
||||
|
||||
private enum class ClassSignature {
|
||||
Old, New, Newest
|
||||
}
|
||||
|
||||
init {
|
||||
val rectClass = Rect::class.java
|
||||
val booleanClass = Boolean::class.java
|
||||
val intClass = Int::class.java
|
||||
val byteArrayClass = ByteArray::class.java
|
||||
val inputStreamClass = InputStream::class.java
|
||||
|
||||
try {
|
||||
classSignature = ClassSignature.Newest
|
||||
|
||||
// decode(region, sampleSize)
|
||||
decodeMethod = ImageDecoder::class.java.getMethod(
|
||||
"decode",
|
||||
rectClass,
|
||||
intClass,
|
||||
)
|
||||
|
||||
// newInstance(stream, cropBorders, displayProfile)
|
||||
newInstanceMethod = ImageDecoder.Companion::class.java.getMethod(
|
||||
"newInstance",
|
||||
inputStreamClass,
|
||||
booleanClass,
|
||||
byteArrayClass,
|
||||
)
|
||||
} catch (_: NoSuchMethodException) {
|
||||
try {
|
||||
classSignature = ClassSignature.New
|
||||
|
||||
// decode(region, rgb565, sampleSize, applyColorManagement, displayProfile)
|
||||
decodeMethod = ImageDecoder::class.java.getMethod(
|
||||
"decode",
|
||||
rectClass,
|
||||
booleanClass,
|
||||
intClass,
|
||||
booleanClass,
|
||||
byteArrayClass,
|
||||
)
|
||||
|
||||
// newInstance(stream, cropBorders)
|
||||
newInstanceMethod = ImageDecoder.Companion::class.java.getMethod(
|
||||
"newInstance",
|
||||
inputStreamClass,
|
||||
booleanClass,
|
||||
)
|
||||
} catch (_: NoSuchMethodException) {
|
||||
classSignature = ClassSignature.Old
|
||||
|
||||
// decode(region, rgb565, sampleSize)
|
||||
decodeMethod =
|
||||
ImageDecoder::class.java.getMethod(
|
||||
"decode",
|
||||
rectClass,
|
||||
booleanClass,
|
||||
intClass,
|
||||
)
|
||||
|
||||
// newInstance(stream, cropBorders)
|
||||
newInstanceMethod = ImageDecoder.Companion::class.java.getMethod(
|
||||
"newInstance",
|
||||
inputStreamClass,
|
||||
booleanClass,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun decodeImage(data: ByteArray, rgb565: Boolean, filename: String, entryName: String): Bitmap {
|
||||
val decoder = when (classSignature) {
|
||||
ClassSignature.Newest -> newInstanceMethod.invoke(ImageDecoder.Companion, ByteArrayInputStream(data), false, null)
|
||||
else -> newInstanceMethod.invoke(ImageDecoder.Companion, ByteArrayInputStream(data), false)
|
||||
} as ImageDecoder?
|
||||
|
||||
if (decoder == null || decoder.width <= 0 || decoder.height <= 0) {
|
||||
throw IOException("Falha ao inicializar o decodificador de imagem")
|
||||
}
|
||||
|
||||
val rect = Rect(0, 0, decoder.width, decoder.height)
|
||||
val bitmap = when (classSignature) {
|
||||
ClassSignature.Newest -> decodeMethod.invoke(decoder, rect, 1)
|
||||
ClassSignature.New -> decodeMethod.invoke(decoder, rect, rgb565, 1, false, null)
|
||||
else -> decodeMethod.invoke(decoder, rect, rgb565, 1)
|
||||
} as Bitmap?
|
||||
|
||||
decoder.recycle()
|
||||
|
||||
if (bitmap == null) {
|
||||
throw IOException("Não foi possível decodificar a imagem $filename#$entryName")
|
||||
}
|
||||
|
||||
return bitmap
|
||||
}
|
||||
}
|
||||
|
||||
open class ZipInterceptor {
|
||||
private val dataUriRegex = Regex("""base64,([0-9a-zA-Z/+=\s]+)""")
|
||||
|
||||
open fun zipGetByteStream(request: Request, response: Response): InputStream {
|
||||
return response.body.byteStream()
|
||||
}
|
||||
|
||||
open fun requestIsZipImage(request: Request): Boolean {
|
||||
return request.url.fragment == "page" && request.url.pathSegments.last().contains(".zip")
|
||||
}
|
||||
|
||||
fun zipImageInterceptor(chain: Interceptor.Chain): Response {
|
||||
val request = chain.request()
|
||||
val response = chain.proceed(request)
|
||||
val filename = request.url.pathSegments.last()
|
||||
|
||||
if (requestIsZipImage(request).not()) {
|
||||
return response
|
||||
}
|
||||
|
||||
val zis = ZipInputStream(zipGetByteStream(request, response))
|
||||
|
||||
val images = generateSequence { zis.nextEntry }
|
||||
.mapNotNull {
|
||||
val entryName = it.name
|
||||
val splitEntryName = entryName.split('.')
|
||||
val entryIndex = splitEntryName.first().toInt()
|
||||
val entryType = splitEntryName.last()
|
||||
|
||||
val imageData = if (entryType == "avif" || splitEntryName.size == 1) {
|
||||
zis.readBytes()
|
||||
} else {
|
||||
val svgBytes = zis.readBytes()
|
||||
val svgContent = svgBytes.toString(Charsets.UTF_8)
|
||||
val b64 = dataUriRegex.find(svgContent)?.groupValues?.get(1)
|
||||
?: return@mapNotNull null
|
||||
|
||||
Base64.decode(b64, Base64.DEFAULT)
|
||||
}
|
||||
|
||||
entryIndex to ImageDecoderWrapper.decodeImage(imageData, isLowRamDevice, filename, entryName)
|
||||
}
|
||||
.sortedBy { it.first }
|
||||
.toList()
|
||||
|
||||
zis.closeEntry()
|
||||
zis.close()
|
||||
|
||||
val totalWidth = images.maxOf { it.second.width }
|
||||
val totalHeight = images.sumOf { it.second.height }
|
||||
|
||||
val result = Bitmap.createBitmap(totalWidth, totalHeight, Bitmap.Config.ARGB_8888)
|
||||
val canvas = Canvas(result)
|
||||
|
||||
var dy = 0
|
||||
|
||||
images.forEach {
|
||||
val srcRect = Rect(0, 0, it.second.width, it.second.height)
|
||||
val dstRect = Rect(0, dy, it.second.width, dy + it.second.height)
|
||||
|
||||
canvas.drawBitmap(it.second, srcRect, dstRect, null)
|
||||
|
||||
dy += it.second.height
|
||||
}
|
||||
|
||||
val output = ByteArrayOutputStream()
|
||||
result.compress(Bitmap.CompressFormat.JPEG, 90, output)
|
||||
|
||||
val image = output.toByteArray()
|
||||
val body = image.toResponseBody("image/jpeg".toMediaType())
|
||||
|
||||
return response.newBuilder()
|
||||
.body(body)
|
||||
.build()
|
||||
}
|
||||
|
||||
/**
|
||||
* ActivityManager#isLowRamDevice is based on a system property, which isn't
|
||||
* necessarily trustworthy. 1GB is supposedly the regular threshold.
|
||||
*
|
||||
* Instead, we consider anything with less than 3GB of RAM as low memory
|
||||
* considering how heavy image processing can be.
|
||||
*/
|
||||
private val isLowRamDevice by lazy {
|
||||
val ctx = Injekt.get<Application>()
|
||||
val activityManager = ctx.getSystemService("activity") as ActivityManager
|
||||
val memInfo = ActivityManager.MemoryInfo()
|
||||
|
||||
activityManager.getMemoryInfo(memInfo)
|
||||
|
||||
memInfo.totalMem < 3L * 1024 * 1024 * 1024
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
kotlin("android")
|
||||
id("kotlinx-serialization")
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = AndroidConfig.compileSdk
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 29
|
||||
}
|
||||
|
||||
namespace = "eu.kanade.tachiyomi.lib.themesources"
|
||||
|
||||
kotlinOptions {
|
||||
freeCompilerArgs += "-opt-in=kotlinx.serialization.ExperimentalSerializationApi"
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
configurations {
|
||||
compileOnly {
|
||||
isCanBeResolved = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(libs.bundles.common)
|
||||
|
||||
// Implements all :lib libraries on the multisrc generator
|
||||
// Note that this does not mean that generated sources are going to
|
||||
// implement them too; this is just to be able to compile and generate sources.
|
||||
rootProject.subprojects
|
||||
.filter { it.path.startsWith(":lib") }
|
||||
.forEach(::implementation)
|
||||
}
|
||||
|
||||
tasks {
|
||||
register<JavaExec>("generateExtensions") {
|
||||
val buildDir = layout.buildDirectory.asFile.get()
|
||||
classpath = configurations.compileOnly.get() +
|
||||
configurations.androidApis.get() + // android.jar path
|
||||
files("$buildDir/intermediates/aar_main_jar/debug/classes.jar") // jar made from this module
|
||||
mainClass.set("generator.GeneratorMainKt")
|
||||
|
||||
workingDir = workingDir.parentFile // project root
|
||||
|
||||
errorOutput = System.out // for GitHub workflow commands
|
||||
|
||||
if (!logger.isInfoEnabled) {
|
||||
standardOutput = org.gradle.internal.io.NullOutputStream.INSTANCE
|
||||
}
|
||||
|
||||
dependsOn("ktLint", "assembleDebug")
|
||||
}
|
||||
|
||||
register<org.jmailen.gradle.kotlinter.tasks.LintTask>("ktLint") {
|
||||
if (project.hasProperty("theme")) {
|
||||
val theme = project.property("theme")
|
||||
source(files("src/main/java/eu/kanade/tachiyomi/multisrc/$theme", "overrides/$theme"))
|
||||
return@register
|
||||
}
|
||||
source(files("src", "overrides"))
|
||||
}
|
||||
|
||||
register<org.jmailen.gradle.kotlinter.tasks.FormatTask>("ktFormat") {
|
||||
if (project.hasProperty("theme")) {
|
||||
val theme = project.property("theme")
|
||||
source(files("src/main/java/eu/kanade/tachiyomi/multisrc/$theme", "overrides/$theme"))
|
||||
return@register
|
||||
}
|
||||
source(files("src", "overrides"))
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 34 KiB |
@@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<application>
|
||||
<activity
|
||||
android:name="eu.kanade.tachiyomi.multisrc.a3manga.A3MangaUrlActivity"
|
||||
android:excludeFromRecents="true"
|
||||
android:exported="true"
|
||||
android:theme="@android:style/Theme.NoDisplay">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:host="${SOURCEHOST}" />
|
||||
<data android:host="*.${SOURCEHOST}" />
|
||||
<data android:pathPattern="/truyen-tranh/..*"
|
||||
android:scheme="${SOURCESCHEME}" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 50 KiB |
@@ -1,7 +0,0 @@
|
||||
package eu.kanade.tachiyomi.extension.vi.ngonphong
|
||||
|
||||
import eu.kanade.tachiyomi.multisrc.a3manga.A3Manga
|
||||
|
||||
class NgonPhong : A3Manga("Ngôn Phong", "https://www.ngonphong.com", "vi") {
|
||||
override val id: Long = 7268977637085631557
|
||||
}
|
||||
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 18 KiB |