react-native-consumet 4.0.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (359) hide show
  1. package/android/src/androidTest/java/com/consumet/TestSupport.kt +12 -6
  2. package/android/src/androidTest/java/com/consumet/WebViewContractTest.kt +30 -2
  3. package/android/src/main/java/com/consumet/HttpRequestModule.kt +27 -13
  4. package/ios/Consumet.mm +42 -19
  5. package/lib/commonjs/NativeConsumet.ts +13 -8
  6. package/lib/commonjs/extension-registry.json +35 -64
  7. package/lib/commonjs/extension-registry.json.sig +1 -1
  8. package/lib/commonjs/extractors/gofile.js +47 -10
  9. package/lib/commonjs/extractors/gofile.js.map +1 -1
  10. package/lib/commonjs/extractors/hubcloud.js +49 -42
  11. package/lib/commonjs/extractors/hubcloud.js.map +1 -1
  12. package/lib/commonjs/index.js +14 -0
  13. package/lib/commonjs/index.js.map +1 -1
  14. package/lib/commonjs/models/index.js +9 -1
  15. package/lib/commonjs/models/index.js.map +1 -1
  16. package/lib/commonjs/models/meta-error.js +6 -3
  17. package/lib/commonjs/models/meta-error.js.map +1 -1
  18. package/lib/commonjs/models/provider-error.js +54 -0
  19. package/lib/commonjs/models/provider-error.js.map +1 -0
  20. package/lib/commonjs/models/types.js +3 -2
  21. package/lib/commonjs/models/types.js.map +1 -1
  22. package/lib/commonjs/providers/anime/anikoto/create-anikoto.js +90 -25
  23. package/lib/commonjs/providers/anime/anikoto/create-anikoto.js.map +1 -1
  24. package/lib/commonjs/providers/anime/{hianime.js → anikoto/hianime.js} +4 -4
  25. package/lib/commonjs/providers/anime/anikoto/hianime.js.map +1 -0
  26. package/lib/commonjs/providers/anime/animepahe/create-animepahe.js +110 -18
  27. package/lib/commonjs/providers/anime/animepahe/create-animepahe.js.map +1 -1
  28. package/lib/commonjs/providers/anime/index.js +1 -9
  29. package/lib/commonjs/providers/anime/index.js.map +1 -1
  30. package/lib/commonjs/providers/anime/reanime/create-reanime.js +6 -2
  31. package/lib/commonjs/providers/anime/reanime/create-reanime.js.map +1 -1
  32. package/lib/commonjs/providers/common/concurrency.js +38 -0
  33. package/lib/commonjs/providers/common/concurrency.js.map +1 -0
  34. package/lib/commonjs/providers/common/errors.js +77 -0
  35. package/lib/commonjs/providers/common/errors.js.map +1 -0
  36. package/lib/commonjs/providers/common/servers.js +9 -3
  37. package/lib/commonjs/providers/common/servers.js.map +1 -1
  38. package/lib/commonjs/providers/common/ttl-cache.js +59 -0
  39. package/lib/commonjs/providers/common/ttl-cache.js.map +1 -0
  40. package/lib/commonjs/providers/manga/asurascans.js +29 -7
  41. package/lib/commonjs/providers/manga/asurascans.js.map +1 -1
  42. package/lib/commonjs/providers/meta/anilist-media.js +23 -13
  43. package/lib/commonjs/providers/meta/anilist-media.js.map +1 -1
  44. package/lib/commonjs/providers/meta/anilist.js +63 -18
  45. package/lib/commonjs/providers/meta/anilist.js.map +1 -1
  46. package/lib/commonjs/providers/meta/mal.js +3 -3
  47. package/lib/commonjs/providers/meta/mal.js.map +1 -1
  48. package/lib/commonjs/providers/meta/shared.js +7 -2
  49. package/lib/commonjs/providers/meta/shared.js.map +1 -1
  50. package/lib/commonjs/providers/meta/tmdb.js +151 -45
  51. package/lib/commonjs/providers/meta/tmdb.js.map +1 -1
  52. package/lib/commonjs/providers/movies/index.js +0 -4
  53. package/lib/commonjs/providers/movies/index.js.map +1 -1
  54. package/lib/commonjs/providers/movies/multimovies/create-multimovies.js +2 -1
  55. package/lib/commonjs/providers/movies/multimovies/create-multimovies.js.map +1 -1
  56. package/lib/commonjs/providers/movies/multistream/create-multistream.js +1 -1
  57. package/lib/commonjs/providers/movies/multistream/create-multistream.js.map +1 -1
  58. package/lib/commonjs/providers/movies/netflixmirror/create-netflixmirror.js +44 -11
  59. package/lib/commonjs/providers/movies/netflixmirror/create-netflixmirror.js.map +1 -1
  60. package/lib/commonjs/providers/movies/site-paths.js +3 -2
  61. package/lib/commonjs/providers/movies/site-paths.js.map +1 -1
  62. package/lib/commonjs/providers/movies/vegamovies/create-vegamovies.js +95 -44
  63. package/lib/commonjs/providers/movies/vegamovies/create-vegamovies.js.map +1 -1
  64. package/lib/commonjs/providers/provider-class.js +1 -1
  65. package/lib/commonjs/utils/ExtractorManager.js +90 -11
  66. package/lib/commonjs/utils/ExtractorManager.js.map +1 -1
  67. package/lib/commonjs/utils/ProviderManager.js +54 -18
  68. package/lib/commonjs/utils/ProviderManager.js.map +1 -1
  69. package/lib/commonjs/utils/extension-modules.js +136 -24
  70. package/lib/commonjs/utils/extension-modules.js.map +1 -1
  71. package/lib/commonjs/utils/registry-schema.js +3 -2
  72. package/lib/commonjs/utils/registry-schema.js.map +1 -1
  73. package/lib/commonjs/utils/tmdb.js +53 -8
  74. package/lib/commonjs/utils/tmdb.js.map +1 -1
  75. package/lib/module/NativeConsumet.ts +13 -8
  76. package/lib/module/extension-registry.json +35 -64
  77. package/lib/module/extension-registry.json.sig +1 -1
  78. package/lib/module/extractors/gofile.js +47 -10
  79. package/lib/module/extractors/gofile.js.map +1 -1
  80. package/lib/module/extractors/hubcloud.js +49 -42
  81. package/lib/module/extractors/hubcloud.js.map +1 -1
  82. package/lib/module/index.js +2 -2
  83. package/lib/module/index.js.map +1 -1
  84. package/lib/module/models/index.js +1 -0
  85. package/lib/module/models/index.js.map +1 -1
  86. package/lib/module/models/meta-error.js +7 -3
  87. package/lib/module/models/meta-error.js.map +1 -1
  88. package/lib/module/models/provider-error.js +49 -0
  89. package/lib/module/models/provider-error.js.map +1 -0
  90. package/lib/module/models/types.js +3 -2
  91. package/lib/module/models/types.js.map +1 -1
  92. package/lib/module/providers/anime/anikoto/create-anikoto.js +91 -25
  93. package/lib/module/providers/anime/anikoto/create-anikoto.js.map +1 -1
  94. package/lib/module/providers/anime/{hianime.js → anikoto/hianime.js} +4 -4
  95. package/lib/module/providers/anime/anikoto/hianime.js.map +1 -0
  96. package/lib/module/providers/anime/animepahe/create-animepahe.js +111 -18
  97. package/lib/module/providers/anime/animepahe/create-animepahe.js.map +1 -1
  98. package/lib/module/providers/anime/index.js +1 -9
  99. package/lib/module/providers/anime/index.js.map +1 -1
  100. package/lib/module/providers/anime/reanime/create-reanime.js +6 -2
  101. package/lib/module/providers/anime/reanime/create-reanime.js.map +1 -1
  102. package/lib/module/providers/common/concurrency.js +34 -0
  103. package/lib/module/providers/common/concurrency.js.map +1 -0
  104. package/lib/module/providers/common/errors.js +70 -0
  105. package/lib/module/providers/common/errors.js.map +1 -0
  106. package/lib/module/providers/common/servers.js +10 -3
  107. package/lib/module/providers/common/servers.js.map +1 -1
  108. package/lib/module/providers/common/ttl-cache.js +54 -0
  109. package/lib/module/providers/common/ttl-cache.js.map +1 -0
  110. package/lib/module/providers/manga/asurascans.js +29 -7
  111. package/lib/module/providers/manga/asurascans.js.map +1 -1
  112. package/lib/module/providers/meta/anilist-media.js +23 -13
  113. package/lib/module/providers/meta/anilist-media.js.map +1 -1
  114. package/lib/module/providers/meta/anilist.js +64 -19
  115. package/lib/module/providers/meta/anilist.js.map +1 -1
  116. package/lib/module/providers/meta/mal.js +3 -3
  117. package/lib/module/providers/meta/mal.js.map +1 -1
  118. package/lib/module/providers/meta/shared.js +8 -3
  119. package/lib/module/providers/meta/shared.js.map +1 -1
  120. package/lib/module/providers/meta/tmdb.js +153 -47
  121. package/lib/module/providers/meta/tmdb.js.map +1 -1
  122. package/lib/module/providers/movies/index.js +0 -4
  123. package/lib/module/providers/movies/index.js.map +1 -1
  124. package/lib/module/providers/movies/multimovies/create-multimovies.js +2 -1
  125. package/lib/module/providers/movies/multimovies/create-multimovies.js.map +1 -1
  126. package/lib/module/providers/movies/multistream/create-multistream.js +1 -1
  127. package/lib/module/providers/movies/multistream/create-multistream.js.map +1 -1
  128. package/lib/module/providers/movies/netflixmirror/create-netflixmirror.js +44 -11
  129. package/lib/module/providers/movies/netflixmirror/create-netflixmirror.js.map +1 -1
  130. package/lib/module/providers/movies/site-paths.js +3 -2
  131. package/lib/module/providers/movies/site-paths.js.map +1 -1
  132. package/lib/module/providers/movies/vegamovies/create-vegamovies.js +95 -44
  133. package/lib/module/providers/movies/vegamovies/create-vegamovies.js.map +1 -1
  134. package/lib/module/providers/provider-class.js +1 -1
  135. package/lib/module/utils/ExtractorManager.js +89 -11
  136. package/lib/module/utils/ExtractorManager.js.map +1 -1
  137. package/lib/module/utils/ProviderManager.js +54 -18
  138. package/lib/module/utils/ProviderManager.js.map +1 -1
  139. package/lib/module/utils/extension-modules.js +136 -24
  140. package/lib/module/utils/extension-modules.js.map +1 -1
  141. package/lib/module/utils/registry-schema.js +3 -2
  142. package/lib/module/utils/registry-schema.js.map +1 -1
  143. package/lib/module/utils/tmdb.js +51 -7
  144. package/lib/module/utils/tmdb.js.map +1 -1
  145. package/lib/typescript/commonjs/src/NativeConsumet.d.ts +13 -8
  146. package/lib/typescript/commonjs/src/NativeConsumet.d.ts.map +1 -1
  147. package/lib/typescript/commonjs/src/extractors/gofile.d.ts.map +1 -1
  148. package/lib/typescript/commonjs/src/extractors/hubcloud.d.ts.map +1 -1
  149. package/lib/typescript/commonjs/src/index.d.ts +4 -3
  150. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  151. package/lib/typescript/commonjs/src/models/extension-manifest.d.ts +2 -0
  152. package/lib/typescript/commonjs/src/models/extension-manifest.d.ts.map +1 -1
  153. package/lib/typescript/commonjs/src/models/index.d.ts +1 -0
  154. package/lib/typescript/commonjs/src/models/index.d.ts.map +1 -1
  155. package/lib/typescript/commonjs/src/models/meta-error.d.ts +4 -1
  156. package/lib/typescript/commonjs/src/models/meta-error.d.ts.map +1 -1
  157. package/lib/typescript/commonjs/src/models/provider-error.d.ts +32 -0
  158. package/lib/typescript/commonjs/src/models/provider-error.d.ts.map +1 -0
  159. package/lib/typescript/commonjs/src/models/types.d.ts +31 -3
  160. package/lib/typescript/commonjs/src/models/types.d.ts.map +1 -1
  161. package/lib/typescript/commonjs/src/providers/anime/anikoto/create-anikoto.d.ts.map +1 -1
  162. package/lib/typescript/{module/src/providers/anime → commonjs/src/providers/anime/anikoto}/hianime.d.ts +2 -2
  163. package/lib/typescript/commonjs/src/providers/anime/anikoto/hianime.d.ts.map +1 -0
  164. package/lib/typescript/commonjs/src/providers/anime/animepahe/create-animepahe.d.ts.map +1 -1
  165. package/lib/typescript/commonjs/src/providers/anime/index.d.ts +0 -6
  166. package/lib/typescript/commonjs/src/providers/anime/index.d.ts.map +1 -1
  167. package/lib/typescript/commonjs/src/providers/anime/reanime/create-reanime.d.ts.map +1 -1
  168. package/lib/typescript/commonjs/src/providers/common/concurrency.d.ts +8 -0
  169. package/lib/typescript/commonjs/src/providers/common/concurrency.d.ts.map +1 -0
  170. package/lib/typescript/commonjs/src/providers/common/errors.d.ts +36 -0
  171. package/lib/typescript/commonjs/src/providers/common/errors.d.ts.map +1 -0
  172. package/lib/typescript/commonjs/src/providers/common/servers.d.ts +2 -1
  173. package/lib/typescript/commonjs/src/providers/common/servers.d.ts.map +1 -1
  174. package/lib/typescript/commonjs/src/providers/common/ttl-cache.d.ts +21 -0
  175. package/lib/typescript/commonjs/src/providers/common/ttl-cache.d.ts.map +1 -0
  176. package/lib/typescript/commonjs/src/providers/manga/asurascans.d.ts.map +1 -1
  177. package/lib/typescript/commonjs/src/providers/meta/anilist-media.d.ts +19 -7
  178. package/lib/typescript/commonjs/src/providers/meta/anilist-media.d.ts.map +1 -1
  179. package/lib/typescript/commonjs/src/providers/meta/anilist.d.ts +15 -7
  180. package/lib/typescript/commonjs/src/providers/meta/anilist.d.ts.map +1 -1
  181. package/lib/typescript/commonjs/src/providers/meta/mal.d.ts +1 -1
  182. package/lib/typescript/commonjs/src/providers/meta/shared.d.ts +4 -1
  183. package/lib/typescript/commonjs/src/providers/meta/shared.d.ts.map +1 -1
  184. package/lib/typescript/commonjs/src/providers/meta/tmdb.d.ts +65 -6
  185. package/lib/typescript/commonjs/src/providers/meta/tmdb.d.ts.map +1 -1
  186. package/lib/typescript/commonjs/src/providers/movies/index.d.ts +0 -3
  187. package/lib/typescript/commonjs/src/providers/movies/index.d.ts.map +1 -1
  188. package/lib/typescript/commonjs/src/providers/movies/multimovies/create-multimovies.d.ts.map +1 -1
  189. package/lib/typescript/commonjs/src/providers/movies/netflixmirror/create-netflixmirror.d.ts.map +1 -1
  190. package/lib/typescript/commonjs/src/providers/movies/site-paths.d.ts +3 -2
  191. package/lib/typescript/commonjs/src/providers/movies/site-paths.d.ts.map +1 -1
  192. package/lib/typescript/commonjs/src/providers/movies/vegamovies/create-vegamovies.d.ts.map +1 -1
  193. package/lib/typescript/commonjs/src/providers/provider-class.d.ts +1 -1
  194. package/lib/typescript/commonjs/src/utils/ExtractorManager.d.ts +29 -1
  195. package/lib/typescript/commonjs/src/utils/ExtractorManager.d.ts.map +1 -1
  196. package/lib/typescript/commonjs/src/utils/ProviderManager.d.ts +19 -5
  197. package/lib/typescript/commonjs/src/utils/ProviderManager.d.ts.map +1 -1
  198. package/lib/typescript/commonjs/src/utils/extension-modules.d.ts +33 -8
  199. package/lib/typescript/commonjs/src/utils/extension-modules.d.ts.map +1 -1
  200. package/lib/typescript/commonjs/src/utils/registry-schema.d.ts +1 -1
  201. package/lib/typescript/commonjs/src/utils/registry-schema.d.ts.map +1 -1
  202. package/lib/typescript/commonjs/src/utils/tmdb.d.ts +18 -3
  203. package/lib/typescript/commonjs/src/utils/tmdb.d.ts.map +1 -1
  204. package/lib/typescript/module/src/NativeConsumet.d.ts +13 -8
  205. package/lib/typescript/module/src/NativeConsumet.d.ts.map +1 -1
  206. package/lib/typescript/module/src/extractors/gofile.d.ts.map +1 -1
  207. package/lib/typescript/module/src/extractors/hubcloud.d.ts.map +1 -1
  208. package/lib/typescript/module/src/index.d.ts +4 -3
  209. package/lib/typescript/module/src/index.d.ts.map +1 -1
  210. package/lib/typescript/module/src/models/extension-manifest.d.ts +2 -0
  211. package/lib/typescript/module/src/models/extension-manifest.d.ts.map +1 -1
  212. package/lib/typescript/module/src/models/index.d.ts +1 -0
  213. package/lib/typescript/module/src/models/index.d.ts.map +1 -1
  214. package/lib/typescript/module/src/models/meta-error.d.ts +4 -1
  215. package/lib/typescript/module/src/models/meta-error.d.ts.map +1 -1
  216. package/lib/typescript/module/src/models/provider-error.d.ts +32 -0
  217. package/lib/typescript/module/src/models/provider-error.d.ts.map +1 -0
  218. package/lib/typescript/module/src/models/types.d.ts +31 -3
  219. package/lib/typescript/module/src/models/types.d.ts.map +1 -1
  220. package/lib/typescript/module/src/providers/anime/anikoto/create-anikoto.d.ts.map +1 -1
  221. package/lib/typescript/{commonjs/src/providers/anime → module/src/providers/anime/anikoto}/hianime.d.ts +2 -2
  222. package/lib/typescript/module/src/providers/anime/anikoto/hianime.d.ts.map +1 -0
  223. package/lib/typescript/module/src/providers/anime/animepahe/create-animepahe.d.ts.map +1 -1
  224. package/lib/typescript/module/src/providers/anime/index.d.ts +0 -6
  225. package/lib/typescript/module/src/providers/anime/index.d.ts.map +1 -1
  226. package/lib/typescript/module/src/providers/anime/reanime/create-reanime.d.ts.map +1 -1
  227. package/lib/typescript/module/src/providers/common/concurrency.d.ts +8 -0
  228. package/lib/typescript/module/src/providers/common/concurrency.d.ts.map +1 -0
  229. package/lib/typescript/module/src/providers/common/errors.d.ts +36 -0
  230. package/lib/typescript/module/src/providers/common/errors.d.ts.map +1 -0
  231. package/lib/typescript/module/src/providers/common/servers.d.ts +2 -1
  232. package/lib/typescript/module/src/providers/common/servers.d.ts.map +1 -1
  233. package/lib/typescript/module/src/providers/common/ttl-cache.d.ts +21 -0
  234. package/lib/typescript/module/src/providers/common/ttl-cache.d.ts.map +1 -0
  235. package/lib/typescript/module/src/providers/manga/asurascans.d.ts.map +1 -1
  236. package/lib/typescript/module/src/providers/meta/anilist-media.d.ts +19 -7
  237. package/lib/typescript/module/src/providers/meta/anilist-media.d.ts.map +1 -1
  238. package/lib/typescript/module/src/providers/meta/anilist.d.ts +15 -7
  239. package/lib/typescript/module/src/providers/meta/anilist.d.ts.map +1 -1
  240. package/lib/typescript/module/src/providers/meta/mal.d.ts +1 -1
  241. package/lib/typescript/module/src/providers/meta/shared.d.ts +4 -1
  242. package/lib/typescript/module/src/providers/meta/shared.d.ts.map +1 -1
  243. package/lib/typescript/module/src/providers/meta/tmdb.d.ts +65 -6
  244. package/lib/typescript/module/src/providers/meta/tmdb.d.ts.map +1 -1
  245. package/lib/typescript/module/src/providers/movies/index.d.ts +0 -3
  246. package/lib/typescript/module/src/providers/movies/index.d.ts.map +1 -1
  247. package/lib/typescript/module/src/providers/movies/multimovies/create-multimovies.d.ts.map +1 -1
  248. package/lib/typescript/module/src/providers/movies/netflixmirror/create-netflixmirror.d.ts.map +1 -1
  249. package/lib/typescript/module/src/providers/movies/site-paths.d.ts +3 -2
  250. package/lib/typescript/module/src/providers/movies/site-paths.d.ts.map +1 -1
  251. package/lib/typescript/module/src/providers/movies/vegamovies/create-vegamovies.d.ts.map +1 -1
  252. package/lib/typescript/module/src/providers/provider-class.d.ts +1 -1
  253. package/lib/typescript/module/src/utils/ExtractorManager.d.ts +29 -1
  254. package/lib/typescript/module/src/utils/ExtractorManager.d.ts.map +1 -1
  255. package/lib/typescript/module/src/utils/ProviderManager.d.ts +19 -5
  256. package/lib/typescript/module/src/utils/ProviderManager.d.ts.map +1 -1
  257. package/lib/typescript/module/src/utils/extension-modules.d.ts +33 -8
  258. package/lib/typescript/module/src/utils/extension-modules.d.ts.map +1 -1
  259. package/lib/typescript/module/src/utils/registry-schema.d.ts +1 -1
  260. package/lib/typescript/module/src/utils/registry-schema.d.ts.map +1 -1
  261. package/lib/typescript/module/src/utils/tmdb.d.ts +18 -3
  262. package/lib/typescript/module/src/utils/tmdb.d.ts.map +1 -1
  263. package/package.json +1 -1
  264. package/src/NativeConsumet.ts +13 -8
  265. package/src/extension-registry.json +35 -64
  266. package/src/extension-registry.json.sig +1 -1
  267. package/src/extractors/gofile.ts +52 -11
  268. package/src/extractors/hubcloud.ts +62 -49
  269. package/src/index.tsx +4 -1
  270. package/src/models/extension-manifest.ts +3 -0
  271. package/src/models/index.ts +1 -0
  272. package/src/models/meta-error.ts +7 -3
  273. package/src/models/provider-error.ts +57 -0
  274. package/src/models/types.ts +27 -3
  275. package/src/providers/anime/anikoto/create-anikoto.ts +75 -27
  276. package/src/providers/anime/{hianime.ts → anikoto/hianime.ts} +5 -5
  277. package/src/providers/anime/animepahe/create-animepahe.ts +101 -19
  278. package/src/providers/anime/index.ts +0 -8
  279. package/src/providers/anime/reanime/create-reanime.ts +8 -1
  280. package/src/providers/common/concurrency.ts +32 -0
  281. package/src/providers/common/errors.ts +84 -0
  282. package/src/providers/common/servers.ts +7 -3
  283. package/src/providers/common/ttl-cache.ts +65 -0
  284. package/src/providers/manga/asurascans.ts +31 -7
  285. package/src/providers/meta/anilist-media.ts +20 -15
  286. package/src/providers/meta/anilist.ts +59 -17
  287. package/src/providers/meta/mal.ts +3 -3
  288. package/src/providers/meta/shared.ts +10 -3
  289. package/src/providers/meta/tmdb.ts +173 -38
  290. package/src/providers/movies/index.ts +0 -4
  291. package/src/providers/movies/multimovies/create-multimovies.ts +1 -0
  292. package/src/providers/movies/multistream/create-multistream.ts +1 -1
  293. package/src/providers/movies/netflixmirror/create-netflixmirror.ts +49 -11
  294. package/src/providers/movies/site-paths.ts +3 -2
  295. package/src/providers/movies/vegamovies/create-vegamovies.ts +93 -42
  296. package/src/providers/provider-class.ts +1 -1
  297. package/src/utils/ExtractorManager.ts +97 -11
  298. package/src/utils/ProviderManager.ts +74 -22
  299. package/src/utils/extension-modules.ts +145 -32
  300. package/src/utils/registry-schema.ts +2 -1
  301. package/src/utils/tmdb.ts +53 -7
  302. package/lib/commonjs/providers/anime/anineko/anineko.js +0 -11
  303. package/lib/commonjs/providers/anime/anineko/anineko.js.map +0 -1
  304. package/lib/commonjs/providers/anime/anineko/create-anineko.js +0 -358
  305. package/lib/commonjs/providers/anime/anineko/create-anineko.js.map +0 -1
  306. package/lib/commonjs/providers/anime/hianime.js.map +0 -1
  307. package/lib/commonjs/providers/anime/zoro/create-zoro.js +0 -362
  308. package/lib/commonjs/providers/anime/zoro/create-zoro.js.map +0 -1
  309. package/lib/commonjs/providers/anime/zoro/zoro.js +0 -11
  310. package/lib/commonjs/providers/anime/zoro/zoro.js.map +0 -1
  311. package/lib/commonjs/providers/movies/himovies/create-himovies.js +0 -231
  312. package/lib/commonjs/providers/movies/himovies/create-himovies.js.map +0 -1
  313. package/lib/commonjs/providers/movies/himovies/himovies.js +0 -11
  314. package/lib/commonjs/providers/movies/himovies/himovies.js.map +0 -1
  315. package/lib/module/providers/anime/anineko/anineko.js +0 -7
  316. package/lib/module/providers/anime/anineko/anineko.js.map +0 -1
  317. package/lib/module/providers/anime/anineko/create-anineko.js +0 -354
  318. package/lib/module/providers/anime/anineko/create-anineko.js.map +0 -1
  319. package/lib/module/providers/anime/hianime.js.map +0 -1
  320. package/lib/module/providers/anime/zoro/create-zoro.js +0 -358
  321. package/lib/module/providers/anime/zoro/create-zoro.js.map +0 -1
  322. package/lib/module/providers/anime/zoro/zoro.js +0 -7
  323. package/lib/module/providers/anime/zoro/zoro.js.map +0 -1
  324. package/lib/module/providers/movies/himovies/create-himovies.js +0 -227
  325. package/lib/module/providers/movies/himovies/create-himovies.js.map +0 -1
  326. package/lib/module/providers/movies/himovies/himovies.js +0 -7
  327. package/lib/module/providers/movies/himovies/himovies.js.map +0 -1
  328. package/lib/typescript/commonjs/src/providers/anime/anineko/anineko.d.ts +0 -5
  329. package/lib/typescript/commonjs/src/providers/anime/anineko/anineko.d.ts.map +0 -1
  330. package/lib/typescript/commonjs/src/providers/anime/anineko/create-anineko.d.ts +0 -52
  331. package/lib/typescript/commonjs/src/providers/anime/anineko/create-anineko.d.ts.map +0 -1
  332. package/lib/typescript/commonjs/src/providers/anime/hianime.d.ts.map +0 -1
  333. package/lib/typescript/commonjs/src/providers/anime/zoro/create-zoro.d.ts +0 -49
  334. package/lib/typescript/commonjs/src/providers/anime/zoro/create-zoro.d.ts.map +0 -1
  335. package/lib/typescript/commonjs/src/providers/anime/zoro/zoro.d.ts +0 -5
  336. package/lib/typescript/commonjs/src/providers/anime/zoro/zoro.d.ts.map +0 -1
  337. package/lib/typescript/commonjs/src/providers/movies/himovies/create-himovies.d.ts +0 -28
  338. package/lib/typescript/commonjs/src/providers/movies/himovies/create-himovies.d.ts.map +0 -1
  339. package/lib/typescript/commonjs/src/providers/movies/himovies/himovies.d.ts +0 -5
  340. package/lib/typescript/commonjs/src/providers/movies/himovies/himovies.d.ts.map +0 -1
  341. package/lib/typescript/module/src/providers/anime/anineko/anineko.d.ts +0 -5
  342. package/lib/typescript/module/src/providers/anime/anineko/anineko.d.ts.map +0 -1
  343. package/lib/typescript/module/src/providers/anime/anineko/create-anineko.d.ts +0 -52
  344. package/lib/typescript/module/src/providers/anime/anineko/create-anineko.d.ts.map +0 -1
  345. package/lib/typescript/module/src/providers/anime/hianime.d.ts.map +0 -1
  346. package/lib/typescript/module/src/providers/anime/zoro/create-zoro.d.ts +0 -49
  347. package/lib/typescript/module/src/providers/anime/zoro/create-zoro.d.ts.map +0 -1
  348. package/lib/typescript/module/src/providers/anime/zoro/zoro.d.ts +0 -5
  349. package/lib/typescript/module/src/providers/anime/zoro/zoro.d.ts.map +0 -1
  350. package/lib/typescript/module/src/providers/movies/himovies/create-himovies.d.ts +0 -28
  351. package/lib/typescript/module/src/providers/movies/himovies/create-himovies.d.ts.map +0 -1
  352. package/lib/typescript/module/src/providers/movies/himovies/himovies.d.ts +0 -5
  353. package/lib/typescript/module/src/providers/movies/himovies/himovies.d.ts.map +0 -1
  354. package/src/providers/anime/anineko/anineko.ts +0 -6
  355. package/src/providers/anime/anineko/create-anineko.ts +0 -394
  356. package/src/providers/anime/zoro/create-zoro.ts +0 -398
  357. package/src/providers/anime/zoro/zoro.ts +0 -6
  358. package/src/providers/movies/himovies/create-himovies.ts +0 -252
  359. package/src/providers/movies/himovies/himovies.ts +0 -6
@@ -67,6 +67,12 @@ export interface IAnimeResult {
67
67
  type?: MediaFormat;
68
68
  releaseDate?: string;
69
69
  relationType?: string;
70
+ /** AniList: `WINTER`, `SPRING`, `SUMMER` or `FALL` */
71
+ season?: string;
72
+ /** Text from providers; minutes per episode (a number) from AniList */
73
+ duration?: string | number;
74
+ /** AniList: the next episode to air; `airingTime` is in Unix seconds, `timeUntilAiring` in seconds */
75
+ nextAiringEpisode?: { airingTime: number; timeUntilAiring: number; episode: number };
70
76
  [x: string]: any; // other fields
71
77
  }
72
78
 
@@ -162,15 +168,21 @@ export interface IAnimeEpisode {
162
168
  }
163
169
 
164
170
  /**
165
- * An episode returned by a meta provider (e.g. `META.Anilist.fetchEpisodesListById`). `number` is
166
- * always the provider's own number.
171
+ * An episode returned by a meta provider (e.g. `META.Anilist.fetchEpisodesListById`). `number`
172
+ * counts from 1 in the season, also when the provider keeps counting from the previous one and
173
+ * ani.zip shows by how much.
167
174
  */
168
175
  export interface IMetaAnimeEpisode extends IAnimeEpisode {
169
176
  /**
170
177
  * Stable key to store watch progress under: `${anilistId}$ep=${n}`, where `n` is the AniDB
171
- * episode number from ani.zip when the episode was matched, otherwise the provider's `number`.
178
+ * episode number from ani.zip when the episode was matched, otherwise `number`.
172
179
  */
173
180
  uniqueId: string;
181
+ /**
182
+ * The AniDB episode number ani.zip matched the episode to (the `n` in `uniqueId`), when it matched
183
+ * one. Per season, like MAL's numbers, so services keyed by MAL id (AniSkip) take this number.
184
+ */
185
+ aniDbNumber?: number;
174
186
  /** TVDB season-relative episode number, when ani.zip matched the episode. */
175
187
  tvdbNumber?: number;
176
188
  /** TVDB absolute episode number, when ani.zip matched the episode. */
@@ -203,8 +215,16 @@ export interface AniZipEpisode {
203
215
  }
204
216
 
205
217
  export interface IEpisodeServer {
218
+ /** `<extractor>-<label>` (`megaplay-hd-1`): what `fetchEpisodeSources` takes to pick the server */
206
219
  name: string;
207
220
  url: string;
221
+ /**
222
+ * The site's own name for the server, as it shows it (`HD-1`, `SubsPlease · 1080p`), when the
223
+ * provider has one. `serverDisplayName(name, label)` makes a display name from both.
224
+ */
225
+ label?: string;
226
+ /** Whether the server plays the dub (`false`: the sub), when the provider knows. */
227
+ isDub?: boolean;
208
228
  [x: string]: unknown;
209
229
  }
210
230
 
@@ -293,6 +313,10 @@ export interface IMangaResult {
293
313
  releaseDate?: number | string;
294
314
  /** Absolute URL of the title's page on the site. */
295
315
  url?: string;
316
+ /** AniList: the number of chapters, once the manga has one */
317
+ totalChapters?: number;
318
+ /** AniList: the number of volumes, once the manga has one */
319
+ volumes?: number;
296
320
  [x: string]: unknown; // other fields
297
321
  }
298
322
 
@@ -13,22 +13,34 @@ import {
13
13
  type ProviderConfig,
14
14
  type ProviderCapabilities,
15
15
  } from '../../../models';
16
+ import { mapLimit } from '../../common/concurrency';
16
17
  import { toMediaStatus } from '../../common/media-status';
17
18
  import { pickServer, serverName } from '../../common/servers';
18
- import { IST_TZ_OFFSET, cardPage, linkedGenres, pageUrl, siteEpisodeId, toEpisodeId } from '../hianime';
19
+ import { PAGE_TTL_MS, ttlCache } from '../../common/ttl-cache';
20
+ import { IST_TZ_OFFSET, cardPage, linkedGenres, pageUrl, siteEpisodeId, toEpisodeId } from './hianime';
21
+
22
+ // Kept at the top level, so they outlive one provider instance (apps build one per query), by
23
+ // request URL: an episode's server list (`/ajax/server/list`) when it lists servers, and the embed
24
+ // URL of a server's link (`/ajax/server?get=`) when it gives one. Servers, then sources, ask once.
25
+ const serverLists = ttlCache<any>({
26
+ ttlMs: PAGE_TTL_MS,
27
+ maxEntries: 16,
28
+ keep: (html) => typeof html === 'string' && html.includes('data-link-id'),
29
+ });
30
+ const embedUrls = ttlCache<any>({ ttlMs: PAGE_TTL_MS, maxEntries: 32, keep: (url) => !!url });
19
31
 
20
32
  export function createAniKoto(ctx: ProviderContext, customBaseURL?: string) {
21
33
  const { axios, load, extractors, enums, createCustomBaseUrl, PolyURL, PolyURLSearchParams, USER_AGENT } = ctx;
22
34
  const { MegaPlay } = extractors;
23
35
  const { SubOrDub: SubOrDubEnum } = enums;
24
36
 
25
- const baseUrl = createCustomBaseUrl('https://anikototv.to', customBaseURL);
37
+ const baseUrl = createCustomBaseUrl('https://anikototv.bz', customBaseURL);
26
38
 
27
39
  const config: ProviderConfig = {
28
40
  name: 'AniKoto',
29
41
  languages: 'en',
30
42
  classPath: 'ANIME.AniKoto',
31
- logo: 'https://anikototv.to/favicon-32x32.png',
43
+ logo: 'https://anikototv.bz/favicon-32x32.png',
32
44
  baseUrl,
33
45
  isNSFW: false,
34
46
  isWorking: true,
@@ -83,7 +95,7 @@ export function createAniKoto(ctx: ProviderContext, customBaseURL?: string) {
83
95
 
84
96
  /**
85
97
  * Search with filters; each is optional. The site has no date filters: `_startDate` and
86
- * `_endDate` are only there so the parameters line up with Zoro's.
98
+ * `_endDate` are accepted and ignored.
87
99
  */
88
100
  const fetchAdvancedSearch = async (
89
101
  page: number = 1,
@@ -320,18 +332,20 @@ export function createAniKoto(ctx: ProviderContext, customBaseURL?: string) {
320
332
  };
321
333
  };
322
334
 
323
- /** @param episodeId an episode id from fetchAnimeInfo, or the site's own episode id */
324
- const fetchEpisodeServers = async (
325
- episodeId: string,
326
- subOrDub: SubOrDub = SubOrDubEnum.SUB
327
- ): Promise<IEpisodeServer[]> => {
335
+ /**
336
+ * The servers the episode's list has in `subOrDub`, in list order: each one's link id, name and
337
+ * label, and whether it is the dub (unknown when the list has no language groups).
338
+ */
339
+ const listServers = async (episodeId: string, subOrDub: SubOrDub) => {
328
340
  const dataIds = siteEpisodeId(episodeId) ?? episodeId;
329
341
  const targetSubDub = subOrDub === SubOrDubEnum.DUB ? 'dub' : 'sub';
330
342
 
331
- const res = await axios.get(`${config.baseUrl}/ajax/server/list?servers=${encodeURIComponent(dataIds)}`, {
332
- headers: ajaxHeaders(),
343
+ const url = `${config.baseUrl}/ajax/server/list?servers=${encodeURIComponent(dataIds)}`;
344
+ const html = await serverLists.get(url, async () => {
345
+ const res = await axios.get(url, { headers: ajaxHeaders() });
346
+ return res.data?.result || res.data;
333
347
  });
334
- const $ = load(res.data?.result || res.data);
348
+ const $ = load(html);
335
349
 
336
350
  // The list is grouped by language; a page without groups lists every server in one.
337
351
  const groups = $('.servers .type[data-type]');
@@ -339,22 +353,40 @@ export function createAniKoto(ctx: ProviderContext, customBaseURL?: string) {
339
353
  ? groups.filter(`[data-type="${targetSubDub}"]`).find('li[data-link-id]')
340
354
  : $('.servers li[data-link-id]');
341
355
 
342
- const servers: IEpisodeServer[] = [];
343
- for (const el of serverList.toArray()) {
344
- const linkId = $(el).attr('data-link-id');
345
- if (!linkId) continue;
346
- try {
347
- const { data: linkData } = await axios.get(`${config.baseUrl}/ajax/server?get=${encodeURIComponent(linkId)}`, {
348
- headers: ajaxHeaders(),
349
- });
350
- const embedUrl = linkData?.result?.url;
351
- if (embedUrl) servers.push({ name: serverName('megaplay', $(el).text()), url: embedUrl });
352
- } catch {
353
- // A server whose link doesn't resolve is left out; the others still play.
354
- }
355
- }
356
+ const isDub = groups.length ? targetSubDub === 'dub' : undefined;
357
+ return serverList.toArray().map((el) => {
358
+ const label = $(el).text().replace(/\s+/g, ' ').trim();
359
+ return { linkId: $(el).attr('data-link-id'), name: serverName('megaplay', label), label, isDub };
360
+ });
361
+ };
356
362
 
357
- return servers;
363
+ /** The embed URL of a server's link; falsy when the site gives none. */
364
+ const embedUrlOf = (linkId: string): Promise<any> => {
365
+ const url = `${config.baseUrl}/ajax/server?get=${encodeURIComponent(linkId)}`;
366
+ return embedUrls.get(url, async () => (await axios.get(url, { headers: ajaxHeaders() })).data?.result?.url);
367
+ };
368
+
369
+ /** @param episodeId an episode id from fetchAnimeInfo, or the site's own episode id */
370
+ const fetchEpisodeServers = async (
371
+ episodeId: string,
372
+ subOrDub: SubOrDub = SubOrDubEnum.SUB
373
+ ): Promise<IEpisodeServer[]> => {
374
+ const servers = await listServers(episodeId, subOrDub);
375
+ const resolved = await mapLimit(
376
+ servers,
377
+ 4,
378
+ async ({ linkId, name, label, isDub }): Promise<IEpisodeServer | undefined> => {
379
+ if (!linkId) return undefined;
380
+ try {
381
+ const embedUrl = await embedUrlOf(linkId);
382
+ return embedUrl ? { name, url: embedUrl, label, isDub } : undefined;
383
+ } catch {
384
+ // A server whose link doesn't resolve is left out; the others still play.
385
+ return undefined;
386
+ }
387
+ }
388
+ );
389
+ return resolved.filter((server): server is IEpisodeServer => !!server);
358
390
  };
359
391
 
360
392
  const extractFrom = (embedUrl: string): Promise<ISource> =>
@@ -371,6 +403,22 @@ export function createAniKoto(ctx: ProviderContext, customBaseURL?: string) {
371
403
  subOrDub: SubOrDub = SubOrDubEnum.SUB
372
404
  ): Promise<ISource> => {
373
405
  if (episodeId.startsWith('http')) return extractFrom(episodeId);
406
+
407
+ // The server pickServer would pick from fetchEpisodeServers: the first, in list order, whose
408
+ // name `server` starts (every server without one) and whose link gives an embed URL. Only the
409
+ // links up to it are resolved.
410
+ const wanted = server?.toLowerCase();
411
+ for (const { linkId, name } of await listServers(episodeId, subOrDub)) {
412
+ if (!linkId || (wanted && !name.toLowerCase().startsWith(wanted))) continue;
413
+ let embedUrl: any;
414
+ try {
415
+ embedUrl = await embedUrlOf(linkId);
416
+ } catch {
417
+ continue;
418
+ }
419
+ if (embedUrl) return extractFrom(embedUrl);
420
+ }
421
+ // None does: pickServer throws its error, naming the servers there are.
374
422
  return extractFrom(pickServer(await fetchEpisodeServers(episodeId, subOrDub), server).url);
375
423
  };
376
424
 
@@ -1,13 +1,13 @@
1
1
  import type { CheerioAPI } from 'cheerio';
2
- import type { IAnimeResult, ISearch } from '../../models';
3
- import { emptySearch } from '../common/search';
2
+ import type { IAnimeResult, ISearch } from '../../../models';
3
+ import { emptySearch } from '../../common/search';
4
4
 
5
- // Helpers for the hianime-style sites (Zoro, AniKoto): listing pages of anime cards with a
6
- // Bootstrap `.pagination` whose links end in `page=N`, and episode ids of the form
5
+ // Helpers for AniKoto, a hianime-style site: listing pages of anime cards with a Bootstrap
6
+ // `.pagination` whose links end in `page=N`, and episode ids of the form
7
7
  // `<anime id>$episode$<the site's episode id>`.
8
8
 
9
9
  /**
10
- * The zone the sites' schedules give airing times in: UTC+5:30 (IST), as minutes behind UTC (the
10
+ * The zone the site's schedule gives airing times in: UTC+5:30 (IST), as minutes behind UTC (the
11
11
  * form Date.getTimezoneOffset uses). It is fixed, not the device's zone.
12
12
  */
13
13
  export const IST_TZ_OFFSET = -330;
@@ -12,10 +12,67 @@ import {
12
12
  type IAnimeEpisode,
13
13
  type ProviderCapabilities,
14
14
  } from '../../../models';
15
+ import { mapLimit } from '../../common/concurrency';
15
16
  import { toMediaStatus } from '../../common/media-status';
16
17
  import { serverName, serversNamed } from '../../common/servers';
18
+ import { PAGE_TTL_MS, ttlCache } from '../../common/ttl-cache';
17
19
  import { webViewJson } from '../helpers';
18
20
 
21
+ // Kept at the top level, so they outlive one provider instance (apps build one per query).
22
+
23
+ /** Each base URL's challenge load (see ensureChallengePassed). */
24
+ const challenges = new Map<string, Promise<void>>();
25
+
26
+ /**
27
+ * The origins a WebView load came back from, so the WebView holds their Cloudflare clearance, with
28
+ * when the first of those loads came back. Loads to an origin run in parallel only while it is
29
+ * cleared: otherwise they go one at a time, so Cloudflare never has several challenges to solve at
30
+ * once. A clearance doesn't last for ever, so an origin counts as cleared for CLEARANCE_MS; the
31
+ * next load after that goes alone again.
32
+ */
33
+ const CLEARANCE_MS = 15 * 60 * 1000;
34
+ const clearedOrigins = new Map<string, number>();
35
+ const originOf = (url: string): string =>
36
+ (String(url).match(/^[a-z][a-z\d+.-]*:\/\/[^/?#]*/i) || [String(url)])[0]!.toLowerCase();
37
+ const originCleared = (origin: string): boolean => {
38
+ const since = clearedOrigins.get(origin);
39
+ return since !== undefined && Date.now() - since < CLEARANCE_MS;
40
+ };
41
+ const isCleared = (url: string): boolean => originCleared(originOf(url));
42
+ const markCleared = (url: string): void => {
43
+ const origin = originOf(url);
44
+ if (!originCleared(origin)) clearedOrigins.set(origin, Date.now());
45
+ };
46
+
47
+ /**
48
+ * `load` of each item, `limit` at a time, as mapLimit runs them (results in item order, failing as
49
+ * a loop would). On an origin that isn't cleared, the first item loads alone: the others on it wait
50
+ * for that load and start once it worked (it clears the origin), or fail with it.
51
+ */
52
+ function mapCleared<T, R>(items: T[], limit: number, urlOf: (item: T) => string, load: (item: T) => Promise<R>) {
53
+ const firstLoads = new Map<string, Promise<R>>();
54
+ return mapLimit(items, limit, async (item) => {
55
+ const origin = originOf(urlOf(item));
56
+ if (!originCleared(origin)) {
57
+ const first = firstLoads.get(origin);
58
+ if (!first) {
59
+ const loading = load(item);
60
+ firstLoads.set(origin, loading);
61
+ return loading;
62
+ }
63
+ await first;
64
+ }
65
+ return load(item);
66
+ });
67
+ }
68
+
69
+ /** An episode's `/play/` page by URL, so servers, then sources, load it once. */
70
+ const playPages = ttlCache<string>({
71
+ ttlMs: PAGE_TTL_MS,
72
+ maxEntries: 16,
73
+ keep: (html) => html.includes('resolutionMenu'),
74
+ });
75
+
19
76
  export function createAnimePahe(ctx: ProviderContext, customBaseURL?: string) {
20
77
  const { load, extractors, enums, createCustomBaseUrl, PolyURL, NativeConsumet } = ctx;
21
78
  const { Kwik } = extractors;
@@ -39,7 +96,6 @@ export function createAnimePahe(ctx: ProviderContext, customBaseURL?: string) {
39
96
  // the hidden WebView, which waits past the challenge. No User-Agent is sent: the WebView keeps
40
97
  // its own, which the cf_clearance cookie it earns is bound to.
41
98
 
42
- let challenge: Promise<void> | undefined;
43
99
  /**
44
100
  * Loads the site once so the WebView holds a clearance before the first API call. Searches
45
101
  * running at once share the one load; a failed load is tried again by the next search. A passed
@@ -47,14 +103,16 @@ export function createAnimePahe(ctx: ProviderContext, customBaseURL?: string) {
47
103
  * itself, so an expired clearance only makes that request slower.
48
104
  */
49
105
  const ensureChallengePassed = (): Promise<void> => {
106
+ let challenge = challenges.get(baseUrl);
50
107
  if (!challenge) {
51
108
  challenge = makeGetRequestWithWebView(baseUrl, {}).then(
52
- () => undefined,
109
+ () => markCleared(baseUrl),
53
110
  (err: unknown) => {
54
- challenge = undefined;
111
+ challenges.delete(baseUrl);
55
112
  throw err;
56
113
  }
57
114
  );
115
+ challenges.set(baseUrl, challenge);
58
116
  }
59
117
  return challenge;
60
118
  };
@@ -78,12 +136,16 @@ export function createAnimePahe(ctx: ProviderContext, customBaseURL?: string) {
78
136
  if (attempt < 3 && String((err as Error)?.message ?? err).includes('QUIC')) continue;
79
137
  throw err;
80
138
  }
139
+ let parsed: T;
81
140
  try {
82
- return parse(html);
141
+ parsed = parse(html);
83
142
  } catch (err) {
84
143
  if (attempt >= 3) throw err;
85
144
  await new Promise((resolve) => setTimeout(resolve, 800));
145
+ continue;
86
146
  }
147
+ markCleared(url);
148
+ return parsed;
87
149
  }
88
150
  };
89
151
 
@@ -138,7 +200,15 @@ export function createAnimePahe(ctx: ProviderContext, customBaseURL?: string) {
138
200
  * pages is the info's `episodePages`.
139
201
  */
140
202
  const fetchAnimeInfo = async (id: string, episodePage: number = -1): Promise<IAnimeInfo> => {
141
- const $ = await webViewPage(`${baseUrl}/anime/${id}`);
203
+ const firstEpisodes = () => fetchEpisodePage(id, episodePage < 0 ? 1 : episodePage);
204
+ // Once the site is cleared, the first page of episodes loads with the anime page; before, after
205
+ // it (see clearedOrigins).
206
+ const together = isCleared(baseUrl);
207
+ const animePage = webViewPage(`${baseUrl}/anime/${id}`);
208
+ const firstLoad = together ? firstEpisodes() : undefined;
209
+ // Its error is thrown below, after the anime page's.
210
+ firstLoad?.catch(() => undefined);
211
+ const $ = await animePage;
142
212
  const animeInfo: IAnimeInfo = { id, title: $('div.title-wrapper > h1 > span').first().text() };
143
213
 
144
214
  animeInfo.image = $('div.anime-poster a').attr('href');
@@ -178,17 +248,19 @@ export function createAnimePahe(ctx: ProviderContext, customBaseURL?: string) {
178
248
  .map((el) => ({ ...relatedCard(el), relationType: $(el).find('h4 > span').text().trim() }));
179
249
 
180
250
  animeInfo.episodes = [];
251
+ const firstPage = await (firstLoad || firstEpisodes());
181
252
  if (episodePage < 0) {
182
- const firstPage = await fetchEpisodePage(id, 1);
183
253
  animeInfo.episodePages = firstPage.last_page;
184
254
  animeInfo.episodes.push(...firstPage.data.map((item: any) => mapEpisode(id, item)));
185
- for (let i = 2; i <= firstPage.last_page; i++) {
186
- animeInfo.episodes.push(...(await fetchEpisodePage(id, i)).data.map((item: any) => mapEpisode(id, item)));
187
- }
188
- } else {
189
- animeInfo.episodes.push(
190
- ...(await fetchEpisodePage(id, episodePage)).data.map((item: any) => mapEpisode(id, item))
255
+ // The site is cleared by now: the other pages load three at a time, joined in page order.
256
+ const pages: number[] = [];
257
+ for (let i = 2; i <= firstPage.last_page; i++) pages.push(i);
258
+ const rest = await mapLimit(pages, 3, async (page) =>
259
+ (await fetchEpisodePage(id, page)).data.map((item: any) => mapEpisode(id, item))
191
260
  );
261
+ for (const episodes of rest) animeInfo.episodes.push(...episodes);
262
+ } else {
263
+ animeInfo.episodes.push(...firstPage.data.map((item: any) => mapEpisode(id, item)));
192
264
  }
193
265
 
194
266
  return animeInfo;
@@ -196,13 +268,14 @@ export function createAnimePahe(ctx: ProviderContext, customBaseURL?: string) {
196
268
 
197
269
  /** The episode's Kwik players, one per fansub and resolution, with the button's label. */
198
270
  const fetchPlayers = async (episodeId: string, subOrDub: SubOrDub) => {
199
- const $ = await webViewPage(`${baseUrl}/play/${episodeId}`);
271
+ const url = `${baseUrl}/play/${episodeId}`;
272
+ const $ = load(await playPages.get(url, () => webViewGet(url, { Referer: baseUrl }, (html) => html)));
200
273
  const players = $('div#resolutionMenu > button')
201
274
  .toArray()
202
275
  .map((el) => ({
203
276
  name: serverName('kwik', `${$(el).attr('data-fansub')}-${$(el).attr('data-resolution')}`),
204
277
  url: $(el).attr('data-src')!,
205
- label: $(el).text(),
278
+ label: $(el).text().replace(/\s+/g, ' ').trim(),
206
279
  isDub: $(el).attr('data-audio') === 'eng',
207
280
  }))
208
281
  .filter((player) =>
@@ -230,13 +303,22 @@ export function createAnimePahe(ctx: ProviderContext, customBaseURL?: string) {
230
303
  const { players, downloads } = await fetchPlayers(episodeId, subOrDub);
231
304
 
232
305
  const iSource: ISource = { sources: [], download: downloads };
233
- for (const player of serversNamed(players, server)) {
306
+ const named = serversNamed(players, server);
307
+ const loadPlayer = async (player: (typeof named)[number]): Promise<Pick<ISource, 'headers' | 'sources'>> => {
234
308
  const res = await Kwik(ctx).extract(new PolyURL(player.url), `${baseUrl}/`);
235
- // Every player is on Kwik, so they all want the same headers.
236
- iSource.headers = res.headers;
309
+ markCleared(player.url);
310
+ const sources: ISource['sources'] = [];
237
311
  for (const source of res.sources) {
238
- iSource.sources.push({ ...source, quality: (player.label.match(/(\d{3,4})p/) || [])[0] });
312
+ sources.push({ ...source, quality: (player.label.match(/(\d{3,4})p/) || [])[0] });
239
313
  }
314
+ return { headers: res.headers, sources };
315
+ };
316
+ // Three at a time, but one alone on Kwik until it is cleared (see clearedOrigins).
317
+ const loaded = await mapCleared(named, 3, (player) => player.url, loadPlayer);
318
+ for (const { headers, sources } of loaded) {
319
+ // Every player is on Kwik, so they all want the same headers.
320
+ iSource.headers = headers;
321
+ iSource.sources.push(...sources);
240
322
  }
241
323
  return iSource;
242
324
  };
@@ -246,7 +328,7 @@ export function createAnimePahe(ctx: ProviderContext, customBaseURL?: string) {
246
328
  subOrDub: SubOrDub = SubOrDubEnum.SUB
247
329
  ): Promise<IEpisodeServer[]> => {
248
330
  const { players } = await fetchPlayers(episodeId, subOrDub);
249
- return players.map(({ name, url }) => ({ name, url }));
331
+ return players.map(({ name, url, label, isDub }) => ({ name, url, label, isDub }));
250
332
  };
251
333
 
252
334
  return {
@@ -1,23 +1,15 @@
1
1
  import { AnimePahe } from './animepahe/animepahe';
2
2
  import { createAnimePahe } from './animepahe/create-animepahe';
3
- import { Zoro } from './zoro/zoro';
4
- import { createZoro } from './zoro/create-zoro';
5
3
  import { AniKoto } from './anikoto/anikoto';
6
4
  import { createAniKoto } from './anikoto/create-anikoto';
7
5
  import { ReAnime } from './reanime/reanime';
8
6
  import { createReanime } from './reanime/create-reanime';
9
- import { AniNeko } from './anineko/anineko';
10
- import { createAniNeko } from './anineko/create-anineko';
11
7
 
12
8
  export const ANIME = {
13
9
  AnimePahe,
14
10
  createAnimePahe,
15
- Zoro,
16
- createZoro,
17
11
  AniKoto,
18
12
  createAniKoto,
19
13
  ReAnime,
20
14
  createReanime,
21
- AniNeko,
22
- createAniNeko,
23
15
  };
@@ -89,7 +89,12 @@ export function createReanime(ctx: ProviderContext, customBaseURL?: string) {
89
89
  seen.add(name);
90
90
  // Only the active server ("bg-primary") has its URL on the page, in the iframe.
91
91
  const url = $(btn).hasClass('bg-primary') ? iframeSrc : '';
92
- servers.push({ name: serverName('flixcloud', name), url });
92
+ servers.push({
93
+ name: serverName('flixcloud', name),
94
+ url,
95
+ label: name,
96
+ isDub: subOrDub === SubOrDubEnum.DUB,
97
+ });
93
98
  });
94
99
  }
95
100
  });
@@ -207,6 +212,8 @@ export function createReanime(ctx: ProviderContext, customBaseURL?: string) {
207
212
  name: serverName('flixcloud', l.serverName),
208
213
  // The site asks FlixCloud for the dub with &a=1.
209
214
  url: isDub ? `${l.dataLink}&a=1` : l.dataLink,
215
+ label: l.serverName,
216
+ isDub,
210
217
  }));
211
218
  }
212
219
 
@@ -0,0 +1,32 @@
1
+ /**
2
+ * `fn` over `items` with at most `limit` calls running at once, results in `items` order. It fails
3
+ * as a sequential loop would: after the first failure no new call starts, the running ones finish,
4
+ * and it rejects with the error of the lowest index that failed (every lower index had already
5
+ * started). No rejection is left unhandled.
6
+ */
7
+ export function mapLimit<T, R>(
8
+ items: readonly T[],
9
+ limit: number,
10
+ fn: (item: T, index: number) => Promise<R>
11
+ ): Promise<R[]> {
12
+ const results: R[] = new Array(items.length);
13
+ const errors: { index: number; error: unknown }[] = [];
14
+ let next = 0;
15
+
16
+ const worker = async (): Promise<void> => {
17
+ while (next < items.length && errors.length === 0) {
18
+ const index = next++;
19
+ try {
20
+ results[index] = await fn(items[index] as T, index);
21
+ } catch (error) {
22
+ errors.push({ index, error });
23
+ }
24
+ }
25
+ };
26
+
27
+ const workers = Math.min(Math.max(1, Math.floor(limit) || 1), items.length);
28
+ return Promise.all(Array.from({ length: workers }, worker)).then(() => {
29
+ if (errors.length) throw errors.reduce((first, e) => (e.index < first.index ? e : first)).error;
30
+ return results;
31
+ });
32
+ }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Why a provider or extractor failed, so apps can word it and offer the right fix:
3
+ * - `network`: the site couldn't be reached (offline, DNS, a timeout, a gateway error)
4
+ * - `blocked`: the site refused the request (401, 403, 429, 451, or Cloudflare's 503)
5
+ * - `not-found`: the site has no such title, episode, chapter or server
6
+ * - `parse`: the site answered, but not with what the code expects (a changed page or API)
7
+ */
8
+ export type ProviderErrorKind = 'network' | 'blocked' | 'not-found' | 'parse';
9
+
10
+ /** A provider failure as registry bundles throw it: a plain Error with ProviderError's fields. */
11
+ export type TaggedProviderError = Error & {
12
+ name: 'ProviderError';
13
+ kind: ProviderErrorKind;
14
+ provider?: string;
15
+ status?: number;
16
+ cause?: unknown;
17
+ };
18
+
19
+ // axios codes, plus the native WebView request's TIMEOUT
20
+ const NETWORK_CODES = new Set([
21
+ 'ERR_NETWORK',
22
+ 'ECONNABORTED',
23
+ 'ETIMEDOUT',
24
+ 'ECONNRESET',
25
+ 'ECONNREFUSED',
26
+ 'ENOTFOUND',
27
+ 'EAI_AGAIN',
28
+ 'TIMEOUT',
29
+ ]);
30
+ const BLOCKED_STATUSES = new Set([401, 403, 429, 451, 503]);
31
+ const GATEWAY_STATUSES = new Set([502, 504, 520, 521, 522, 523, 524]);
32
+
33
+ /** The HTTP status of a failed request: axios's `response.status`, or a `status` the error carries. */
34
+ export function errorStatus(error: unknown): number | undefined {
35
+ const failure = error as { status?: unknown; response?: { status?: unknown } } | null | undefined;
36
+ const status = failure?.response?.status ?? failure?.status;
37
+ return typeof status === 'number' ? status : undefined;
38
+ }
39
+
40
+ /** Whether `error` is a ProviderError: an instance, or a tagged plain Error from a registry bundle. */
41
+ export function isProviderError(error: unknown): error is TaggedProviderError {
42
+ const failure = error as { name?: unknown; kind?: unknown } | null | undefined;
43
+ return failure?.name === 'ProviderError' && typeof failure.kind === 'string';
44
+ }
45
+
46
+ /**
47
+ * The kind of failure `error` is: its own kind when it is a ProviderError, else read from its HTTP
48
+ * status or network error code, else from its `cause` (a MetaError's). Anything else is `parse`.
49
+ */
50
+ export function errorKind(error: unknown, depth = 0): ProviderErrorKind {
51
+ if (isProviderError(error)) return error.kind;
52
+ const status = errorStatus(error);
53
+ if (status !== undefined) {
54
+ if (status === 404 || status === 410) return 'not-found';
55
+ if (BLOCKED_STATUSES.has(status)) return 'blocked';
56
+ if (GATEWAY_STATUSES.has(status)) return 'network';
57
+ return 'parse';
58
+ }
59
+ const failure = error as { code?: unknown; message?: unknown; cause?: unknown } | null | undefined;
60
+ if (typeof failure?.code === 'string' && NETWORK_CODES.has(failure.code)) return 'network';
61
+ // React Native's fetch rejects with this TypeError when there's no connection
62
+ if (failure?.message === 'Network request failed') return 'network';
63
+ if (failure?.cause !== undefined && depth < 4) return errorKind(failure.cause, depth + 1);
64
+ return 'parse';
65
+ }
66
+
67
+ /**
68
+ * A ProviderError as a plain Error, so registry bundles can throw one without importing anything
69
+ * from the host library (an app on an older library would have no class to construct). Without a
70
+ * `kind`, it is read from `cause` (see errorKind), or is `parse` when there is no cause.
71
+ */
72
+ export function providerError(
73
+ message: string,
74
+ options: { kind?: ProviderErrorKind; provider?: string; cause?: unknown } = {}
75
+ ): TaggedProviderError {
76
+ const { cause, provider } = options;
77
+ return Object.assign(new Error(message), {
78
+ name: 'ProviderError' as const,
79
+ kind: options.kind ?? (cause === undefined ? 'parse' : errorKind(cause)),
80
+ provider,
81
+ status: errorStatus(cause),
82
+ cause,
83
+ });
84
+ }
@@ -1,4 +1,5 @@
1
1
  import type { IEpisodeServer } from '../../models';
2
+ import { providerError } from './errors';
2
3
 
3
4
  /**
4
5
  * The name of an episode server: the name of the extractor (or file host) that reads it, then the
@@ -17,15 +18,18 @@ export function serverName(extractor: string, label: string = ''): string {
17
18
  /**
18
19
  * The servers `server` names: those whose name starts with it, case-insensitively (server names
19
20
  * start with the name of the extractor that reads them, the rule ExtractorManager resolves them
20
- * by). Every server when `server` is omitted. Throws when there is none, or none matches.
21
+ * by). Every server when `server` is omitted. Throws a `not-found` ProviderError when there is none,
22
+ * or none matches.
21
23
  */
22
24
  export function serversNamed<T extends IEpisodeServer>(servers: readonly T[], server?: string): T[] {
23
- if (!servers.length) throw new Error('No servers found for this episode');
25
+ if (!servers.length) throw providerError('No servers found for this episode', { kind: 'not-found' });
24
26
  if (!server) return [...servers];
25
27
  const wanted = server.toLowerCase();
26
28
  const matches = servers.filter((candidate) => candidate.name.toLowerCase().startsWith(wanted));
27
29
  if (!matches.length) {
28
- throw new Error(`Server '${server}' not found; available: ${servers.map((s) => s.name).join(', ')}`);
30
+ throw providerError(`Server '${server}' not found; available: ${servers.map((s) => s.name).join(', ')}`, {
31
+ kind: 'not-found',
32
+ });
29
33
  }
30
34
  return matches;
31
35
  }