[skip bumping version] FilmiFen [BG]: Create the series URL cache lazily; run the inspector on fork PRs (#1105)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
7heMech
2026-10-08 16:27:38 +03:00
committed by GitHub
parent b3032099c6
commit ea687f617a
5 changed files with 25 additions and 8 deletions

View File

@@ -159,7 +159,8 @@ jobs:
publish:
name: Check extension repo
needs: [prepare, build]
if: github.repository == github.event.pull_request.head.repo.full_name
# Matches the APK upload condition, so fork PRs also run the inspector
if: "github.repository == 'yuzono/anime-extensions'"
runs-on: 'ubuntu-26.04'
steps:
- name: Download APK artifacts
@@ -180,13 +181,19 @@ jobs:
fetch-depth: 0
persist-credentials: false
# Authenticated, so the lookup isn't subject to the shared runner IP's anonymous rate limit
- name: Download extensions inspector
env:
GH_TOKEN: ${{ github.token }}
run: |
INSPECTOR_LINK="$(curl -fsS --retry 3 -H "Authorization: Bearer $GH_TOKEN" "https://api.github.com/repos/komikku-app/aniyomi-extensions-inspector/releases/latest" | jq -er '.assets[0].browser_download_url')"
curl -fL --retry 3 "$INSPECTOR_LINK" -o "$RUNNER_TEMP/Inspector.jar"
- name: Create repo artifacts
run: |
cd PR
python ./.github/scripts/move-built-apks.py
INSPECTOR_LINK="$(curl -s "https://api.github.com/repos/komikku-app/aniyomi-extensions-inspector/releases/latest" | jq -r '.assets[0].browser_download_url')"
curl -L "$INSPECTOR_LINK" -o ./Inspector.jar
java -jar ./Inspector.jar "repo/apk" "output.json" "tmp"
java -jar "$RUNNER_TEMP/Inspector.jar" "repo/apk" "output.json" "tmp"
python ./.github/scripts/create-repo.py
- name: Checkout repo branch

View File

@@ -203,13 +203,19 @@ jobs:
fetch-depth: 0
persist-credentials: false
# Authenticated, so the lookup isn't subject to the shared runner IP's anonymous rate limit
- name: Download extensions inspector
env:
GH_TOKEN: ${{ github.token }}
run: |
INSPECTOR_LINK="$(curl -fsS --retry 3 -H "Authorization: Bearer $GH_TOKEN" "https://api.github.com/repos/komikku-app/aniyomi-extensions-inspector/releases/latest" | jq -er '.assets[0].browser_download_url')"
curl -fL --retry 3 "$INSPECTOR_LINK" -o "$RUNNER_TEMP/Inspector.jar"
- name: Create repo artifacts
run: |
cd ${{ github.ref_name }}
python ./.github/scripts/move-built-apks.py
INSPECTOR_LINK="$(curl -s "https://api.github.com/repos/komikku-app/aniyomi-extensions-inspector/releases/latest" | jq -r '.assets[0].browser_download_url')"
curl -L "$INSPECTOR_LINK" -o ./Inspector.jar
java -jar ./Inspector.jar "repo/apk" "output.json" "tmp"
java -jar "$RUNNER_TEMP/Inspector.jar" "repo/apk" "output.json" "tmp"
python ./.github/scripts/create-repo.py
- name: Checkout repo branch

View File

@@ -86,6 +86,9 @@ See `CONTRIBUTING.md` for full rules. Critical for agents:
`by lazy` keeps serving the stale client. See `lib-multisrc/anikototheme/.../AnikotoTheme.kt`.
- Do not eagerly initialize `client` in a theme base class: the initializer runs before subclass
constructors, so an overridden `open val rateLimit` reads `0`.
- Do not create `android.*` objects (e.g. `LruCache`) in a source's constructor or property
initializers – use `by lazy`. The repo publisher instantiates sources on a plain JVM where they
throw `Stub!`, which blocks the publish for every extension. See `CONTRIBUTING.md#misc-notes`.
## Versioning – bump once per PR, theme bump propagates

View File

@@ -963,6 +963,7 @@ custom headers when the stream requires them. Don't use the deprecated positiona
videos in a legacy method, throw `UnsupportedOperationException()` instead of returning an empty
value. Also use this pattern for unused inherited methods.
- **Cache Regex instances:** Define `Regex` instances at the class level or in a `companion object` so they aren't recompiled on every method call.
- **Don't create Android classes when the source is constructed:** To publish the repo, CI instantiates every source on a plain JVM with the [extensions inspector](https://github.com/komikku-app/aniyomi-extensions-inspector). There, `android.*` classes are stubs that throw `RuntimeException: Stub!`. One extension that builds such a class (for example `android.util.LruCache`) in its constructor or in a property initializer stops the publish for every extension. Wrap those properties in `by lazy { ... }`. The PR check runs the same inspector.
- **Do not hardcode `User-Agent`:** Unless absolutely necessary (e.g., to bypass Cloudflare/protection, or to retrieve a specific mobile layout/different selectors), do not hardcode a specific `User-Agent`. Calling `super.headersBuilder()` already provides the app's default User-Agent.
- **Use `buildString { }`:** When building descriptions or dynamic strings, use Kotlin's `buildString { ... }` instead of manually instantiating a `StringBuilder()`.
- **Media Types:** `application/json` is intrinsically UTF-8. Avoid using `application/json; charset=utf-8`. Prefer helper functions like `toJsonRequestBody()` instead of manually specifying media types (e.g., `"application/json".toMediaType()`).

View File

@@ -44,7 +44,7 @@ class FilmiFen : AnimeHttpSource() {
override fun headersBuilder() = super.headersBuilder().add("Referer", "$baseUrl/")
private val seriesUrls = LruCache<String, String>(128)
private val seriesUrls by lazy { LruCache<String, String>(128) }
private val playlistUtils by lazy { PlaylistUtils(client, headers) }
private val okruExtractor by lazy { OkruExtractor(client, headers) }
private val voeExtractor by lazy { VoeExtractor(client, headers) }