@kyun.si/codex-hongguo 0.0.0-stage → 0.0.21
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.
- package/.codex-plugin/plugin.json +19 -0
- package/.mcp.json +11 -0
- package/LICENSE +21 -0
- package/README.en.md +131 -0
- package/README.md +129 -2
- package/bin/codex-hongguo.mjs +3 -0
- package/bin/run-node +29 -0
- package/bin/run-node.exe +0 -0
- package/dist/cli/main.mjs +8 -0
- package/dist/hooks/write.mjs +46 -0
- package/dist/server/index.mjs +147 -0
- package/dist/setup/check.mjs +47 -0
- package/dist/ui/player.html +2067 -0
- package/dist/vendor/openhongguo/GO_LICENSE +27 -0
- package/dist/vendor/openhongguo/LICENSE +202 -0
- package/dist/vendor/openhongguo/README.md +283 -0
- package/dist/vendor/openhongguo/dist/openhongguo.wasm +0 -0
- package/dist/vendor/openhongguo/dist/wasm_exec.js +575 -0
- package/dist/vendor/openhongguo/index.d.ts +212 -0
- package/dist/vendor/openhongguo/index.js +297 -0
- package/dist/vendor/openhongguo/package.json +46 -0
- package/dist/vendor/openhongguo/types.d.ts +887 -0
- package/docs/images/codex-hongguo-catalog.png +0 -0
- package/docs/images/codex-hongguo-player.png +0 -0
- package/hooks/hooks.json +40 -0
- package/licenses/@babel-runtime-LICENSE +22 -0
- package/licenses/@hono-node-server-LICENSE +21 -0
- package/licenses/@modelcontextprotocol-ext-apps-LICENSE +216 -0
- package/licenses/@modelcontextprotocol-sdk-LICENSE +21 -0
- package/licenses/@standard-schema-spec-LICENSE +21 -0
- package/licenses/@videojs-vhs-utils-LICENSE +19 -0
- package/licenses/@xmldom-xmldom-LICENSE +8 -0
- package/licenses/PROJECT-NOTICE.txt +1 -0
- package/licenses/accepts-LICENSE +23 -0
- package/licenses/ajv-LICENSE +22 -0
- package/licenses/ajv-formats-LICENSE +21 -0
- package/licenses/body-parser-LICENSE +23 -0
- package/licenses/body-parser-content-type-LICENSE +22 -0
- package/licenses/bytes-LICENSE +23 -0
- package/licenses/call-bind-apply-helpers-LICENSE +21 -0
- package/licenses/call-bound-LICENSE +21 -0
- package/licenses/content-disposition-LICENSE +22 -0
- package/licenses/content-type-LICENSE +22 -0
- package/licenses/cookie-LICENSE +24 -0
- package/licenses/cookie-signature-LICENSE +22 -0
- package/licenses/cors-LICENSE +22 -0
- package/licenses/cross-spawn-LICENSE +21 -0
- package/licenses/debug-LICENSE +20 -0
- package/licenses/depd-LICENSE +22 -0
- package/licenses/dom-walk-LICENCE +19 -0
- package/licenses/dunder-proto-LICENSE +21 -0
- package/licenses/ee-first-LICENSE +22 -0
- package/licenses/encodeurl-LICENSE +22 -0
- package/licenses/es-define-property-LICENSE +21 -0
- package/licenses/es-errors-LICENSE +21 -0
- package/licenses/es-object-atoms-LICENSE +21 -0
- package/licenses/escape-html-LICENSE +24 -0
- package/licenses/etag-LICENSE +22 -0
- package/licenses/eventsource-LICENSE +22 -0
- package/licenses/eventsource-parser-LICENSE +21 -0
- package/licenses/express-LICENSE +24 -0
- package/licenses/express-content-type-LICENSE +22 -0
- package/licenses/express-rate-limit-license +21 -0
- package/licenses/fast-deep-equal-LICENSE +21 -0
- package/licenses/fast-uri-LICENSE +30 -0
- package/licenses/finalhandler-LICENSE +22 -0
- package/licenses/forwarded-LICENSE +22 -0
- package/licenses/fresh-LICENSE +23 -0
- package/licenses/function-bind-LICENSE +20 -0
- package/licenses/get-intrinsic-LICENSE +21 -0
- package/licenses/get-proto-LICENSE +21 -0
- package/licenses/global-LICENSE +19 -0
- package/licenses/gopd-LICENSE +21 -0
- package/licenses/has-symbols-LICENSE +21 -0
- package/licenses/hasown-LICENSE +21 -0
- package/licenses/hls.js-LICENSE +28 -0
- package/licenses/hono-LICENSE +21 -0
- package/licenses/http-errors-LICENSE +23 -0
- package/licenses/iconv-lite-LICENSE +21 -0
- package/licenses/inherits-LICENSE +16 -0
- package/licenses/ip-address-LICENSE +19 -0
- package/licenses/ipaddr.js-LICENSE +19 -0
- package/licenses/is-promise-LICENSE +19 -0
- package/licenses/isexe-LICENSE +15 -0
- package/licenses/jose-LICENSE.md +21 -0
- package/licenses/json-schema-traverse-LICENSE +21 -0
- package/licenses/json-schema-typed-LICENSE.md +57 -0
- package/licenses/m3u8-parser-LICENSE +13 -0
- package/licenses/math-intrinsics-LICENSE +21 -0
- package/licenses/media-typer-LICENSE +22 -0
- package/licenses/merge-descriptors-license +11 -0
- package/licenses/mime-db-LICENSE +23 -0
- package/licenses/mime-types-LICENSE +23 -0
- package/licenses/min-document-LICENCE +19 -0
- package/licenses/mpd-parser-LICENSE +13 -0
- package/licenses/ms-license.md +21 -0
- package/licenses/negotiator-LICENSE +24 -0
- package/licenses/negotiator-content-type-LICENSE +22 -0
- package/licenses/object-assign-license +21 -0
- package/licenses/object-inspect-LICENSE +21 -0
- package/licenses/on-finished-LICENSE +23 -0
- package/licenses/once-LICENSE +15 -0
- package/licenses/openhongguo-LICENSE +202 -0
- package/licenses/parseurl-LICENSE +24 -0
- package/licenses/path-key-license +9 -0
- package/licenses/path-to-regexp-LICENSE +21 -0
- package/licenses/pkce-challenge-LICENSE +21 -0
- package/licenses/process-LICENSE +22 -0
- package/licenses/proxy-addr-LICENSE +22 -0
- package/licenses/qs-LICENSE.md +29 -0
- package/licenses/range-parser-LICENSE +23 -0
- package/licenses/raw-body-LICENSE +22 -0
- package/licenses/require-from-string-license +21 -0
- package/licenses/router-LICENSE +23 -0
- package/licenses/safer-buffer-LICENSE +21 -0
- package/licenses/send-LICENSE +23 -0
- package/licenses/serve-static-LICENSE +25 -0
- package/licenses/setprototypeof-LICENSE +13 -0
- package/licenses/shebang-command-license +9 -0
- package/licenses/shebang-regex-license +9 -0
- package/licenses/side-channel-LICENSE +21 -0
- package/licenses/side-channel-list-LICENSE +21 -0
- package/licenses/side-channel-map-LICENSE +21 -0
- package/licenses/side-channel-weakmap-LICENSE +21 -0
- package/licenses/statuses-LICENSE +23 -0
- package/licenses/toidentifier-LICENSE +21 -0
- package/licenses/type-is-LICENSE +23 -0
- package/licenses/type-is-content-type-LICENSE +22 -0
- package/licenses/unpipe-LICENSE +22 -0
- package/licenses/vary-LICENSE +22 -0
- package/licenses/which-LICENSE +15 -0
- package/licenses/wrappy-LICENSE +15 -0
- package/licenses/zod-LICENSE +21 -0
- package/licenses/zod-to-json-schema-LICENSE +15 -0
- package/package.json +37 -4
- package/skills/hongguo-setup/SKILL.md +16 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Copyright 2009 The Go Authors.
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
|
4
|
+
modification, are permitted provided that the following conditions are
|
|
5
|
+
met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright
|
|
8
|
+
notice, this list of conditions and the following disclaimer.
|
|
9
|
+
* Redistributions in binary form must reproduce the above
|
|
10
|
+
copyright notice, this list of conditions and the following disclaimer
|
|
11
|
+
in the documentation and/or other materials provided with the
|
|
12
|
+
distribution.
|
|
13
|
+
* Neither the name of Google LLC nor the names of its
|
|
14
|
+
contributors may be used to endorse or promote products derived from
|
|
15
|
+
this software without specific prior written permission.
|
|
16
|
+
|
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
18
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
19
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
20
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
21
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
22
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
23
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
24
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
25
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
26
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
27
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
# openhongguo(Node.js)
|
|
2
|
+
|
|
3
|
+
openhongguo 是红果短剧(Hongguo)的非官方 Node.js SDK。SDK 可以浏览短剧目录、搜索短剧,并取得分集的播放地址。
|
|
4
|
+
|
|
5
|
+
SDK 用匿名设备发送所有请求。SDK 不需要登录。
|
|
6
|
+
|
|
7
|
+
SDK 的核心是 Go SDK 编译成的 WebAssembly,所以 Node.js SDK 与 Go SDK 的行为相同。
|
|
8
|
+
|
|
9
|
+
> **免责声明**:本仓库的所有内容仅供学习和参考之用,禁止用于商业用途。使用前请阅读[完整的免责声明](https://github.com/beilunyang/openhongguo#免责声明)。使用本仓库的内容即表示您同意其所有条款和条件。
|
|
10
|
+
|
|
11
|
+
术语的含义见[根目录 README 的术语表](https://github.com/beilunyang/openhongguo#术语)。
|
|
12
|
+
|
|
13
|
+
## 快速上手
|
|
14
|
+
|
|
15
|
+
下面的代码搜索一部短剧,然后取得第 1 集的播放地址。
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { createClient } from 'openhongguo';
|
|
19
|
+
|
|
20
|
+
const client = await createClient();
|
|
21
|
+
const page = await client.search('全球死考');
|
|
22
|
+
const episodes = await client.listEpisodes(page.items[0].id);
|
|
23
|
+
const { playback } = await client.resolvePlayback(episodes.items[0].id);
|
|
24
|
+
console.log(playback.streams.map((s) => `${s.definition} ${s.url}`));
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
第一次请求时,SDK 注册一台匿名设备,并保存设备档案。以后的请求都使用这台匿名设备。
|
|
28
|
+
|
|
29
|
+
## 安装
|
|
30
|
+
|
|
31
|
+
需要 Node.js 20 或更高版本。
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
npm install openhongguo
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
> **注意**:这个包只支持 ES 模块(`import`)。
|
|
38
|
+
|
|
39
|
+
## 接口
|
|
40
|
+
|
|
41
|
+
所有方法都返回 Promise。如果方法失败,它抛出 `OpenhongguoError`。
|
|
42
|
+
|
|
43
|
+
<!-- gen:methods -->
|
|
44
|
+
<!-- 由 go run ./bindings/docgen 生成,请修改 sdk 的 Go 注释,不要手工修改。 -->
|
|
45
|
+
|
|
46
|
+
### 发现与搜索
|
|
47
|
+
|
|
48
|
+
| 方法 | 作用 |
|
|
49
|
+
|---|---|
|
|
50
|
+
| `discover(options)` | 加载书城的一个频道,默认是“推荐” |
|
|
51
|
+
| `discoverAll(options)` | 逐页遍历书城的一个频道,并去掉跨页重复的短剧 |
|
|
52
|
+
| `search(query, options)` | 搜索短剧,可以按真人剧、漫剧等筛选 |
|
|
53
|
+
| `searchAll(query, options)` | 逐页遍历搜索结果,并去掉跨页重复的短剧 |
|
|
54
|
+
| `suggest(prefix)` | 返回某个前缀的搜索联想词 |
|
|
55
|
+
| `hotSearch()` | 加载搜索页的“猜你想搜”和各个热搜榜 |
|
|
56
|
+
| `searchCues()` | 加载搜索框里轮播的提示词 |
|
|
57
|
+
| `newReleases(query)` | 加载上新日历的一页 |
|
|
58
|
+
|
|
59
|
+
### 短剧与分集
|
|
60
|
+
|
|
61
|
+
| 方法 | 作用 |
|
|
62
|
+
|---|---|
|
|
63
|
+
| `getSeries(seriesId)` | 加载一部短剧的详情 |
|
|
64
|
+
| `getSeriesBatch(seriesIds)` | 加载多部短剧及其分集,按请求顺序返回 |
|
|
65
|
+
| `listEpisodes(seriesId, options)` | 加载一部短剧的分集列表 |
|
|
66
|
+
| `seasons(seriesId)` | 列出多季短剧的全部季 |
|
|
67
|
+
| `seriesRecommend(seriesId)` | 加载一部短剧的相关推荐 |
|
|
68
|
+
| `getAlbum(albumId)` | 加载一个合集(多季合集)及其各季 |
|
|
69
|
+
|
|
70
|
+
### 榜单与分类
|
|
71
|
+
|
|
72
|
+
| 方法 | 作用 |
|
|
73
|
+
|---|---|
|
|
74
|
+
| `shortRank(query)` | 加载短剧排行榜的一页,包括演员榜 |
|
|
75
|
+
| `shortFilterPanel(genre)` | 加载短剧筛选面板的各个选择行 |
|
|
76
|
+
| `shortFilter(query)` | 按条件筛选短剧,一次一页 |
|
|
77
|
+
| `rankRows(cellId, offset)` | 加载书城榜单的一页(经典频道的榜单入口) |
|
|
78
|
+
| `rankGroups()` | 列出书城榜单的类型(经典频道的各个榜单) |
|
|
79
|
+
| `ranking(activityId, rankListId)` | 加载一个活动榜单 |
|
|
80
|
+
| `categories(categoryId)` | 加载书籍分类的标签页:全部、男生、女生和默认标签页 |
|
|
81
|
+
| `categoryLanding(categoryId, options)` | 加载书籍分类下列表的一页,以及它的筛选面板 |
|
|
82
|
+
|
|
83
|
+
### 演员
|
|
84
|
+
|
|
85
|
+
| 方法 | 作用 |
|
|
86
|
+
|---|---|
|
|
87
|
+
| `person(userId)` | 加载一位演员或一个角色的主页 |
|
|
88
|
+
| `personWorks(userId, cursor)` | 加载一位演员参演的短剧,一次一页(主页上的作品 › 剧作) |
|
|
89
|
+
|
|
90
|
+
### 播放与设备
|
|
91
|
+
|
|
92
|
+
| 方法 | 作用 |
|
|
93
|
+
|---|---|
|
|
94
|
+
| `resolvePlayback(episodeId)` | 加载一集的播放模型:各清晰度的地址、编码和码率 |
|
|
95
|
+
| `resetDevice()` | 丢弃当前匿名设备,并注册一台新设备 |
|
|
96
|
+
<!-- /gen:methods -->
|
|
97
|
+
|
|
98
|
+
参数和返回值的类型见 `index.d.ts` 和 `types.d.ts`。类型定义由 Go 源码生成,字段说明与 Go SDK 相同。
|
|
99
|
+
|
|
100
|
+
### 翻页
|
|
101
|
+
|
|
102
|
+
`discoverAll` 和 `searchAll` 逐部遍历带游标的列表。服务端会在不同的页中返回同一部短剧。这两个方法删除重复的短剧。
|
|
103
|
+
|
|
104
|
+
```js
|
|
105
|
+
for await (const series of client.searchAll('末世', {}, { maxPages: 3 })) {
|
|
106
|
+
console.log(series.id, series.title);
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 搜索筛选
|
|
111
|
+
|
|
112
|
+
`SearchFilter` 提供“综合”分类的筛选项。
|
|
113
|
+
|
|
114
|
+
```js
|
|
115
|
+
import { SearchFilter } from 'openhongguo';
|
|
116
|
+
|
|
117
|
+
await client.search('奇幻', { filters: [SearchFilter.ShortPlay, SearchFilter.Film] });
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
| 筛选项 | 含义 |
|
|
121
|
+
|---|---|
|
|
122
|
+
| `ShortPlay` | 真人剧 |
|
|
123
|
+
| `Comic` | 漫剧 |
|
|
124
|
+
| `AIComic` | AI 剧 |
|
|
125
|
+
| `Film` | 影视剧 |
|
|
126
|
+
| `Unwatched` | 未看过 |
|
|
127
|
+
|
|
128
|
+
### 加密分集
|
|
129
|
+
|
|
130
|
+
`resolvePlayback` 返回 `{ playback, contentKey }`。如果分集是加密的,`playback.protected` 是 `true`,`contentKey.key` 是内容密钥。加密方式是 cenc-aes-ctr。
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
const { playback, contentKey } = await client.resolvePlayback(episodeId);
|
|
134
|
+
if (playback.protected) {
|
|
135
|
+
// 例如:ffmpeg -decryption_key <key> -i <url> -c copy out.mp4
|
|
136
|
+
console.log(contentKey.key);
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
如果 SDK 不能推导内容密钥,结果中没有 `contentKey`。`contentKeyError` 给出原因。播放模型仍然正常返回。
|
|
141
|
+
|
|
142
|
+
## 字段命名
|
|
143
|
+
|
|
144
|
+
| 方向 | 风格 | 示例 |
|
|
145
|
+
|---|---|---|
|
|
146
|
+
| 返回值 | 下划线风格,与 Go SDK 的 JSON 相同 | `has_more`、`cover_url`、`episode_count` |
|
|
147
|
+
| 查询参数 | 驼峰风格 | `pageSize`、`cursor` |
|
|
148
|
+
|
|
149
|
+
返回值的字段名也与 CLI 的 `--json` 输出相同。
|
|
150
|
+
|
|
151
|
+
## 设置
|
|
152
|
+
|
|
153
|
+
`createClient(options)` 的设置都是可选的。
|
|
154
|
+
|
|
155
|
+
| 设置 | 作用 |
|
|
156
|
+
|---|---|
|
|
157
|
+
| `profile` | 设备档案的位置:文件路径,或自定义的存储对象 |
|
|
158
|
+
| `transport` | 自定义的请求发送函数 |
|
|
159
|
+
| `timeoutMs` | 默认发送函数的超时,单位是毫秒。默认值是 30000 |
|
|
160
|
+
| `retryAttempts` | 可重试的失败的最多尝试次数。默认值是 3 |
|
|
161
|
+
| `deviceResets` | 设备被拒或播放返回空结果时,一次调用最多更换几台匿名设备。默认值是 2,0 表示关闭 |
|
|
162
|
+
| `device` | 新匿名设备的机型。空字段使用默认值(小米 14) |
|
|
163
|
+
| `log` | 接收诊断日志的函数。日志中的 URL 已经脱敏 |
|
|
164
|
+
| `apiOrigin`、`registerOrigin`、`distributionOrigin` | 接口地址。默认值与 App 相同 |
|
|
165
|
+
|
|
166
|
+
### 设备档案
|
|
167
|
+
|
|
168
|
+
设备档案的默认位置是 `<用户配置目录>/openhongguo/anonymous.json`。CLI 使用同一个设备档案。
|
|
169
|
+
|
|
170
|
+
| 系统 | 默认位置 |
|
|
171
|
+
|---|---|
|
|
172
|
+
| macOS | `~/Library/Application Support/openhongguo/anonymous.json` |
|
|
173
|
+
| 其他系统 | `<用户配置目录>/openhongguo/anonymous.json` |
|
|
174
|
+
|
|
175
|
+
如果要更改目录,设置环境变量 `OHG_CONFIG_DIR`。
|
|
176
|
+
|
|
177
|
+
如果只把设备档案保存在内存中,使用 `memoryProfileStore`。进程退出后,设备档案丢失。
|
|
178
|
+
|
|
179
|
+
```js
|
|
180
|
+
import { createClient, memoryProfileStore } from 'openhongguo';
|
|
181
|
+
|
|
182
|
+
const client = await createClient({ profile: memoryProfileStore() });
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
自定义的存储对象必须实现三个异步方法:
|
|
186
|
+
|
|
187
|
+
| 方法 | 作用 |
|
|
188
|
+
|---|---|
|
|
189
|
+
| `load()` | 读取设备档案。如果没有设备档案,返回 `null` |
|
|
190
|
+
| `save(json)` | 保存设备档案 |
|
|
191
|
+
| `reset()` | 删除设备档案 |
|
|
192
|
+
|
|
193
|
+
### 自定义请求
|
|
194
|
+
|
|
195
|
+
`transport` 接收一个请求对象,返回一个响应对象。
|
|
196
|
+
|
|
197
|
+
```js
|
|
198
|
+
const client = await createClient({
|
|
199
|
+
transport: async ({ method, url, headers, body }) => {
|
|
200
|
+
// ……发送请求……
|
|
201
|
+
return { status, headers, cookies, body }; // body 是 Uint8Array
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
> **注意**:响应体必须是原始字节。不要自动解压响应体。SDK 根据 `Content-Encoding` 自己解压。
|
|
207
|
+
|
|
208
|
+
> **注意**:只在没有收到响应时,`transport` 才抛出错误。如果收到 HTTP 错误状态码,正常返回响应。SDK 判断状态码。
|
|
209
|
+
|
|
210
|
+
## 错误处理
|
|
211
|
+
|
|
212
|
+
所有错误都是 `OpenhongguoError`。`OpenhongguoError` 有三个属性:
|
|
213
|
+
|
|
214
|
+
| 属性 | 含义 |
|
|
215
|
+
|---|---|
|
|
216
|
+
| `code` | 错误码,例如 `RATE_LIMITED`、`CONTENT_UNAVAILABLE`、`DEVICE_REJECTED` |
|
|
217
|
+
| `retryable` | 重试同一请求能否成功 |
|
|
218
|
+
| `retryAfterMs` | 服务端建议的等待时间,单位是毫秒。0 表示没有建议 |
|
|
219
|
+
|
|
220
|
+
```js
|
|
221
|
+
import { OpenhongguoError } from 'openhongguo';
|
|
222
|
+
|
|
223
|
+
try {
|
|
224
|
+
await client.getSeries(seriesId);
|
|
225
|
+
} catch (e) {
|
|
226
|
+
if (e instanceof OpenhongguoError && e.code === 'CONTENT_UNAVAILABLE') {
|
|
227
|
+
console.log('这部短剧已下架');
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
下表列出所有错误码。
|
|
233
|
+
|
|
234
|
+
<!-- gen:errors -->
|
|
235
|
+
<!-- 由 go run ./bindings/docgen 生成,请修改 sdk 的 Go 注释,不要手工修改。 -->
|
|
236
|
+
|
|
237
|
+
| 错误码 | 含义 | 可重试 |
|
|
238
|
+
|---|---|---|
|
|
239
|
+
| `INVALID_OPTIONS` | 客户端的设置或调用参数无效 | 否 |
|
|
240
|
+
| `PROFILE_NOT_FOUND` | 还没有保存过设备档案 | 否 |
|
|
241
|
+
| `SIGNER_UNAVAILABLE` | 请求需要签名,而客户端没有可用的签名器 | 否 |
|
|
242
|
+
| `AUTHENTICATION_REQUIRED` | 内容需要登录才能访问,匿名客户端无法继续 | 否 |
|
|
243
|
+
| `NOT_PROTECTED` | 为未加密的播放模型请求了内容密钥 | 否 |
|
|
244
|
+
| `DRM_PROTECTED` | 分集是加密的,需要内容密钥才能解密 | 否 |
|
|
245
|
+
| `ANONYMOUS_LIMITED` | 服务端给匿名设备返回了空结果 | 否 |
|
|
246
|
+
| `RATE_LIMITED` | 请求太频繁,被服务端限流 | 是 |
|
|
247
|
+
| `TRANSPORT` | 网络请求失败 | 是 |
|
|
248
|
+
| `SIGNATURE_REJECTED` | 服务端拒绝了请求的签名 | 否 |
|
|
249
|
+
| `CONTENT_UNAVAILABLE` | 内容已下架、不存在,或当前调用方无权访问 | 否 |
|
|
250
|
+
| `PARAM_INVALID` | 服务端认为请求参数无效 | 否 |
|
|
251
|
+
| `CHALLENGE_REQUIRED` | 服务端要求验证码或其他验证,匿名客户端无法继续 | 否 |
|
|
252
|
+
| `DEVICE_REJECTED` | 匿名设备被拒绝,需要重置设备后重新注册 | 否 |
|
|
253
|
+
| `END_OF_LIST` | 列表已经没有更多内容 | 否 |
|
|
254
|
+
| `ALBUM_UNAVAILABLE` | 匿名读取不到这个合集,或者这部短剧没有其他季 | 否 |
|
|
255
|
+
| `CANCELLED` | 调用被取消 | 否 |
|
|
256
|
+
<!-- /gen:errors -->
|
|
257
|
+
|
|
258
|
+
## 实现原理
|
|
259
|
+
|
|
260
|
+
`dist/openhongguo.wasm` 是 Go SDK 编译成的 WebAssembly。桥接代码在 `bindings/node/wasm` 中。方法表在 `bindings/internal/dispatch` 中,Android SDK 和 iOS SDK 也使用它。
|
|
261
|
+
|
|
262
|
+
| 工作 | 执行者 |
|
|
263
|
+
|---|---|
|
|
264
|
+
| 发送请求 | JS。Go 把请求传给 `transport`。默认的 `transport` 使用 `node:https` |
|
|
265
|
+
| 读写设备档案 | JS。Go 通过 `profile` 的三个方法读写 JSON |
|
|
266
|
+
| 执行 SDK 方法 | Go。每个方法在一个 goroutine 中运行,结果以 JSON 返回给 JS |
|
|
267
|
+
|
|
268
|
+
第一次调用 `createClient` 时,SDK 加载 wasm。加载需要几百毫秒。同一进程中的所有客户端共用一个 wasm 实例。
|
|
269
|
+
|
|
270
|
+
## 开发
|
|
271
|
+
|
|
272
|
+
从源码构建需要 Go 1.22 或更高版本。在本目录中运行以下命令。
|
|
273
|
+
|
|
274
|
+
| 命令 | 作用 |
|
|
275
|
+
|---|---|
|
|
276
|
+
| `npm run build` | 编译 wasm,复制 `wasm_exec.js`,重新生成 `types.d.ts` |
|
|
277
|
+
| `npm test` | 用 `testdata/protocol` 的样本回放测试。测试不访问网络 |
|
|
278
|
+
|
|
279
|
+
> **注意**:不要手工修改 `types.d.ts`。`go run ./bindings/node/tsgen` 生成这个文件。仓库根目录的 `go test ./...` 检查它是否过时。
|
|
280
|
+
|
|
281
|
+
## 许可证
|
|
282
|
+
|
|
283
|
+
本包使用 Apache License 2.0 许可证。`dist/wasm_exec.js` 来自 Go 项目,使用 BSD 许可证,全文见 `GO_LICENSE`。
|
|
Binary file
|