react-native-consumet 4.0.0 → 5.0.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 (357) 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 +33 -62
  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.map +1 -1
  21. package/lib/commonjs/providers/anime/anikoto/create-anikoto.js +88 -23
  22. package/lib/commonjs/providers/anime/anikoto/create-anikoto.js.map +1 -1
  23. package/lib/commonjs/providers/anime/{hianime.js → anikoto/hianime.js} +4 -4
  24. package/lib/commonjs/providers/anime/anikoto/hianime.js.map +1 -0
  25. package/lib/commonjs/providers/anime/animepahe/create-animepahe.js +110 -18
  26. package/lib/commonjs/providers/anime/animepahe/create-animepahe.js.map +1 -1
  27. package/lib/commonjs/providers/anime/index.js +1 -9
  28. package/lib/commonjs/providers/anime/index.js.map +1 -1
  29. package/lib/commonjs/providers/anime/reanime/create-reanime.js +6 -2
  30. package/lib/commonjs/providers/anime/reanime/create-reanime.js.map +1 -1
  31. package/lib/commonjs/providers/common/concurrency.js +38 -0
  32. package/lib/commonjs/providers/common/concurrency.js.map +1 -0
  33. package/lib/commonjs/providers/common/errors.js +77 -0
  34. package/lib/commonjs/providers/common/errors.js.map +1 -0
  35. package/lib/commonjs/providers/common/servers.js +9 -3
  36. package/lib/commonjs/providers/common/servers.js.map +1 -1
  37. package/lib/commonjs/providers/common/ttl-cache.js +59 -0
  38. package/lib/commonjs/providers/common/ttl-cache.js.map +1 -0
  39. package/lib/commonjs/providers/manga/asurascans.js +29 -7
  40. package/lib/commonjs/providers/manga/asurascans.js.map +1 -1
  41. package/lib/commonjs/providers/meta/anilist-media.js +23 -13
  42. package/lib/commonjs/providers/meta/anilist-media.js.map +1 -1
  43. package/lib/commonjs/providers/meta/anilist.js +25 -14
  44. package/lib/commonjs/providers/meta/anilist.js.map +1 -1
  45. package/lib/commonjs/providers/meta/mal.js +3 -3
  46. package/lib/commonjs/providers/meta/mal.js.map +1 -1
  47. package/lib/commonjs/providers/meta/shared.js +7 -2
  48. package/lib/commonjs/providers/meta/shared.js.map +1 -1
  49. package/lib/commonjs/providers/meta/tmdb.js +151 -45
  50. package/lib/commonjs/providers/meta/tmdb.js.map +1 -1
  51. package/lib/commonjs/providers/movies/index.js +0 -4
  52. package/lib/commonjs/providers/movies/index.js.map +1 -1
  53. package/lib/commonjs/providers/movies/multimovies/create-multimovies.js +2 -1
  54. package/lib/commonjs/providers/movies/multimovies/create-multimovies.js.map +1 -1
  55. package/lib/commonjs/providers/movies/multistream/create-multistream.js +1 -1
  56. package/lib/commonjs/providers/movies/multistream/create-multistream.js.map +1 -1
  57. package/lib/commonjs/providers/movies/netflixmirror/create-netflixmirror.js +44 -11
  58. package/lib/commonjs/providers/movies/netflixmirror/create-netflixmirror.js.map +1 -1
  59. package/lib/commonjs/providers/movies/site-paths.js +3 -2
  60. package/lib/commonjs/providers/movies/site-paths.js.map +1 -1
  61. package/lib/commonjs/providers/movies/vegamovies/create-vegamovies.js +95 -44
  62. package/lib/commonjs/providers/movies/vegamovies/create-vegamovies.js.map +1 -1
  63. package/lib/commonjs/providers/provider-class.js +1 -1
  64. package/lib/commonjs/utils/ExtractorManager.js +90 -11
  65. package/lib/commonjs/utils/ExtractorManager.js.map +1 -1
  66. package/lib/commonjs/utils/ProviderManager.js +54 -18
  67. package/lib/commonjs/utils/ProviderManager.js.map +1 -1
  68. package/lib/commonjs/utils/extension-modules.js +136 -24
  69. package/lib/commonjs/utils/extension-modules.js.map +1 -1
  70. package/lib/commonjs/utils/registry-schema.js +3 -2
  71. package/lib/commonjs/utils/registry-schema.js.map +1 -1
  72. package/lib/commonjs/utils/tmdb.js +53 -8
  73. package/lib/commonjs/utils/tmdb.js.map +1 -1
  74. package/lib/module/NativeConsumet.ts +13 -8
  75. package/lib/module/extension-registry.json +33 -62
  76. package/lib/module/extension-registry.json.sig +1 -1
  77. package/lib/module/extractors/gofile.js +47 -10
  78. package/lib/module/extractors/gofile.js.map +1 -1
  79. package/lib/module/extractors/hubcloud.js +49 -42
  80. package/lib/module/extractors/hubcloud.js.map +1 -1
  81. package/lib/module/index.js +2 -2
  82. package/lib/module/index.js.map +1 -1
  83. package/lib/module/models/index.js +1 -0
  84. package/lib/module/models/index.js.map +1 -1
  85. package/lib/module/models/meta-error.js +7 -3
  86. package/lib/module/models/meta-error.js.map +1 -1
  87. package/lib/module/models/provider-error.js +49 -0
  88. package/lib/module/models/provider-error.js.map +1 -0
  89. package/lib/module/models/types.js.map +1 -1
  90. package/lib/module/providers/anime/anikoto/create-anikoto.js +89 -23
  91. package/lib/module/providers/anime/anikoto/create-anikoto.js.map +1 -1
  92. package/lib/module/providers/anime/{hianime.js → anikoto/hianime.js} +4 -4
  93. package/lib/module/providers/anime/anikoto/hianime.js.map +1 -0
  94. package/lib/module/providers/anime/animepahe/create-animepahe.js +111 -18
  95. package/lib/module/providers/anime/animepahe/create-animepahe.js.map +1 -1
  96. package/lib/module/providers/anime/index.js +1 -9
  97. package/lib/module/providers/anime/index.js.map +1 -1
  98. package/lib/module/providers/anime/reanime/create-reanime.js +6 -2
  99. package/lib/module/providers/anime/reanime/create-reanime.js.map +1 -1
  100. package/lib/module/providers/common/concurrency.js +34 -0
  101. package/lib/module/providers/common/concurrency.js.map +1 -0
  102. package/lib/module/providers/common/errors.js +70 -0
  103. package/lib/module/providers/common/errors.js.map +1 -0
  104. package/lib/module/providers/common/servers.js +10 -3
  105. package/lib/module/providers/common/servers.js.map +1 -1
  106. package/lib/module/providers/common/ttl-cache.js +54 -0
  107. package/lib/module/providers/common/ttl-cache.js.map +1 -0
  108. package/lib/module/providers/manga/asurascans.js +29 -7
  109. package/lib/module/providers/manga/asurascans.js.map +1 -1
  110. package/lib/module/providers/meta/anilist-media.js +23 -13
  111. package/lib/module/providers/meta/anilist-media.js.map +1 -1
  112. package/lib/module/providers/meta/anilist.js +26 -15
  113. package/lib/module/providers/meta/anilist.js.map +1 -1
  114. package/lib/module/providers/meta/mal.js +3 -3
  115. package/lib/module/providers/meta/mal.js.map +1 -1
  116. package/lib/module/providers/meta/shared.js +8 -3
  117. package/lib/module/providers/meta/shared.js.map +1 -1
  118. package/lib/module/providers/meta/tmdb.js +153 -47
  119. package/lib/module/providers/meta/tmdb.js.map +1 -1
  120. package/lib/module/providers/movies/index.js +0 -4
  121. package/lib/module/providers/movies/index.js.map +1 -1
  122. package/lib/module/providers/movies/multimovies/create-multimovies.js +2 -1
  123. package/lib/module/providers/movies/multimovies/create-multimovies.js.map +1 -1
  124. package/lib/module/providers/movies/multistream/create-multistream.js +1 -1
  125. package/lib/module/providers/movies/multistream/create-multistream.js.map +1 -1
  126. package/lib/module/providers/movies/netflixmirror/create-netflixmirror.js +44 -11
  127. package/lib/module/providers/movies/netflixmirror/create-netflixmirror.js.map +1 -1
  128. package/lib/module/providers/movies/site-paths.js +3 -2
  129. package/lib/module/providers/movies/site-paths.js.map +1 -1
  130. package/lib/module/providers/movies/vegamovies/create-vegamovies.js +95 -44
  131. package/lib/module/providers/movies/vegamovies/create-vegamovies.js.map +1 -1
  132. package/lib/module/providers/provider-class.js +1 -1
  133. package/lib/module/utils/ExtractorManager.js +89 -11
  134. package/lib/module/utils/ExtractorManager.js.map +1 -1
  135. package/lib/module/utils/ProviderManager.js +54 -18
  136. package/lib/module/utils/ProviderManager.js.map +1 -1
  137. package/lib/module/utils/extension-modules.js +136 -24
  138. package/lib/module/utils/extension-modules.js.map +1 -1
  139. package/lib/module/utils/registry-schema.js +3 -2
  140. package/lib/module/utils/registry-schema.js.map +1 -1
  141. package/lib/module/utils/tmdb.js +51 -7
  142. package/lib/module/utils/tmdb.js.map +1 -1
  143. package/lib/typescript/commonjs/src/NativeConsumet.d.ts +13 -8
  144. package/lib/typescript/commonjs/src/NativeConsumet.d.ts.map +1 -1
  145. package/lib/typescript/commonjs/src/extractors/gofile.d.ts.map +1 -1
  146. package/lib/typescript/commonjs/src/extractors/hubcloud.d.ts.map +1 -1
  147. package/lib/typescript/commonjs/src/index.d.ts +4 -3
  148. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  149. package/lib/typescript/commonjs/src/models/extension-manifest.d.ts +2 -0
  150. package/lib/typescript/commonjs/src/models/extension-manifest.d.ts.map +1 -1
  151. package/lib/typescript/commonjs/src/models/index.d.ts +1 -0
  152. package/lib/typescript/commonjs/src/models/index.d.ts.map +1 -1
  153. package/lib/typescript/commonjs/src/models/meta-error.d.ts +4 -1
  154. package/lib/typescript/commonjs/src/models/meta-error.d.ts.map +1 -1
  155. package/lib/typescript/commonjs/src/models/provider-error.d.ts +32 -0
  156. package/lib/typescript/commonjs/src/models/provider-error.d.ts.map +1 -0
  157. package/lib/typescript/commonjs/src/models/types.d.ts +27 -0
  158. package/lib/typescript/commonjs/src/models/types.d.ts.map +1 -1
  159. package/lib/typescript/commonjs/src/providers/anime/anikoto/create-anikoto.d.ts.map +1 -1
  160. package/lib/typescript/{module/src/providers/anime → commonjs/src/providers/anime/anikoto}/hianime.d.ts +2 -2
  161. package/lib/typescript/commonjs/src/providers/anime/anikoto/hianime.d.ts.map +1 -0
  162. package/lib/typescript/commonjs/src/providers/anime/animepahe/create-animepahe.d.ts.map +1 -1
  163. package/lib/typescript/commonjs/src/providers/anime/index.d.ts +0 -6
  164. package/lib/typescript/commonjs/src/providers/anime/index.d.ts.map +1 -1
  165. package/lib/typescript/commonjs/src/providers/anime/reanime/create-reanime.d.ts.map +1 -1
  166. package/lib/typescript/commonjs/src/providers/common/concurrency.d.ts +8 -0
  167. package/lib/typescript/commonjs/src/providers/common/concurrency.d.ts.map +1 -0
  168. package/lib/typescript/commonjs/src/providers/common/errors.d.ts +36 -0
  169. package/lib/typescript/commonjs/src/providers/common/errors.d.ts.map +1 -0
  170. package/lib/typescript/commonjs/src/providers/common/servers.d.ts +2 -1
  171. package/lib/typescript/commonjs/src/providers/common/servers.d.ts.map +1 -1
  172. package/lib/typescript/commonjs/src/providers/common/ttl-cache.d.ts +21 -0
  173. package/lib/typescript/commonjs/src/providers/common/ttl-cache.d.ts.map +1 -0
  174. package/lib/typescript/commonjs/src/providers/manga/asurascans.d.ts.map +1 -1
  175. package/lib/typescript/commonjs/src/providers/meta/anilist-media.d.ts +19 -7
  176. package/lib/typescript/commonjs/src/providers/meta/anilist-media.d.ts.map +1 -1
  177. package/lib/typescript/commonjs/src/providers/meta/anilist.d.ts +14 -7
  178. package/lib/typescript/commonjs/src/providers/meta/anilist.d.ts.map +1 -1
  179. package/lib/typescript/commonjs/src/providers/meta/mal.d.ts +1 -1
  180. package/lib/typescript/commonjs/src/providers/meta/shared.d.ts +4 -1
  181. package/lib/typescript/commonjs/src/providers/meta/shared.d.ts.map +1 -1
  182. package/lib/typescript/commonjs/src/providers/meta/tmdb.d.ts +65 -6
  183. package/lib/typescript/commonjs/src/providers/meta/tmdb.d.ts.map +1 -1
  184. package/lib/typescript/commonjs/src/providers/movies/index.d.ts +0 -3
  185. package/lib/typescript/commonjs/src/providers/movies/index.d.ts.map +1 -1
  186. package/lib/typescript/commonjs/src/providers/movies/multimovies/create-multimovies.d.ts.map +1 -1
  187. package/lib/typescript/commonjs/src/providers/movies/netflixmirror/create-netflixmirror.d.ts.map +1 -1
  188. package/lib/typescript/commonjs/src/providers/movies/site-paths.d.ts +3 -2
  189. package/lib/typescript/commonjs/src/providers/movies/site-paths.d.ts.map +1 -1
  190. package/lib/typescript/commonjs/src/providers/movies/vegamovies/create-vegamovies.d.ts.map +1 -1
  191. package/lib/typescript/commonjs/src/providers/provider-class.d.ts +1 -1
  192. package/lib/typescript/commonjs/src/utils/ExtractorManager.d.ts +29 -1
  193. package/lib/typescript/commonjs/src/utils/ExtractorManager.d.ts.map +1 -1
  194. package/lib/typescript/commonjs/src/utils/ProviderManager.d.ts +19 -5
  195. package/lib/typescript/commonjs/src/utils/ProviderManager.d.ts.map +1 -1
  196. package/lib/typescript/commonjs/src/utils/extension-modules.d.ts +33 -8
  197. package/lib/typescript/commonjs/src/utils/extension-modules.d.ts.map +1 -1
  198. package/lib/typescript/commonjs/src/utils/registry-schema.d.ts +1 -1
  199. package/lib/typescript/commonjs/src/utils/registry-schema.d.ts.map +1 -1
  200. package/lib/typescript/commonjs/src/utils/tmdb.d.ts +18 -3
  201. package/lib/typescript/commonjs/src/utils/tmdb.d.ts.map +1 -1
  202. package/lib/typescript/module/src/NativeConsumet.d.ts +13 -8
  203. package/lib/typescript/module/src/NativeConsumet.d.ts.map +1 -1
  204. package/lib/typescript/module/src/extractors/gofile.d.ts.map +1 -1
  205. package/lib/typescript/module/src/extractors/hubcloud.d.ts.map +1 -1
  206. package/lib/typescript/module/src/index.d.ts +4 -3
  207. package/lib/typescript/module/src/index.d.ts.map +1 -1
  208. package/lib/typescript/module/src/models/extension-manifest.d.ts +2 -0
  209. package/lib/typescript/module/src/models/extension-manifest.d.ts.map +1 -1
  210. package/lib/typescript/module/src/models/index.d.ts +1 -0
  211. package/lib/typescript/module/src/models/index.d.ts.map +1 -1
  212. package/lib/typescript/module/src/models/meta-error.d.ts +4 -1
  213. package/lib/typescript/module/src/models/meta-error.d.ts.map +1 -1
  214. package/lib/typescript/module/src/models/provider-error.d.ts +32 -0
  215. package/lib/typescript/module/src/models/provider-error.d.ts.map +1 -0
  216. package/lib/typescript/module/src/models/types.d.ts +27 -0
  217. package/lib/typescript/module/src/models/types.d.ts.map +1 -1
  218. package/lib/typescript/module/src/providers/anime/anikoto/create-anikoto.d.ts.map +1 -1
  219. package/lib/typescript/{commonjs/src/providers/anime → module/src/providers/anime/anikoto}/hianime.d.ts +2 -2
  220. package/lib/typescript/module/src/providers/anime/anikoto/hianime.d.ts.map +1 -0
  221. package/lib/typescript/module/src/providers/anime/animepahe/create-animepahe.d.ts.map +1 -1
  222. package/lib/typescript/module/src/providers/anime/index.d.ts +0 -6
  223. package/lib/typescript/module/src/providers/anime/index.d.ts.map +1 -1
  224. package/lib/typescript/module/src/providers/anime/reanime/create-reanime.d.ts.map +1 -1
  225. package/lib/typescript/module/src/providers/common/concurrency.d.ts +8 -0
  226. package/lib/typescript/module/src/providers/common/concurrency.d.ts.map +1 -0
  227. package/lib/typescript/module/src/providers/common/errors.d.ts +36 -0
  228. package/lib/typescript/module/src/providers/common/errors.d.ts.map +1 -0
  229. package/lib/typescript/module/src/providers/common/servers.d.ts +2 -1
  230. package/lib/typescript/module/src/providers/common/servers.d.ts.map +1 -1
  231. package/lib/typescript/module/src/providers/common/ttl-cache.d.ts +21 -0
  232. package/lib/typescript/module/src/providers/common/ttl-cache.d.ts.map +1 -0
  233. package/lib/typescript/module/src/providers/manga/asurascans.d.ts.map +1 -1
  234. package/lib/typescript/module/src/providers/meta/anilist-media.d.ts +19 -7
  235. package/lib/typescript/module/src/providers/meta/anilist-media.d.ts.map +1 -1
  236. package/lib/typescript/module/src/providers/meta/anilist.d.ts +14 -7
  237. package/lib/typescript/module/src/providers/meta/anilist.d.ts.map +1 -1
  238. package/lib/typescript/module/src/providers/meta/mal.d.ts +1 -1
  239. package/lib/typescript/module/src/providers/meta/shared.d.ts +4 -1
  240. package/lib/typescript/module/src/providers/meta/shared.d.ts.map +1 -1
  241. package/lib/typescript/module/src/providers/meta/tmdb.d.ts +65 -6
  242. package/lib/typescript/module/src/providers/meta/tmdb.d.ts.map +1 -1
  243. package/lib/typescript/module/src/providers/movies/index.d.ts +0 -3
  244. package/lib/typescript/module/src/providers/movies/index.d.ts.map +1 -1
  245. package/lib/typescript/module/src/providers/movies/multimovies/create-multimovies.d.ts.map +1 -1
  246. package/lib/typescript/module/src/providers/movies/netflixmirror/create-netflixmirror.d.ts.map +1 -1
  247. package/lib/typescript/module/src/providers/movies/site-paths.d.ts +3 -2
  248. package/lib/typescript/module/src/providers/movies/site-paths.d.ts.map +1 -1
  249. package/lib/typescript/module/src/providers/movies/vegamovies/create-vegamovies.d.ts.map +1 -1
  250. package/lib/typescript/module/src/providers/provider-class.d.ts +1 -1
  251. package/lib/typescript/module/src/utils/ExtractorManager.d.ts +29 -1
  252. package/lib/typescript/module/src/utils/ExtractorManager.d.ts.map +1 -1
  253. package/lib/typescript/module/src/utils/ProviderManager.d.ts +19 -5
  254. package/lib/typescript/module/src/utils/ProviderManager.d.ts.map +1 -1
  255. package/lib/typescript/module/src/utils/extension-modules.d.ts +33 -8
  256. package/lib/typescript/module/src/utils/extension-modules.d.ts.map +1 -1
  257. package/lib/typescript/module/src/utils/registry-schema.d.ts +1 -1
  258. package/lib/typescript/module/src/utils/registry-schema.d.ts.map +1 -1
  259. package/lib/typescript/module/src/utils/tmdb.d.ts +18 -3
  260. package/lib/typescript/module/src/utils/tmdb.d.ts.map +1 -1
  261. package/package.json +1 -1
  262. package/src/NativeConsumet.ts +13 -8
  263. package/src/extension-registry.json +33 -62
  264. package/src/extension-registry.json.sig +1 -1
  265. package/src/extractors/gofile.ts +52 -11
  266. package/src/extractors/hubcloud.ts +62 -49
  267. package/src/index.tsx +4 -1
  268. package/src/models/extension-manifest.ts +3 -0
  269. package/src/models/index.ts +1 -0
  270. package/src/models/meta-error.ts +7 -3
  271. package/src/models/provider-error.ts +57 -0
  272. package/src/models/types.ts +23 -0
  273. package/src/providers/anime/anikoto/create-anikoto.ts +73 -25
  274. package/src/providers/anime/{hianime.ts → anikoto/hianime.ts} +5 -5
  275. package/src/providers/anime/animepahe/create-animepahe.ts +101 -19
  276. package/src/providers/anime/index.ts +0 -8
  277. package/src/providers/anime/reanime/create-reanime.ts +8 -1
  278. package/src/providers/common/concurrency.ts +32 -0
  279. package/src/providers/common/errors.ts +84 -0
  280. package/src/providers/common/servers.ts +7 -3
  281. package/src/providers/common/ttl-cache.ts +65 -0
  282. package/src/providers/manga/asurascans.ts +31 -7
  283. package/src/providers/meta/anilist-media.ts +20 -15
  284. package/src/providers/meta/anilist.ts +23 -13
  285. package/src/providers/meta/mal.ts +3 -3
  286. package/src/providers/meta/shared.ts +10 -3
  287. package/src/providers/meta/tmdb.ts +173 -38
  288. package/src/providers/movies/index.ts +0 -4
  289. package/src/providers/movies/multimovies/create-multimovies.ts +1 -0
  290. package/src/providers/movies/multistream/create-multistream.ts +1 -1
  291. package/src/providers/movies/netflixmirror/create-netflixmirror.ts +49 -11
  292. package/src/providers/movies/site-paths.ts +3 -2
  293. package/src/providers/movies/vegamovies/create-vegamovies.ts +93 -42
  294. package/src/providers/provider-class.ts +1 -1
  295. package/src/utils/ExtractorManager.ts +97 -11
  296. package/src/utils/ProviderManager.ts +74 -22
  297. package/src/utils/extension-modules.ts +145 -32
  298. package/src/utils/registry-schema.ts +2 -1
  299. package/src/utils/tmdb.ts +53 -7
  300. package/lib/commonjs/providers/anime/anineko/anineko.js +0 -11
  301. package/lib/commonjs/providers/anime/anineko/anineko.js.map +0 -1
  302. package/lib/commonjs/providers/anime/anineko/create-anineko.js +0 -358
  303. package/lib/commonjs/providers/anime/anineko/create-anineko.js.map +0 -1
  304. package/lib/commonjs/providers/anime/hianime.js.map +0 -1
  305. package/lib/commonjs/providers/anime/zoro/create-zoro.js +0 -362
  306. package/lib/commonjs/providers/anime/zoro/create-zoro.js.map +0 -1
  307. package/lib/commonjs/providers/anime/zoro/zoro.js +0 -11
  308. package/lib/commonjs/providers/anime/zoro/zoro.js.map +0 -1
  309. package/lib/commonjs/providers/movies/himovies/create-himovies.js +0 -231
  310. package/lib/commonjs/providers/movies/himovies/create-himovies.js.map +0 -1
  311. package/lib/commonjs/providers/movies/himovies/himovies.js +0 -11
  312. package/lib/commonjs/providers/movies/himovies/himovies.js.map +0 -1
  313. package/lib/module/providers/anime/anineko/anineko.js +0 -7
  314. package/lib/module/providers/anime/anineko/anineko.js.map +0 -1
  315. package/lib/module/providers/anime/anineko/create-anineko.js +0 -354
  316. package/lib/module/providers/anime/anineko/create-anineko.js.map +0 -1
  317. package/lib/module/providers/anime/hianime.js.map +0 -1
  318. package/lib/module/providers/anime/zoro/create-zoro.js +0 -358
  319. package/lib/module/providers/anime/zoro/create-zoro.js.map +0 -1
  320. package/lib/module/providers/anime/zoro/zoro.js +0 -7
  321. package/lib/module/providers/anime/zoro/zoro.js.map +0 -1
  322. package/lib/module/providers/movies/himovies/create-himovies.js +0 -227
  323. package/lib/module/providers/movies/himovies/create-himovies.js.map +0 -1
  324. package/lib/module/providers/movies/himovies/himovies.js +0 -7
  325. package/lib/module/providers/movies/himovies/himovies.js.map +0 -1
  326. package/lib/typescript/commonjs/src/providers/anime/anineko/anineko.d.ts +0 -5
  327. package/lib/typescript/commonjs/src/providers/anime/anineko/anineko.d.ts.map +0 -1
  328. package/lib/typescript/commonjs/src/providers/anime/anineko/create-anineko.d.ts +0 -52
  329. package/lib/typescript/commonjs/src/providers/anime/anineko/create-anineko.d.ts.map +0 -1
  330. package/lib/typescript/commonjs/src/providers/anime/hianime.d.ts.map +0 -1
  331. package/lib/typescript/commonjs/src/providers/anime/zoro/create-zoro.d.ts +0 -49
  332. package/lib/typescript/commonjs/src/providers/anime/zoro/create-zoro.d.ts.map +0 -1
  333. package/lib/typescript/commonjs/src/providers/anime/zoro/zoro.d.ts +0 -5
  334. package/lib/typescript/commonjs/src/providers/anime/zoro/zoro.d.ts.map +0 -1
  335. package/lib/typescript/commonjs/src/providers/movies/himovies/create-himovies.d.ts +0 -28
  336. package/lib/typescript/commonjs/src/providers/movies/himovies/create-himovies.d.ts.map +0 -1
  337. package/lib/typescript/commonjs/src/providers/movies/himovies/himovies.d.ts +0 -5
  338. package/lib/typescript/commonjs/src/providers/movies/himovies/himovies.d.ts.map +0 -1
  339. package/lib/typescript/module/src/providers/anime/anineko/anineko.d.ts +0 -5
  340. package/lib/typescript/module/src/providers/anime/anineko/anineko.d.ts.map +0 -1
  341. package/lib/typescript/module/src/providers/anime/anineko/create-anineko.d.ts +0 -52
  342. package/lib/typescript/module/src/providers/anime/anineko/create-anineko.d.ts.map +0 -1
  343. package/lib/typescript/module/src/providers/anime/hianime.d.ts.map +0 -1
  344. package/lib/typescript/module/src/providers/anime/zoro/create-zoro.d.ts +0 -49
  345. package/lib/typescript/module/src/providers/anime/zoro/create-zoro.d.ts.map +0 -1
  346. package/lib/typescript/module/src/providers/anime/zoro/zoro.d.ts +0 -5
  347. package/lib/typescript/module/src/providers/anime/zoro/zoro.d.ts.map +0 -1
  348. package/lib/typescript/module/src/providers/movies/himovies/create-himovies.d.ts +0 -28
  349. package/lib/typescript/module/src/providers/movies/himovies/create-himovies.d.ts.map +0 -1
  350. package/lib/typescript/module/src/providers/movies/himovies/himovies.d.ts +0 -5
  351. package/lib/typescript/module/src/providers/movies/himovies/himovies.d.ts.map +0 -1
  352. package/src/providers/anime/anineko/anineko.ts +0 -6
  353. package/src/providers/anime/anineko/create-anineko.ts +0 -394
  354. package/src/providers/anime/zoro/create-zoro.ts +0 -398
  355. package/src/providers/anime/zoro/zoro.ts +0 -6
  356. package/src/providers/movies/himovies/create-himovies.ts +0 -252
  357. package/src/providers/movies/himovies/himovies.ts +0 -6
@@ -10,6 +10,8 @@ import {
10
10
  } from '../../../models';
11
11
  import type { AxiosRequestConfig } from 'axios';
12
12
  import { serverName } from '../../common/servers';
13
+ import { PAGE_TTL_MS, ttlCache } from '../../common/ttl-cache';
14
+ import { providerError } from '../../common/errors';
13
15
 
14
16
  type NetMirrorOtt = 'nf' | 'pv' | 'hs';
15
17
 
@@ -80,11 +82,19 @@ const NEWTV_API = 'https://tv.imgcdn.kim';
80
82
  const NEWTV_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0 /OS.GatuNewTV v1.0';
81
83
 
82
84
  // One verified session works for every catalog, so every instance made from this module shares it:
83
- // in the library that's all three catalogs. A registry load compiles each entry's bundle on its own,
84
- // so there each catalog unlocks its own session.
85
+ // all three catalogs, in the library and in a registry load alike (a manager runs a bundle once per
86
+ // sha256, and the three entries share this one).
85
87
  const sessions = new Map<string, { token: string; ts: number }>();
86
88
  const pendingUnlocks = new Map<string, Promise<string>>();
87
89
 
90
+ // A title's NewTV post (post.php), kept when its status is ok, so a search, then that title's info,
91
+ // load it once. The answer depends on the catalog (the Ott header), so it is part of the key.
92
+ const newTvPosts = ttlCache<NewTvPost>({
93
+ ttlMs: PAGE_TTL_MS,
94
+ maxEntries: 32,
95
+ keep: (post) => post?.status === 'ok',
96
+ });
97
+
88
98
  interface NetMirrorSearchResult {
89
99
  status?: string;
90
100
  searchResult?: Array<{ id: string | number; t: string; y?: string; r?: string }>;
@@ -228,7 +238,7 @@ function createNetMirror(ctx: ProviderContext, platform: NetMirrorPlatform, cust
228
238
  .join('; ');
229
239
  const host = baseUrl.replace(/^https?:\/\//, '').replace(/\/.*$/, '');
230
240
 
231
- await axios
241
+ const adVisit = axios
232
242
  .get(`https://userver.${host}/?hee5=${addhash}&a=y&t=${Math.random()}`, {
233
243
  headers: { 'User-Agent': APP_UA, 'Referer': `${baseUrl}/mobile/home?app=1`, 'Cookie': initialCookie },
234
244
  maxRedirects: 0,
@@ -236,6 +246,9 @@ function createNetMirror(ctx: ProviderContext, platform: NetMirrorPlatform, cust
236
246
  timeout: 10000,
237
247
  })
238
248
  .catch(() => undefined);
249
+ // The 2 s before the first poll run while the ad visit loads, not after it.
250
+ let firstWait: Promise<unknown> | undefined = sleep(2000);
251
+ await adVisit;
239
252
 
240
253
  // As the app does: ext_name is the id of the site's browser extension, which the poll reports.
241
254
  const pollCookie = [
@@ -248,7 +261,8 @@ function createNetMirror(ctx: ProviderContext, platform: NetMirrorPlatform, cust
248
261
 
249
262
  const deadline = Date.now() + UNLOCK_TIMEOUT_MS;
250
263
  while (Date.now() < deadline) {
251
- await sleep(2000);
264
+ await (firstWait || sleep(2000));
265
+ firstWait = undefined;
252
266
  const res = await axios
253
267
  .post(`${baseUrl}/mobile/verify2.php`, `verify=${encodeURIComponent(addhash)}`, {
254
268
  headers: {
@@ -335,6 +349,12 @@ function createNetMirror(ctx: ProviderContext, platform: NetMirrorPlatform, cust
335
349
  return data;
336
350
  };
337
351
 
352
+ /** A title's NewTV post, which search and info share (see newTvPosts). */
353
+ const getNewTvPost = (id: string): Promise<NewTvPost> => {
354
+ const path = `post.php?id=${id}`;
355
+ return newTvPosts.get(`${platform.ott}|${NEWTV_API}/newtv/${path}`, () => getNewTv<NewTvPost>(path));
356
+ };
357
+
338
358
  const postUrl = (id: string) => `${baseUrl}/mobile/${platform.path}post.php?id=${id}`;
339
359
  const playlistUrl = (id: string) => `${baseUrl}/mobile/${platform.path}playlist.php?id=${id}`;
340
360
 
@@ -342,7 +362,7 @@ function createNetMirror(ctx: ProviderContext, platform: NetMirrorPlatform, cust
342
362
  // season count, so fill those in from each title's (session-free) post data.
343
363
  const withPostDetails = async (result: IMovieResult): Promise<IMovieResult> => {
344
364
  try {
345
- const post = await getNewTv<NewTvPost>(`post.php?id=${result.id}`);
365
+ const post = await getNewTvPost(result.id);
346
366
  if (post?.status !== 'ok') return result;
347
367
  const isSeries = post.type === 't';
348
368
  return {
@@ -393,7 +413,10 @@ function createNetMirror(ctx: ProviderContext, platform: NetMirrorPlatform, cust
393
413
  const results = await searchNewTv(query).catch(() => searchViaSession(query));
394
414
  return { currentPage: page, hasNextPage: false, results };
395
415
  } catch (err) {
396
- throw new Error(`${config.name} search failed: ${(err as Error).message}`);
416
+ throw providerError(`${config.name} search failed: ${(err as Error).message}`, {
417
+ provider: config.name,
418
+ cause: err,
419
+ });
397
420
  }
398
421
  };
399
422
 
@@ -472,7 +495,7 @@ function createNetMirror(ctx: ProviderContext, platform: NetMirrorPlatform, cust
472
495
  };
473
496
 
474
497
  const fetchMediaInfoNewTv = async (mediaId: string): Promise<IMovieInfo> => {
475
- const post = await getNewTv<NewTvPost>(`post.php?id=${mediaId}`);
498
+ const post = await getNewTvPost(mediaId);
476
499
  if (post?.status !== 'ok') throw new Error('NewTV title unavailable');
477
500
 
478
501
  const detail = (key: string) => post.moredetails?.find((d) => d.k === key)?.v;
@@ -553,14 +576,23 @@ function createNetMirror(ctx: ProviderContext, platform: NetMirrorPlatform, cust
553
576
  try {
554
577
  return await fetchMediaInfoNewTv(mediaId).catch(() => fetchMediaInfoViaSession(mediaId));
555
578
  } catch (err) {
556
- throw new Error(`${config.name} fetchMediaInfo failed: ${(err as Error).message}`);
579
+ throw providerError(`${config.name} fetchMediaInfo failed: ${(err as Error).message}`, {
580
+ provider: config.name,
581
+ cause: err,
582
+ });
557
583
  }
558
584
  };
559
585
 
560
586
  const playlistPath = (episodeId: string) => `/mobile/${platform.path}playlist.php?id=${episodeId}&t=x&tm=${now()}`;
561
587
 
562
588
  const fetchEpisodeServers = async (episodeId: string, _mediaId?: string): Promise<IEpisodeServer[]> => {
563
- return [{ name: serverName('netmirror', platform.label), url: `${baseUrl}${playlistPath(episodeId)}` }];
589
+ return [
590
+ {
591
+ name: serverName('netmirror', platform.label),
592
+ url: `${baseUrl}${playlistPath(episodeId)}`,
593
+ label: platform.label,
594
+ },
595
+ ];
564
596
  };
565
597
 
566
598
  const qualityFromLabel = (label: string): string => {
@@ -625,7 +657,10 @@ function createNetMirror(ctx: ProviderContext, platform: NetMirrorPlatform, cust
625
657
  subtitles,
626
658
  };
627
659
  } catch (err) {
628
- throw new Error(`${config.name} fetchEpisodeSources failed: ${(err as Error).message}`);
660
+ throw providerError(`${config.name} fetchEpisodeSources failed: ${(err as Error).message}`, {
661
+ provider: config.name,
662
+ cause: err,
663
+ });
629
664
  }
630
665
  };
631
666
 
@@ -637,7 +672,10 @@ function createNetMirror(ctx: ProviderContext, platform: NetMirrorPlatform, cust
637
672
  const { data } = await axios.get<string>(master.url, { headers, responseType: 'text' });
638
673
  return data;
639
674
  } catch (err) {
640
- throw new Error(`${config.name} fetchHlsPlaylist failed: ${(err as Error).message}`);
675
+ throw providerError(`${config.name} fetchHlsPlaylist failed: ${(err as Error).message}`, {
676
+ provider: config.name,
677
+ cause: err,
678
+ });
641
679
  }
642
680
  };
643
681
 
@@ -3,8 +3,9 @@ const pathOf = (url: string): string => url.replace(/^https?:\/\/[^/]+/i, '').re
3
3
 
4
4
  /**
5
5
  * The id of a page on a movie site: its path below `baseUrl`, without slashes around it
6
- * (`https://himovies.sx/tv/watch-vincenzo-67955` -> `tv/watch-vincenzo-67955`). Only the path
7
- * counts, so a custom base URL and links to the site's other domains give the same ids.
6
+ * (`https://vegamovies.lease/download-breaking-bad-season-1-5/` ->
7
+ * `download-breaking-bad-season-1-5`). Only the path counts, so a custom base URL and links to the
8
+ * site's other domains give the same ids.
8
9
  */
9
10
  export function pageId(url: string, baseUrl: string): string {
10
11
  const path = pathOf(url);
@@ -12,6 +12,7 @@ import {
12
12
  } from '../../../models';
13
13
  import { isFastDl, isGofilePage, isHubCloudPage, qualityIn, unwrapFastDlUrl } from '../../../extractors/file-hosts';
14
14
  import { serverName } from '../../common/servers';
15
+ import { PAGE_TTL_MS, ttlCache } from '../../common/ttl-cache';
15
16
  import { pageId, pageUrl } from '../site-paths';
16
17
 
17
18
  const cleanTitle = (raw: string): string => {
@@ -57,6 +58,14 @@ const hostRank = (href: string) => DOWNLOAD_HOSTS.findIndex((host) => href.inclu
57
58
  // FastDL links come from the site's nexdrive pages, and FastDL wants a Referer from there.
58
59
  const NEXDRIVE_URL = 'https://nexdrive.fit/';
59
60
 
61
+ // Kept at the top level, so they outlive one provider instance (apps build one per query): a link
62
+ // page's (nexdrive) HTML by URL, when it links to a host, so servers, then sources, load it once.
63
+ const linkPages = ttlCache<any>({
64
+ ttlMs: PAGE_TTL_MS,
65
+ maxEntries: 16,
66
+ keep: (html) => typeof html === 'string' && /vcloud|hubcloud|fastdl|fsl\.|filebee|filepress|G-Direct/i.test(html),
67
+ });
68
+
60
69
  const qualityRank = (text: string): number => {
61
70
  if (/1080p|2160p|4k/i.test(text)) return 3;
62
71
  if (/720p/i.test(text)) return 2;
@@ -436,23 +445,75 @@ export function createVegaMovies(ctx: ProviderContext, customBaseURL?: string) {
436
445
  };
437
446
  };
438
447
 
439
- /** `source`, or when it is a Gofile page, the files on it (none when Gofile can't read it). */
440
- const resolveGofile = async (source: IVideo): Promise<IVideo[]> => {
441
- if (!isGofilePage(source.url)) return [source];
448
+ /**
449
+ * The files on a Gofile page (none when Gofile can't read it), and whether Gofile's API took or
450
+ * rejected the account token it keeps: a file (or an empty folder) says the token works, and
451
+ * `error-auth` that Gofile dropped it, so the next read gets a new one.
452
+ */
453
+ const readGofile = async (source: IVideo): Promise<{ files: IVideo[]; tokenChecked: boolean }> => {
442
454
  try {
443
455
  const { sources } = await Gofile(ctx).extract(new PolyURL(source.url));
444
- return sources.map((file) => ({ ...file, server: source.server, quality: source.quality, size: source.size }));
445
- } catch {
446
- return [];
456
+ const files = sources.map((file) => ({
457
+ ...file,
458
+ server: source.server,
459
+ quality: source.quality,
460
+ size: source.size,
461
+ }));
462
+ return { files, tokenChecked: true };
463
+ } catch (err) {
464
+ const message = String((err as Error | undefined)?.message);
465
+ return {
466
+ files: [],
467
+ tokenChecked: /^\[Gofile\] (API returned (error-auth|HTTP 401)$|No downloadable file)/.test(message),
468
+ };
469
+ }
470
+ };
471
+
472
+ /**
473
+ * Each source, or when it is a Gofile page, the files on it, in order. Gofile pages are read one
474
+ * at a time until one checks Gofile's account token, then the others all at once. The token is
475
+ * kept from earlier calls and may have expired: the first page read with it drops it and the
476
+ * others get a new one, as when every page was read one after another.
477
+ */
478
+ const resolveGofiles = async (sources: IVideo[]): Promise<IVideo[][]> => {
479
+ const resolved: (IVideo[] | Promise<IVideo[]>)[] = [];
480
+ let tokenChecked = false;
481
+ for (const source of sources) {
482
+ if (!isGofilePage(source.url)) {
483
+ resolved.push([source]);
484
+ } else if (tokenChecked) {
485
+ resolved.push(readGofile(source).then((read) => read.files));
486
+ } else {
487
+ const read = await readGofile(source);
488
+ tokenChecked = read.tokenChecked;
489
+ resolved.push(read.files);
490
+ }
491
+ }
492
+ return Promise.all(resolved);
493
+ };
494
+
495
+ /** The files a HubCloud page lists (its Gofile pages read), as sources of an episode of `quality`. */
496
+ const hubCloudFiles = async (url: string, quality: string) => {
497
+ const res = await readHubCloud(url);
498
+ const sources: IVideo[] = [];
499
+ for (const files of await resolveGofiles(res.sources)) {
500
+ for (const file of files) {
501
+ sources.push({ ...file, quality: file.quality && file.quality !== 'auto' ? file.quality : quality });
502
+ }
447
503
  }
504
+ return { sources, headers: res.headers };
448
505
  };
449
506
 
450
- /** The servers a HubCloud page lists, then the page itself (`hubcloud`), which fetchEpisodeSources reads again. */
507
+ /**
508
+ * The servers a HubCloud page lists, labelled with HubCloud's name for their host, then the page
509
+ * itself (`hubcloud`), which fetchEpisodeSources reads again.
510
+ */
451
511
  const hubCloudServers = async (url: string): Promise<IEpisodeServer[]> => {
452
512
  const servers: IEpisodeServer[] = [];
453
513
  try {
454
- for (const source of (await readHubCloud(url)).sources) {
455
- if (!servers.some((s) => s.name === source.server)) servers.push({ name: source.server!, url: source.url });
514
+ for (const source of (await HubCloud(ctx).extract(new PolyURL(url))).sources) {
515
+ const name = serverName('hubcloud', source.server);
516
+ if (!servers.some((s) => s.name === name)) servers.push({ name, url: source.url, label: source.server });
456
517
  }
457
518
  } catch {
458
519
  // The page itself stays a server.
@@ -461,6 +522,9 @@ export function createVegaMovies(ctx: ProviderContext, customBaseURL?: string) {
461
522
  return servers;
462
523
  };
463
524
 
525
+ /** A link page's (nexdrive) HTML, which servers, then sources, read (see linkPages). */
526
+ const linkPage = (url: string) => linkPages.get(url, async () => (await request(url)).data);
527
+
464
528
  /** Where a link page (nexdrive) sends the file: its HubCloud page and its FastDL and FilePress mirrors. */
465
529
  const linkPageHosts = (html: string) => {
466
530
  const $ = load(html);
@@ -484,7 +548,7 @@ export function createVegaMovies(ctx: ProviderContext, customBaseURL?: string) {
484
548
  if (isHubCloudPage(episodeUrl)) return hubCloudServers(episodeUrl);
485
549
  if (isFastDl(episodeUrl)) return [{ name: serverName('fastdl'), url: episodeUrl }];
486
550
 
487
- const hosts = linkPageHosts((await request(episodeUrl)).data);
551
+ const hosts = linkPageHosts(await linkPage(episodeUrl));
488
552
  const servers = hosts.hubCloud ? await hubCloudServers(hosts.hubCloud) : [];
489
553
  if (hosts.fastDl) servers.push({ name: serverName('fastdl'), url: hosts.fastDl });
490
554
  if (hosts.filePress) servers.push({ name: serverName('filepress'), url: hosts.filePress });
@@ -538,44 +602,31 @@ export function createVegaMovies(ctx: ProviderContext, customBaseURL?: string) {
538
602
  };
539
603
  }
540
604
 
541
- // A link page (nexdrive) links to the HubCloud page and to mirrors on FastDL and FilePress.
542
- // Each mirror is optional: when one fails, the others still play.
543
- const mirrors: IVideo[] = [];
605
+ // A link page (nexdrive) links to the HubCloud page and to mirrors on FastDL and FilePress, which
606
+ // all load at once. Each mirror is optional: when one fails, the others still play.
607
+ let hosts: ReturnType<typeof linkPageHosts> | undefined;
544
608
  let hubCloudUrl: string | undefined = episodeUrl;
545
609
  if (!isHubCloudPage(episodeUrl)) {
546
- const hosts = linkPageHosts((await request(episodeUrl)).data);
610
+ hosts = linkPageHosts(await linkPage(episodeUrl));
547
611
  hubCloudUrl = hosts.hubCloud;
548
- if (hosts.fastDl) {
549
- try {
550
- const file = await fastDlFile(hosts.fastDl, episodeUrl);
551
- if (file) mirrors.push(fileSource(file, 'fastdl'));
552
- } catch {}
553
- }
554
- if (hosts.filePress) {
555
- try {
556
- const file = await filePressFile(hosts.filePress);
557
- if (file) mirrors.push(fileSource(file, 'filepress'));
558
- } catch {}
559
- }
560
612
  }
613
+ const [fastDl, filePress, hubCloud] = await Promise.allSettled([
614
+ hosts?.fastDl ? fastDlFile(hosts.fastDl, episodeUrl) : undefined,
615
+ hosts?.filePress ? filePressFile(hosts.filePress) : undefined,
616
+ hubCloudUrl ? hubCloudFiles(hubCloudUrl, episodeQuality) : undefined,
617
+ ]);
618
+
619
+ const mirrors: IVideo[] = [];
620
+ if (fastDl.status === 'fulfilled' && fastDl.value) mirrors.push(fileSource(fastDl.value, 'fastdl'));
621
+ if (filePress.status === 'fulfilled' && filePress.value) mirrors.push(fileSource(filePress.value, 'filepress'));
561
622
 
562
623
  let headers: Record<string, string> = { Referer: baseUrl };
563
- const hubCloudSources: IVideo[] = [];
564
- if (hubCloudUrl) {
565
- try {
566
- const res = await readHubCloud(hubCloudUrl);
567
- for (const source of res.sources) {
568
- for (const file of await resolveGofile(source)) {
569
- hubCloudSources.push({
570
- ...file,
571
- quality: file.quality && file.quality !== 'auto' ? file.quality : episodeQuality,
572
- });
573
- }
574
- }
575
- headers = res.headers ?? headers;
576
- } catch (err) {
577
- if (!mirrors.length) throw err;
578
- }
624
+ let hubCloudSources: IVideo[] = [];
625
+ if (hubCloud.status === 'rejected') {
626
+ if (!mirrors.length) throw hubCloud.reason;
627
+ } else if (hubCloud.value) {
628
+ hubCloudSources = hubCloud.value.sources;
629
+ headers = hubCloud.value.headers ?? headers;
579
630
  }
580
631
 
581
632
  let sources = [...mirrors, ...hubCloudSources];
@@ -19,7 +19,7 @@ export interface ProviderClass<F extends ProviderFactory, B extends ParserClass>
19
19
  }
20
20
 
21
21
  /**
22
- * The class form of a provider factory, e.g. `providerClass(AnimeParser, createZoro)` for `new ANIME.Zoro()`.
22
+ * The class form of a provider factory, e.g. `providerClass(AnimeParser, createAniKoto)` for `new ANIME.AniKoto()`.
23
23
  * Registry code only has the factory; the class exists so bundled providers keep `new` and `instanceof`.
24
24
  */
25
25
  export function providerClass<F extends ProviderFactory, B extends ParserClass>(
@@ -10,6 +10,8 @@ type LoadedExtractor = { factory: ExtractorFactory; instance: IVideoExtractor };
10
10
  export class ExtractorManager {
11
11
  // Loads by `${extractor name}|${sha256}` (`|bundled` for extractors the registry lacks), see load
12
12
  private loads = new Map<string, Promise<LoadedExtractor>>();
13
+ // Lowercased names of the extractors prefetch has started loading
14
+ private prefetched = new Set<string>();
13
15
  private compiled: CompiledCodeCache;
14
16
  private registry = new Map<string, ExtractorInfo>();
15
17
  // Bundled extractors by lowercased name
@@ -93,14 +95,46 @@ export class ExtractorManager {
93
95
  return (await this.load(extractorId)).factory;
94
96
  }
95
97
 
98
+ /**
99
+ * Start loading the registry versions of `extractorIds` (extractor or server names) in the
100
+ * background, so the first loadExtractor of each shares a load already under way. Each extractor
101
+ * is prefetched once per manager. Names the registry lacks are skipped, nothing falls back to the
102
+ * bundled extractor, and failures are ignored: a failed load is forgotten as usual, so the next
103
+ * loadExtractor tries the registry again. Never throws.
104
+ */
105
+ prefetch(extractorIds: readonly string[]): void {
106
+ try {
107
+ if (!Array.isArray(extractorIds)) return;
108
+ for (const extractorId of extractorIds) {
109
+ if (typeof extractorId !== 'string') continue;
110
+ const metadata = this.getExtractorMetadata(extractorId);
111
+ if (!metadata) continue;
112
+ const name = metadata.name.toLowerCase();
113
+ if (this.prefetched.has(name)) continue;
114
+ this.prefetched.add(name);
115
+ this.registryLoad(name, metadata).catch(() => {});
116
+ }
117
+ } catch {
118
+ // A prefetch is only a head start.
119
+ }
120
+ }
121
+
96
122
  /**
97
123
  * Forget a loaded extractor and its compiled code, so the next load fetches and runs it again.
98
- * Takes the same names as loadExtractor ('megacloud-hd-1', 'MegaCloud').
124
+ * Takes the same names as loadExtractor ('megacloud-hd-1', 'MegaCloud'). Extractors whose code has
125
+ * the same sha256 share one compiled copy, so forgetting one forgets the others' loads and
126
+ * compiled code too.
99
127
  */
100
128
  invalidate(extractorId: string): void {
101
129
  const name = this.nameOf(extractorId);
102
- deleteEntriesOf(this.loads, name);
103
- this.compiled.forget(name);
130
+ const forgotten = new Set([name, ...this.compiled.forget(name)]);
131
+ const sha256 = this.registry.get(name)?.sha256;
132
+ if (sha256) for (const sibling of this.siblingsOf(sha256)) forgotten.add(sibling.name.toLowerCase());
133
+ for (const id of forgotten) {
134
+ deleteEntriesOf(this.loads, id);
135
+ this.compiled.forget(id);
136
+ this.prefetched.delete(id);
137
+ }
104
138
  }
105
139
 
106
140
  /**
@@ -134,20 +168,33 @@ export class ExtractorManager {
134
168
  if (!bundled) throw new Error(`Extractor '${extractorId}' not found in registry or static extractors`);
135
169
  return memoiseLoad(this.loads, `${name}|bundled`, async () => this.loaded(bundled));
136
170
  }
137
- // A version that needs a newer extension context is refused before it's downloaded. A failed
138
- // load isn't cached (memoiseLoad forgets it), so a network blip doesn't pin the bundled
139
- // version: the next load tries the registry again.
140
- const registryLoad = memoiseLoad(this.loads, `${name}|${metadata.sha256 ?? ''}`, async () => {
141
- assertCompatibleEntry(metadata);
142
- return this.loaded(this.compileExtractor(await fetchEntryCode('extractor', metadata.main), metadata));
143
- });
144
- return registryLoad.catch((error) => {
171
+ return this.registryLoad(name, metadata).catch((error) => {
145
172
  if (!bundled) throw error;
146
173
  console.warn(`Extractor '${metadata.name}' from the registry failed; using the bundled one:`, error);
147
174
  return this.loaded(bundled);
148
175
  });
149
176
  }
150
177
 
178
+ /**
179
+ * The registry version of the extractor `name` (lowercased), loaded once per sha256. A version
180
+ * that needs a newer extension context is refused before it's downloaded, and code this manager
181
+ * already verified against the entry's sha256 (executeExtractorCode with the same code, say) isn't
182
+ * downloaded again. A failed load isn't cached (memoiseLoad forgets it), so a network blip doesn't
183
+ * pin the bundled version: the next load tries the registry again.
184
+ */
185
+ private registryLoad(name: string, metadata: ExtractorInfo): Promise<LoadedExtractor> {
186
+ return memoiseLoad(this.loads, `${name}|${metadata.sha256 ?? ''}`, async () => {
187
+ assertCompatibleEntry(metadata);
188
+ const compiled = this.compiled.lookup(name, metadata.sha256, metadata.name);
189
+ return this.loaded(compiled ?? this.compileExtractor(await fetchEntryCode('extractor', metadata.main), metadata));
190
+ });
191
+ }
192
+
193
+ /** The registry extractors whose code has this sha256. */
194
+ private siblingsOf(sha256: string): ExtractorInfo[] {
195
+ return Array.from(this.registry.values()).filter((extractor) => extractor.sha256 === sha256);
196
+ }
197
+
151
198
  private loaded(factory: ExtractorFactory): LoadedExtractor {
152
199
  return { factory, instance: factory(this.context) };
153
200
  }
@@ -162,7 +209,46 @@ export class ExtractorManager {
162
209
  code,
163
210
  entry: metadata,
164
211
  globals: () => extensionGlobals('extractor', id, this.context),
212
+ siblings: () => (metadata?.sha256 ? this.siblingsOf(metadata.sha256).map((extractor) => extractor.name) : []),
165
213
  skipIntegrity: options.skipIntegrity,
166
214
  }) as ExtractorFactory;
167
215
  }
168
216
  }
217
+
218
+ // Hosts providers name servers after that aren't extractors (`fastdl`, `netmirror-netflix`).
219
+ const HOST_NAMES = ['FastDL', 'FilePress', 'NetMirror'];
220
+ const DISPLAY_NAMES = new Map(
221
+ [...Object.keys(defaultExtractors), ...HOST_NAMES].map((name): [string, string] => [name.toLowerCase(), name])
222
+ );
223
+ const ACRONYMS = new Set(['hd', 'sd', 'fhd', 'uhd', 'hq', 'cf']);
224
+
225
+ const capitalize = (word: string) => word.charAt(0).toUpperCase() + word.slice(1);
226
+
227
+ /** The label part of a server name, readable: `hd-1` -> `HD-1`, `cf-storage` -> `CF Storage`. */
228
+ function labelFromSlug(slug: string): string {
229
+ const words = slug.toLowerCase().split('-').filter(Boolean);
230
+ return words
231
+ .map((word, index) => {
232
+ const shown = ACRONYMS.has(word) || /^\d+k$/.test(word) ? word.toUpperCase() : capitalize(word);
233
+ if (index === 0) return shown;
234
+ return ACRONYMS.has(words[index - 1]!) && /^\d+$/.test(word) ? `-${shown}` : ` ${shown}`;
235
+ })
236
+ .join('');
237
+ }
238
+
239
+ /**
240
+ * A server's name for people: its extractor or host, then the site's `label` for it when the
241
+ * provider gives one (IEpisodeServer `label`), else the rest of `name` made readable.
242
+ * `('megaplay-hd-1', 'HD-1')` -> `MegaPlay · HD-1`, `('kwik-subsplease-1080', 'SubsPlease · 1080p')`
243
+ * -> `Kwik · SubsPlease · 1080p`, `('hubcloud-cf-storage')` -> `HubCloud · CF Storage`.
244
+ */
245
+ export function serverDisplayName(name: string, label?: string): string {
246
+ const [prefix = '', ...rest] = String(name ?? '')
247
+ .trim()
248
+ .split('-');
249
+ const host = DISPLAY_NAMES.get(prefix.toLowerCase()) ?? capitalize(prefix);
250
+ const shownLabel =
251
+ (typeof label === 'string' ? label.replace(/\s+/g, ' ').trim() : '') || labelFromSlug(rest.join('-'));
252
+ if (!host) return shownLabel;
253
+ return shownLabel && shownLabel.toLowerCase() !== host.toLowerCase() ? `${host} · ${shownLabel}` : host;
254
+ }