Commit ec799bb
fix: allanime aareq runtime fetch (#333)
* fix: fetch AllAnime aaReq crypto values at runtime
AllAnime rotates the epoch and the encryption secrets used to sign the aaReq
token every few days. With those values hardcoded, episode sources stop
resolving after each rotation and playback fails.
Fetch the current values at runtime instead: epoch and partB come from
window.__aaCrypto on the mkissa frontend, and the key mask is the lone hex
constant in the app chunk it statically imports. The result is cached for the
epoch window and falls back to the last known good hardcoded values when the
fetch fails, so playback keeps working even if the site is unreachable.
* feat: report AllAnime aaReq crypto refresh through an info callback
Add an optional info_callback to BaseProvider and get_provider, mirroring the
callback the Downloader already uses. The AllAnime provider calls it to report
whether it fetched fresh crypto values or fell back to the hardcoded ones,
including the active epoch and the first bytes of the fetched hash.
Wire the CLI to pass logger.info as this callback wherever it builds a provider
(get_prefered_providers and the MAL and AniList proxies), so the messages
surface at -V verbosity and in the log file.
* refactor: extract AllAnime aaReq crypto into its own class
Move the runtime aaReq crypto (fetching and caching the rotating values, token
generation, tobeparsed decryption and the last known good fallback values) out
of the provider module and into a dedicated AllAnimeCrypto class in its own
file. The provider builds it in its constructor and delegates to it, so the
crypto lives in one place instead of module level state and loose functions
scattered through the provider.
No behaviour change: episode sources and the -V info logging work exactly as
before.
* feat: fetch the AllAnime source query hash and drop the unused buildId
The two remaining hardcoded aaReq values are no longer pinned:
- The persisted-query hash is now derived at runtime. The source query is
assembled from its template and fragments in the app chunk (the same chunk
the mask comes from) and sha256'd, falling back to the last known good hash
if the template cannot be fully resolved.
- buildId is dropped entirely. The api does not check it, it only exists
obfuscated in the chunk, and the source request is accepted without it, so
the payload and iv no longer carry it.
* misc: merge allanime crypto into provider
* version: bump
---------
Co-authored-by: sdaqo <sdaqo.dev@protonmail.com>1 parent 4734076 commit ec799bb
10 files changed
Lines changed: 239 additions & 71 deletions
File tree
- api
- src/anipy_api
- provider
- providers
- cli
- src/anipy_cli
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
108 | 120 | | |
109 | 121 | | |
110 | 122 | | |
| |||
125 | 137 | | |
126 | 138 | | |
127 | 139 | | |
128 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
129 | 145 | | |
130 | 146 | | |
131 | 147 | | |
132 | 148 | | |
| 149 | + | |
| 150 | + | |
133 | 151 | | |
134 | 152 | | |
135 | 153 | | |
136 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
137 | 158 | | |
138 | 159 | | |
139 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
41 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| 51 | + | |
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
54 | | - | |
| 58 | + | |
0 commit comments