multi_embed_player 3.0.1 → 3.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.
- package/.github/workflows/build-and-deploy.yml +44 -0
- package/.gitmodules +3 -0
- package/CLAUDE.md +92 -0
- package/README.md +0 -24
- package/add_types.sh +61 -0
- package/browserExtention/chrome/background.js +55 -0
- package/browserExtention/chrome/extention.json +1 -0
- package/browserExtention/chrome/liteplayer.js +26439 -0
- package/browserExtention/chrome/manifest.json +31 -0
- package/browserExtention/chrome/player-selector.js +1854 -0
- package/browserExtention/firefox/background.js +27 -0
- package/browserExtention/firefox/extention.json +1 -0
- package/browserExtention/firefox/liteplayer.js +26439 -0
- package/browserExtention/firefox/manifest.json +19 -0
- package/browserExtention/firefox/player-selector.js +1854 -0
- package/documents/.hugo_build.lock +0 -0
- package/documents/archetypes/default.md +5 -0
- package/documents/assets/jsconfig.json +11 -0
- package/documents/content/docs/install.md +103 -0
- package/documents/content/docs/quickstart.md +51 -0
- package/documents/content/docs/reference/HTML.md +31 -0
- package/documents/content/docs/reference/_index.md +10 -0
- package/documents/content/docs/reference/error_code.md +23 -0
- package/documents/content/docs/reference/iframe_api.md +737 -0
- package/documents/content/docs/reference/iframe_class.md +230 -0
- package/documents/content/docs/reference/multi_embed_player_class.md +113 -0
- package/documents/content/docs/reference/reserved_words.md +71 -0
- package/documents/content/docs/usage/GDPR_mode.md +77 -0
- package/documents/content/docs/usage/_index.md +10 -0
- package/documents/content/docs/usage/custom_playlist.md +239 -0
- package/documents/content/docs/usage/embed_api.md +163 -0
- package/documents/content/docs/usage/embed_various_service.md +81 -0
- package/documents/content/docs/usage/thumbnail_click.md +57 -0
- package/documents/go.mod +8 -0
- package/documents/go.sum +14 -0
- package/documents/hugo.toml +18 -0
- package/documents/layouts/partials/docs/sidebar.html +117 -0
- package/documents/layouts/partials/landing/features.html +47 -0
- package/documents/layouts/robots.txt +4 -0
- package/documents/static/_headers +7 -0
- package/documents/static/localStorageCheck.html +27 -0
- package/documents/static/no_extention.json +1 -0
- package/example.html +27 -0
- package/extention.json +1 -0
- package/icon/video_not_found.odg +0 -0
- package/icon/video_not_found.svgz +0 -0
- package/iframe_api/bilibili.ts +1095 -0
- package/iframe_api/niconico.ts +429 -0
- package/iframe_api/soundcloud.ts +450 -0
- package/iframe_api/youtube.ts +311 -0
- package/multi_embed_player.ts +989 -0
- package/package.json +10 -41
- package/player_api_gate/bilibili-api-gate/cgi/cpp/bilibili-api-gate-cgi.cpp +281 -0
- package/player_api_gate/bilibili-api-gate/cgi/go/src.go +46 -0
- package/player_api_gate/bilibili-api-gate/cloudflare_workers/package-lock.json +1356 -0
- package/player_api_gate/bilibili-api-gate/cloudflare_workers/package.json +12 -0
- package/player_api_gate/bilibili-api-gate/cloudflare_workers/src/index.js +50 -0
- package/player_api_gate/bilibili-api-gate/cloudflare_workers/wrangler.toml +3 -0
- package/player_api_gate/iframe-api-ts/.editorconfig +12 -0
- package/player_api_gate/iframe-api-ts/.prettierrc +6 -0
- package/player_api_gate/iframe-api-ts/package-lock.json +3054 -0
- package/player_api_gate/iframe-api-ts/package.json +18 -0
- package/player_api_gate/iframe-api-ts/src/bilibili.ts +49 -0
- package/player_api_gate/iframe-api-ts/src/index.ts +35 -0
- package/player_api_gate/iframe-api-ts/src/niconico.ts +95 -0
- package/player_api_gate/iframe-api-ts/src/soundcloud.ts +38 -0
- package/player_api_gate/iframe-api-ts/src/types.ts +115 -0
- package/player_api_gate/iframe-api-ts/src/url-proxy.ts +29 -0
- package/player_api_gate/iframe-api-ts/src/utils.ts +82 -0
- package/player_api_gate/iframe-api-ts/src/youtube.ts +41 -0
- package/player_api_gate/iframe-api-ts/test/bilibili.spec.ts +47 -0
- package/player_api_gate/iframe-api-ts/test/env.d.ts +3 -0
- package/player_api_gate/iframe-api-ts/test/index.spec.ts +59 -0
- package/player_api_gate/iframe-api-ts/test/niconico.spec.ts +55 -0
- package/player_api_gate/iframe-api-ts/test/soundcloud.spec.ts +55 -0
- package/player_api_gate/iframe-api-ts/test/tsconfig.json +8 -0
- package/player_api_gate/iframe-api-ts/test/url-proxy.spec.ts +46 -0
- package/player_api_gate/iframe-api-ts/test/youtube.spec.ts +45 -0
- package/player_api_gate/iframe-api-ts/tsconfig.json +45 -0
- package/player_api_gate/iframe-api-ts/vitest.config.mts +11 -0
- package/player_api_gate/iframe-api-ts/worker-configuration.d.ts +5768 -0
- package/player_api_gate/iframe-api-ts/wrangler.jsonc +47 -0
- package/player_api_gate/iframe_api/.editorconfig +13 -0
- package/player_api_gate/iframe_api/.prettierrc +6 -0
- package/player_api_gate/iframe_api/package-lock.json +1307 -0
- package/player_api_gate/iframe_api/package.json +12 -0
- package/player_api_gate/iframe_api/src/bilibili_api.js +60 -0
- package/player_api_gate/iframe_api/src/index.js +47 -0
- package/player_api_gate/iframe_api/src/niconico_api.js +112 -0
- package/player_api_gate/iframe_api/src/soundcloud_api.js +57 -0
- package/player_api_gate/iframe_api/src/url_proxy.js +28 -0
- package/player_api_gate/iframe_api/src/youtube_api.js +44 -0
- package/player_api_gate/iframe_api/wrangler.toml +51 -0
- package/player_api_gate/niconico-imager/cgi/go/src.go +74 -0
- package/player_api_gate/niconico-imager/cloudflare_workers/package-lock.json +2175 -0
- package/player_api_gate/niconico-imager/cloudflare_workers/package.json +12 -0
- package/player_api_gate/niconico-imager/cloudflare_workers/src/index.js +78 -0
- package/player_api_gate/niconico-imager/cloudflare_workers/wrangler.toml +3 -0
- package/test_script.html +172 -0
- package/tsconfig.json +36 -0
- package/dist/iframe_api/bilibili.d.ts +0 -91
- package/dist/iframe_api/bilibili.d.ts.map +0 -1
- package/dist/iframe_api/bilibili.js +0 -451
- package/dist/iframe_api/bilibili.js.map +0 -1
- package/dist/iframe_api/index.d.ts +0 -6
- package/dist/iframe_api/index.d.ts.map +0 -1
- package/dist/iframe_api/index.js +0 -8
- package/dist/iframe_api/index.js.map +0 -1
- package/dist/iframe_api/niconico.d.ts +0 -42
- package/dist/iframe_api/niconico.d.ts.map +0 -1
- package/dist/iframe_api/niconico.js +0 -181
- package/dist/iframe_api/niconico.js.map +0 -1
- package/dist/iframe_api/soundcloud.d.ts +0 -80
- package/dist/iframe_api/soundcloud.d.ts.map +0 -1
- package/dist/iframe_api/soundcloud.js +0 -188
- package/dist/iframe_api/soundcloud.js.map +0 -1
- package/dist/iframe_api/youtube.d.ts +0 -133
- package/dist/iframe_api/youtube.d.ts.map +0 -1
- package/dist/iframe_api/youtube.js +0 -278
- package/dist/iframe_api/youtube.js.map +0 -1
- package/dist/multi_embed_player.d.ts +0 -48
- package/dist/multi_embed_player.d.ts.map +0 -1
- package/dist/multi_embed_player.js +0 -318
- package/dist/multi_embed_player.js.map +0 -1
- package/dist/types.d.ts +0 -126
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -22
- package/dist/types.js.map +0 -1
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import { PlayerState, ErrorCode } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Class representing a YouTube player.
|
|
4
|
-
*/
|
|
5
|
-
export class mep_youtube {
|
|
6
|
-
/**
|
|
7
|
-
* Load YouTube Iframe API asynchronously.
|
|
8
|
-
*/
|
|
9
|
-
async load_youtube_api() {
|
|
10
|
-
return new Promise((resolve) => {
|
|
11
|
-
if (mep_youtube.youtube_api_loaded === 0) {
|
|
12
|
-
mep_youtube.youtube_api_loaded = 1;
|
|
13
|
-
const script_doc = document.createElement("script");
|
|
14
|
-
script_doc.src = "https://www.youtube.com/iframe_api";
|
|
15
|
-
script_doc.addEventListener("load", () => {
|
|
16
|
-
window.YT.ready(() => {
|
|
17
|
-
mep_youtube.youtube_api_promise.forEach(func => func());
|
|
18
|
-
mep_youtube.youtube_api_loaded = 2;
|
|
19
|
-
resolve();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
document.body.appendChild(script_doc);
|
|
23
|
-
}
|
|
24
|
-
else if (mep_youtube.youtube_api_loaded === 1) {
|
|
25
|
-
mep_youtube.youtube_api_promise.push(resolve);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
resolve();
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Create a new YouTube player instance.
|
|
34
|
-
*/
|
|
35
|
-
constructor(replacing_element, content, player_set_event_function) {
|
|
36
|
-
this.autoplay = 0;
|
|
37
|
-
this.startSeconds = 0;
|
|
38
|
-
this.endSeconds = -1;
|
|
39
|
-
this.load(replacing_element, content, player_set_event_function);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Load the YouTube player.
|
|
43
|
-
*/
|
|
44
|
-
async load(replacing_element, content, player_set_event_function) {
|
|
45
|
-
this.player = document.createElement("div"); // dummy
|
|
46
|
-
if (typeof player_set_event_function === "function") {
|
|
47
|
-
player_set_event_function();
|
|
48
|
-
}
|
|
49
|
-
await this.load_youtube_api();
|
|
50
|
-
let iframe_replace_node;
|
|
51
|
-
if (typeof replacing_element === "string") {
|
|
52
|
-
const element = document.getElementById(replacing_element);
|
|
53
|
-
if (!element) {
|
|
54
|
-
throw new Error(`Element with id "${replacing_element}" not found`);
|
|
55
|
-
}
|
|
56
|
-
iframe_replace_node = element;
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
iframe_replace_node = replacing_element;
|
|
60
|
-
}
|
|
61
|
-
const playerVars = content.playerVars || {};
|
|
62
|
-
const player_vars_pass_over = {};
|
|
63
|
-
this.autoplay = 0;
|
|
64
|
-
if (playerVars.autoplay) {
|
|
65
|
-
this.autoplay = 1;
|
|
66
|
-
player_vars_pass_over.autoplay = 1;
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
player_vars_pass_over.autoplay = 0;
|
|
70
|
-
}
|
|
71
|
-
this.startSeconds = 0;
|
|
72
|
-
this.endSeconds = -1;
|
|
73
|
-
if (playerVars.startSeconds) {
|
|
74
|
-
this.startSeconds = playerVars.startSeconds;
|
|
75
|
-
player_vars_pass_over.start = playerVars.startSeconds;
|
|
76
|
-
}
|
|
77
|
-
if (playerVars.endSeconds) {
|
|
78
|
-
this.endSeconds = playerVars.endSeconds;
|
|
79
|
-
player_vars_pass_over.end = playerVars.endSeconds;
|
|
80
|
-
}
|
|
81
|
-
this.el = iframe_replace_node;
|
|
82
|
-
this.YT_player = new window.YT.Player(iframe_replace_node, {
|
|
83
|
-
height: "315",
|
|
84
|
-
width: "560",
|
|
85
|
-
videoId: content.videoId,
|
|
86
|
-
playerVars: player_vars_pass_over,
|
|
87
|
-
host: "https://www.youtube-nocookie.com",
|
|
88
|
-
events: {
|
|
89
|
-
onReady: () => {
|
|
90
|
-
this.dispatch_event(new Event("onReady"));
|
|
91
|
-
},
|
|
92
|
-
onError: (e) => {
|
|
93
|
-
this.error_event_handler(e);
|
|
94
|
-
},
|
|
95
|
-
onStateChange: () => {
|
|
96
|
-
this.dispatch_event(new CustomEvent("onStateChange", { detail: this.getPlayerState() }));
|
|
97
|
-
if (this.getPlayerState() === PlayerState.ENDED) {
|
|
98
|
-
this.dispatch_event(new Event("onEndVideo"));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
if (!this.autoplay) {
|
|
104
|
-
this.player.addEventListener("onReady", () => {
|
|
105
|
-
this.pauseVideo();
|
|
106
|
-
}, { once: true });
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Handle error events from the player.
|
|
111
|
-
*/
|
|
112
|
-
error_event_handler(event) {
|
|
113
|
-
let code = 520;
|
|
114
|
-
switch (event.data) {
|
|
115
|
-
case 2:
|
|
116
|
-
code = ErrorCode.INVALID_PARAMETER;
|
|
117
|
-
break;
|
|
118
|
-
case 5:
|
|
119
|
-
code = ErrorCode.HTML5_ERROR;
|
|
120
|
-
break;
|
|
121
|
-
case 100:
|
|
122
|
-
code = ErrorCode.VIDEO_NOT_FOUND;
|
|
123
|
-
break;
|
|
124
|
-
case 101:
|
|
125
|
-
case 150:
|
|
126
|
-
code = ErrorCode.EMBED_NOT_ALLOWED;
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
this.player.dispatchEvent(new CustomEvent("onError", { detail: { code } }));
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Dispatch event to the player element.
|
|
133
|
-
*/
|
|
134
|
-
dispatch_event(event) {
|
|
135
|
-
this.player.dispatchEvent(event);
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Play the video.
|
|
139
|
-
*/
|
|
140
|
-
playVideo() {
|
|
141
|
-
this.YT_player.playVideo();
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Pause the video.
|
|
145
|
-
*/
|
|
146
|
-
pauseVideo() {
|
|
147
|
-
this.YT_player.pauseVideo();
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Get the current time of the video.
|
|
151
|
-
*/
|
|
152
|
-
getCurrentTime() {
|
|
153
|
-
return this.YT_player.getCurrentTime();
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Get the duration of the video.
|
|
157
|
-
*/
|
|
158
|
-
getDuration() {
|
|
159
|
-
return this.YT_player.getDuration();
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Get the actual duration between the start and end times.
|
|
163
|
-
*/
|
|
164
|
-
getRealDulation() {
|
|
165
|
-
if (this.endSeconds == -1) {
|
|
166
|
-
return this.getDuration() - this.startSeconds;
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
return this.endSeconds - this.startSeconds;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Seek to a specific time in the video.
|
|
174
|
-
*/
|
|
175
|
-
seekTo(time) {
|
|
176
|
-
// try to time as number
|
|
177
|
-
time = Number(time);
|
|
178
|
-
if (isNaN(time)) {
|
|
179
|
-
console.error("time is not a number(Nan error)");
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
if (time < 0) {
|
|
183
|
-
time = 0;
|
|
184
|
-
}
|
|
185
|
-
this.YT_player.seekTo(time);
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Set the volume of the player.
|
|
189
|
-
*/
|
|
190
|
-
setVolume(volume) {
|
|
191
|
-
if (typeof volume === "number" && volume >= 0 && volume <= 100) {
|
|
192
|
-
this.YT_player.setVolume(volume);
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
console.error("volume is not a number or not in range 0-100");
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Mute the player.
|
|
200
|
-
*/
|
|
201
|
-
mute() {
|
|
202
|
-
this.YT_player.mute();
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Unmute the player.
|
|
206
|
-
*/
|
|
207
|
-
unMute() {
|
|
208
|
-
this.YT_player.unMute();
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Check if the player is muted.
|
|
212
|
-
*/
|
|
213
|
-
isMuted() {
|
|
214
|
-
return this.YT_player.isMuted();
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Get the current volume of the player.
|
|
218
|
-
*/
|
|
219
|
-
getVolume() {
|
|
220
|
-
return this.YT_player.getVolume();
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Get the current state of the player.
|
|
224
|
-
*/
|
|
225
|
-
getPlayerState() {
|
|
226
|
-
let nowstatus = this.YT_player.getPlayerState();
|
|
227
|
-
if ((this.getCurrentTime() > this.getDuration() - 1 && this.getCurrentTime() != 0 && this.getDuration() != 0) || (this.endSeconds != -1 && this.endSeconds - 1 <= this.getCurrentTime())) {
|
|
228
|
-
return PlayerState.ENDED;
|
|
229
|
-
}
|
|
230
|
-
else if (nowstatus == -1) {
|
|
231
|
-
return PlayerState.UNSTARTED;
|
|
232
|
-
}
|
|
233
|
-
else if (nowstatus == 0) {
|
|
234
|
-
return PlayerState.ENDED;
|
|
235
|
-
}
|
|
236
|
-
else if (nowstatus == 1) {
|
|
237
|
-
return PlayerState.PLAYING;
|
|
238
|
-
}
|
|
239
|
-
else if (nowstatus == 2) {
|
|
240
|
-
return PlayerState.PAUSED;
|
|
241
|
-
}
|
|
242
|
-
else if (nowstatus == 3 || nowstatus == 5) {
|
|
243
|
-
return PlayerState.BUFFERING;
|
|
244
|
-
}
|
|
245
|
-
return PlayerState.UNSTARTED;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Get the title of the currently loaded video.
|
|
249
|
-
*/
|
|
250
|
-
getTitle() {
|
|
251
|
-
return this.YT_player.getVideoData().title;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Load a new video by ID.
|
|
255
|
-
*/
|
|
256
|
-
loadVideoById(content, startSeconds) {
|
|
257
|
-
if (typeof content === "object") {
|
|
258
|
-
this.YT_player.loadVideoById(content.videoId, startSeconds);
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
this.YT_player.loadVideoById(content, startSeconds);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Cue a new video by ID.
|
|
266
|
-
*/
|
|
267
|
-
cueVideoById(content, startSeconds) {
|
|
268
|
-
if (typeof content === "object") {
|
|
269
|
-
this.YT_player.cueVideoById(content.videoId, startSeconds);
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
this.YT_player.cueVideoById(content, startSeconds);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
mep_youtube.youtube_api_loaded = 0;
|
|
277
|
-
mep_youtube.youtube_api_promise = [];
|
|
278
|
-
//# sourceMappingURL=youtube.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"youtube.js","sourceRoot":"","sources":["../../iframe_api/youtube.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,WAAW,EAAE,SAAS,EAAgB,MAAM,UAAU,CAAC;AAyC5G;;GAE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,OAAc,EAAE,YAAY,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,OAAuB,EAAE,YAAqB;QACzD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QAC7D,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,OAAc,EAAE,YAAY,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;;AA1Sc,8BAAkB,GAAW,CAAC,AAAZ,CAAa;AAC/B,+BAAmB,GAAsB,EAAE,AAAxB,CAAyB"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { ApiCache, ApiPromise, GDPRAccepted, MEPStatusLoadApi, MEPLoadApiPromise, IframeApiClass, TearmsPolicyService } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* A custom HTML element for embedding multiple video services in a single player.
|
|
4
|
-
* @extends HTMLElement
|
|
5
|
-
*/
|
|
6
|
-
export declare class multi_embed_player extends HTMLElement {
|
|
7
|
-
static script_origin: string;
|
|
8
|
-
static iframe_api_endpoint: string;
|
|
9
|
-
static mep_status_load_api: MEPStatusLoadApi;
|
|
10
|
-
static mep_load_api_promise: MEPLoadApiPromise;
|
|
11
|
-
static api_cache: ApiCache;
|
|
12
|
-
static api_promise: ApiPromise;
|
|
13
|
-
static GDPR_accept_promise: MEPLoadApiPromise;
|
|
14
|
-
static iframe_api_class: IframeApiClass;
|
|
15
|
-
static GDPR_accepted: GDPRAccepted;
|
|
16
|
-
static possible_direct_access_services: string[];
|
|
17
|
-
static cors_proxy: string;
|
|
18
|
-
static tearms_policy_service: TearmsPolicyService;
|
|
19
|
-
static follow_GDPR: boolean;
|
|
20
|
-
private videoid;
|
|
21
|
-
private service;
|
|
22
|
-
private image_url?;
|
|
23
|
-
private picture_tag?;
|
|
24
|
-
private follow_GDPR;
|
|
25
|
-
constructor();
|
|
26
|
-
connectedCallback(): Promise<void>;
|
|
27
|
-
/**
|
|
28
|
-
* Asynchronously fetches the image URL for a given video ID and service.
|
|
29
|
-
*/
|
|
30
|
-
private mep_imageurl;
|
|
31
|
-
/**
|
|
32
|
-
* Checks the status of an image URL.
|
|
33
|
-
*/
|
|
34
|
-
private check_image_status;
|
|
35
|
-
/**
|
|
36
|
-
* This function adds an iframe to the current element.
|
|
37
|
-
*/
|
|
38
|
-
private add_iframe;
|
|
39
|
-
/**
|
|
40
|
-
* Plays a video on the specified player with the given parameters.
|
|
41
|
-
*/
|
|
42
|
-
private play_on_player;
|
|
43
|
-
/**
|
|
44
|
-
* Adds a new play item to the playlist of the player.
|
|
45
|
-
*/
|
|
46
|
-
private add_playlist;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=multi_embed_player.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"multi_embed_player.d.ts","sourceRoot":"","sources":["../multi_embed_player.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EAIpB,MAAM,SAAS,CAAC;AA0MjB;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,WAAW;IACjD,MAAM,CAAC,aAAa,EAAE,MAAM,CAAsE;IAClG,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAA6C;IAC/E,MAAM,CAAC,mBAAmB,EAAE,gBAAgB,CAA2D;IACvG,MAAM,CAAC,oBAAoB,EAAE,iBAAiB,CAA+D;IAC7G,MAAM,CAAC,SAAS,EAAE,QAAQ,CAA+D;IACzF,MAAM,CAAC,WAAW,EAAE,UAAU,CAA+D;IAC7F,MAAM,CAAC,mBAAmB,EAAE,iBAAiB,CAA+D;IAC5G,MAAM,CAAC,gBAAgB,EAAE,cAAc,CAAM;IAC7C,MAAM,CAAC,aAAa,EAAE,YAAY,CAA2E;IAC7G,MAAM,CAAC,+BAA+B,EAAE,MAAM,EAAE,CAA6B;IAC7E,MAAM,CAAC,UAAU,EAAE,MAAM,CAAM;IAC/B,MAAM,CAAC,qBAAqB,EAAE,mBAAmB,CAK/C;IACF,MAAM,CAAC,WAAW,EAAE,OAAO,CAAS;IAEpC,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,SAAS,CAAC,CAAgB;IAClC,OAAO,CAAC,WAAW,CAAC,CAAqB;IACzC,OAAO,CAAC,WAAW,CAAU;;IAOvB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAwCxC;;OAEG;YACW,YAAY;IA0C1B;;OAEG;YACW,kBAAkB;IAYhC;;OAEG;YACW,UAAU;IAIxB;;OAEG;IACH,OAAO,CAAC,cAAc;IAItB;;OAEG;IACH,OAAO,CAAC,YAAY;CAGrB"}
|
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
import { ErrorCode } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* Fetches the iframe API for a given service and video ID.
|
|
4
|
-
*/
|
|
5
|
-
const multi_embed_player_fetch_iframe_api = async (service, videoid, use_cors, image_proxy, GDPR_access_accept, failed_send_error = false, failed_send_error_target = null) => {
|
|
6
|
-
const xml_first_search = (data, search_string, start = 0) => {
|
|
7
|
-
return data.substring(data.indexOf("<" + search_string + ">", start) + search_string.length + 2, data.indexOf("</" + search_string + ">", start));
|
|
8
|
-
};
|
|
9
|
-
const possible_direct_access = GDPR_access_accept && multi_embed_player.possible_direct_access_services.includes(service);
|
|
10
|
-
if (use_cors || possible_direct_access) {
|
|
11
|
-
let url = "";
|
|
12
|
-
if (possible_direct_access) {
|
|
13
|
-
url = "";
|
|
14
|
-
}
|
|
15
|
-
else if (multi_embed_player.cors_proxy !== "") {
|
|
16
|
-
url = multi_embed_player.cors_proxy;
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
url = `${multi_embed_player.iframe_api_endpoint}?route=url_proxy&url=`;
|
|
20
|
-
}
|
|
21
|
-
let first_access = false;
|
|
22
|
-
if (!multi_embed_player.api_promise[service]) {
|
|
23
|
-
multi_embed_player.api_promise[service] = {};
|
|
24
|
-
}
|
|
25
|
-
if (multi_embed_player.api_promise[service][videoid] === undefined) {
|
|
26
|
-
multi_embed_player.api_promise[service][videoid] = { res: [], rej: [] };
|
|
27
|
-
first_access = true;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
await new Promise((resolve, reject) => {
|
|
31
|
-
const promise_data = multi_embed_player.api_promise[service][videoid];
|
|
32
|
-
if (promise_data) {
|
|
33
|
-
promise_data.res.push(resolve);
|
|
34
|
-
promise_data.rej.push(reject);
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
try {
|
|
39
|
-
if (first_access) {
|
|
40
|
-
switch (service) {
|
|
41
|
-
case 'soundcloud':
|
|
42
|
-
const numericRegex = /^[0-9]+$/;
|
|
43
|
-
let url_oembed;
|
|
44
|
-
if (numericRegex.test(videoid)) {
|
|
45
|
-
url_oembed = `https://soundcloud.com/oembed?url=https://api.soundcloud.com/tracks/${videoid}&format=json`;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
url_oembed = `https://soundcloud.com/oembed?url=https://soundcloud.com/${videoid}&format=json`;
|
|
49
|
-
}
|
|
50
|
-
const oembed_response_fetch = await fetch(url + encodeURI(url_oembed));
|
|
51
|
-
const oembed_response = await oembed_response_fetch.json();
|
|
52
|
-
oembed_response["image_base64"] = url + oembed_response["thumbnail_url"];
|
|
53
|
-
multi_embed_player.api_cache[service][videoid] = oembed_response;
|
|
54
|
-
break;
|
|
55
|
-
case 'niconico':
|
|
56
|
-
const xml_response = await (await fetch(url + `https://ext.nicovideo.jp/api/getthumbinfo/${videoid}`)).text();
|
|
57
|
-
let image_url = xml_first_search(xml_response, "thumbnail_url");
|
|
58
|
-
const predict_long = 43 + 2 * (videoid.length - 2);
|
|
59
|
-
const return_data = {};
|
|
60
|
-
if (image_url.length > predict_long) {
|
|
61
|
-
image_url += ".L";
|
|
62
|
-
}
|
|
63
|
-
if (image_url === "<?xml version=") {
|
|
64
|
-
return_data["status"] = "invalid videoid";
|
|
65
|
-
return_data["thumbnail_url"] = "";
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
return_data["status"] = "success";
|
|
69
|
-
return_data["thumbnail_url"] = image_url;
|
|
70
|
-
const search_element_names = {
|
|
71
|
-
video_id: "video_id",
|
|
72
|
-
title: "title",
|
|
73
|
-
description: "description",
|
|
74
|
-
length: "length",
|
|
75
|
-
view_counter: "view_count",
|
|
76
|
-
comment_num: "comment_count",
|
|
77
|
-
mylist_counter: "mylist_count",
|
|
78
|
-
first_retrieve: "publish_time",
|
|
79
|
-
embeddable: "embedable",
|
|
80
|
-
genre: "genre"
|
|
81
|
-
};
|
|
82
|
-
Object.keys(search_element_names).forEach(key_name => return_data[search_element_names[key_name]] = xml_first_search(xml_response, key_name));
|
|
83
|
-
}
|
|
84
|
-
multi_embed_player.api_cache[service][videoid] = return_data;
|
|
85
|
-
break;
|
|
86
|
-
case 'bilibili':
|
|
87
|
-
const json_response_bilibili = await (await fetch(url + `https://api.bilibili.com/x/web-interface/view?bvid=${videoid}`)).json();
|
|
88
|
-
if (json_response_bilibili?.data?.pic === undefined) {
|
|
89
|
-
json_response_bilibili["image_base64"] = null;
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
json_response_bilibili["image_base64"] = url + json_response_bilibili.data.pic;
|
|
93
|
-
}
|
|
94
|
-
multi_embed_player.api_cache[service][videoid] = json_response_bilibili;
|
|
95
|
-
break;
|
|
96
|
-
case "youtube":
|
|
97
|
-
try {
|
|
98
|
-
const json_response_youtube = await (await fetch(url + `https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=${videoid}&format=json`)).json();
|
|
99
|
-
json_response_youtube["image_base64"] = url + json_response_youtube["thumbnail_url"];
|
|
100
|
-
multi_embed_player.api_cache[service][videoid] = json_response_youtube;
|
|
101
|
-
}
|
|
102
|
-
catch {
|
|
103
|
-
multi_embed_player.api_cache[service][videoid] = {};
|
|
104
|
-
}
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
const promise_data = multi_embed_player.api_promise[service]?.[videoid];
|
|
108
|
-
if (promise_data) {
|
|
109
|
-
promise_data.res.forEach(resolve => resolve());
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
catch {
|
|
114
|
-
const promise_data = multi_embed_player.api_promise[service]?.[videoid];
|
|
115
|
-
if (promise_data && "rej" in promise_data) {
|
|
116
|
-
promise_data.rej.forEach(reject => reject());
|
|
117
|
-
}
|
|
118
|
-
if (failed_send_error && failed_send_error_target !== null) {
|
|
119
|
-
failed_send_error_target.dispatchEvent(new CustomEvent("onError", { detail: { code: ErrorCode.NETWORK_ERROR } }));
|
|
120
|
-
}
|
|
121
|
-
multi_embed_player.api_cache[service][videoid] = {};
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
let fetch_response;
|
|
126
|
-
try {
|
|
127
|
-
const url = `${multi_embed_player.iframe_api_endpoint}?route=${service}&videoid=${videoid}` + (image_proxy ? "&image_base64=1" : "");
|
|
128
|
-
if (multi_embed_player.api_promise[service]?.[videoid] === undefined) {
|
|
129
|
-
if (!multi_embed_player.api_promise[service]) {
|
|
130
|
-
multi_embed_player.api_promise[service] = {};
|
|
131
|
-
}
|
|
132
|
-
multi_embed_player.api_promise[service][videoid] = { res: [], rej: [] };
|
|
133
|
-
fetch_response = await fetch(url);
|
|
134
|
-
multi_embed_player.api_cache[service][videoid] = await fetch_response.json();
|
|
135
|
-
multi_embed_player.api_promise[service][videoid].res.forEach(resolve => resolve());
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
await new Promise((resolve, reject) => {
|
|
139
|
-
multi_embed_player.api_promise[service][videoid].res.push(resolve);
|
|
140
|
-
multi_embed_player.api_promise[service][videoid].rej.push(reject);
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
catch (e) {
|
|
145
|
-
const promise_data = multi_embed_player.api_promise[service]?.[videoid];
|
|
146
|
-
if (promise_data && "rej" in promise_data) {
|
|
147
|
-
promise_data.rej.forEach(reject => reject());
|
|
148
|
-
}
|
|
149
|
-
if (failed_send_error && failed_send_error_target !== null) {
|
|
150
|
-
failed_send_error_target.dispatchEvent(new CustomEvent("onError", { detail: { code: ErrorCode.NETWORK_ERROR } }));
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
multi_embed_player.api_cache[service][videoid] = {};
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
/**
|
|
159
|
-
* Resets all values in multi_embed_player.GDPR_accepted to false and removes the corresponding item from localStorage.
|
|
160
|
-
*/
|
|
161
|
-
const multi_embed_player_GDPR_accepted_all_back_down = () => {
|
|
162
|
-
Object.keys(multi_embed_player.GDPR_accepted).forEach(key => multi_embed_player.GDPR_accepted[key] = false);
|
|
163
|
-
localStorage.removeItem('multi_embed_player_GDPR_accepted');
|
|
164
|
-
};
|
|
165
|
-
/**
|
|
166
|
-
* A custom HTML element for embedding multiple video services in a single player.
|
|
167
|
-
* @extends HTMLElement
|
|
168
|
-
*/
|
|
169
|
-
export class multi_embed_player extends HTMLElement {
|
|
170
|
-
constructor() {
|
|
171
|
-
super();
|
|
172
|
-
this.videoid = null;
|
|
173
|
-
this.follow_GDPR = multi_embed_player.follow_GDPR;
|
|
174
|
-
}
|
|
175
|
-
async connectedCallback() {
|
|
176
|
-
if (this.getAttribute("follow_GDPR") === "true") {
|
|
177
|
-
this.follow_GDPR = true;
|
|
178
|
-
}
|
|
179
|
-
if (this.getAttribute("type") === null || this.getAttribute("type") === "embed" || this.getAttribute("type") === "thumbnail-click") {
|
|
180
|
-
this.videoid = this.getAttribute("videoid");
|
|
181
|
-
this.service = this.getAttribute("service");
|
|
182
|
-
if (this.getAttribute("img_url") != null) {
|
|
183
|
-
this.image_url = this.getAttribute("img_url");
|
|
184
|
-
}
|
|
185
|
-
else if (this.getAttribute("picture_tag") != null) {
|
|
186
|
-
this.picture_tag = document.createElement("picture");
|
|
187
|
-
this.appendChild(this.picture_tag);
|
|
188
|
-
this.picture_tag.innerHTML = this.getAttribute("picture_tag");
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
this.image_url = await this.mep_imageurl(this.videoid, this.service);
|
|
192
|
-
if (!await this.check_image_status(this.image_url)) {
|
|
193
|
-
this.image_url = await this.mep_imageurl(this.getAttribute("subVideoid"), this.getAttribute("subService"));
|
|
194
|
-
if (!await this.check_image_status(this.image_url)) {
|
|
195
|
-
this.style.backgroundImage = `${multi_embed_player.script_origin}icon/video_not_found.svgz`;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
if (typeof this.image_url === "string") {
|
|
200
|
-
this.style.backgroundImage = `url(${this.image_url})`;
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
this.style.backgroundImage = `url(${multi_embed_player.script_origin}icon/video_not_found.svgz)`;
|
|
204
|
-
}
|
|
205
|
-
//status setting
|
|
206
|
-
if (this.getAttribute("type") === null || this.getAttribute("type") === "embed") {
|
|
207
|
-
this.addEventListener('click', this.add_iframe, { once: true });
|
|
208
|
-
}
|
|
209
|
-
if (this.getAttribute("type") === "thumbnail-click") {
|
|
210
|
-
this.addEventListener('click', () => { this.play_on_player(this.getAttribute("for"), this.getAttribute("service"), this.getAttribute("videoid"), this.getAttribute("start"), this.getAttribute("end"), this.getAttribute("subService"), this.getAttribute("subVideoid")); });
|
|
211
|
-
this.addEventListener('contextmenu', (e) => { e.preventDefault(); this.add_playlist(); });
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
else if (this.getAttribute("type") === "player") {
|
|
215
|
-
// player initialization
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Asynchronously fetches the image URL for a given video ID and service.
|
|
220
|
-
*/
|
|
221
|
-
async mep_imageurl(videoid, service) {
|
|
222
|
-
let GDPR_accepted = false;
|
|
223
|
-
if (!this.follow_GDPR) {
|
|
224
|
-
GDPR_accepted = true;
|
|
225
|
-
}
|
|
226
|
-
else if (this.follow_GDPR && !multi_embed_player.GDPR_accepted[service]) {
|
|
227
|
-
GDPR_accepted = false;
|
|
228
|
-
}
|
|
229
|
-
else if (this.follow_GDPR && multi_embed_player.GDPR_accepted[service]) {
|
|
230
|
-
GDPR_accepted = true;
|
|
231
|
-
}
|
|
232
|
-
let image_url = "";
|
|
233
|
-
let use_cors = false;
|
|
234
|
-
if (GDPR_accepted) {
|
|
235
|
-
if (multi_embed_player.cors_proxy !== "") {
|
|
236
|
-
image_url = multi_embed_player.cors_proxy;
|
|
237
|
-
use_cors = true;
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
image_url = `${multi_embed_player.iframe_api_endpoint}?route=url_proxy&url=`;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
if (multi_embed_player.cors_proxy !== "") {
|
|
244
|
-
use_cors = true;
|
|
245
|
-
}
|
|
246
|
-
if (!GDPR_accepted || service === "bilibili") {
|
|
247
|
-
if (!(videoid in multi_embed_player.api_cache[service])) {
|
|
248
|
-
await multi_embed_player_fetch_iframe_api(service, videoid, use_cors, true, false);
|
|
249
|
-
}
|
|
250
|
-
return multi_embed_player.api_cache[service][videoid]["image_base64"];
|
|
251
|
-
}
|
|
252
|
-
else if (service === "soundcloud" || service === "youtube" || service === "niconico") {
|
|
253
|
-
if (!(videoid in multi_embed_player.api_cache[service])) {
|
|
254
|
-
await multi_embed_player_fetch_iframe_api(service, videoid, use_cors, !GDPR_accepted, GDPR_accepted);
|
|
255
|
-
}
|
|
256
|
-
if (!GDPR_accepted) {
|
|
257
|
-
return multi_embed_player.api_cache[service][videoid]["image_base64"];
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
return multi_embed_player.api_cache[service][videoid]["thumbnail_url"];
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
return "invalid_url";
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Checks the status of an image URL.
|
|
269
|
-
*/
|
|
270
|
-
async check_image_status(img_url) {
|
|
271
|
-
if (typeof img_url !== "string") {
|
|
272
|
-
return false;
|
|
273
|
-
}
|
|
274
|
-
const img = new Image();
|
|
275
|
-
img.src = img_url;
|
|
276
|
-
return new Promise((resolve) => {
|
|
277
|
-
img.onload = () => { img.remove(); resolve(true); };
|
|
278
|
-
img.onerror = () => { img.remove(); resolve(false); };
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* This function adds an iframe to the current element.
|
|
283
|
-
*/
|
|
284
|
-
async add_iframe() {
|
|
285
|
-
// Implementation here
|
|
286
|
-
}
|
|
287
|
-
/**
|
|
288
|
-
* Plays a video on the specified player with the given parameters.
|
|
289
|
-
*/
|
|
290
|
-
play_on_player(playerid, service, videoid, start, end, subService, subVideoid) {
|
|
291
|
-
// Implementation here
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Adds a new play item to the playlist of the player.
|
|
295
|
-
*/
|
|
296
|
-
add_playlist() {
|
|
297
|
-
// Implementation here
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
multi_embed_player.script_origin = "https://cdn.jsdelivr.net/gh/bonjinnorenka/multi_embed_player@v3/";
|
|
301
|
-
multi_embed_player.iframe_api_endpoint = "https://iframe_api.ryokuryu.workers.dev";
|
|
302
|
-
multi_embed_player.mep_status_load_api = { youtube: 0, niconico: 0, bilibili: 0, soundcloud: 0 };
|
|
303
|
-
multi_embed_player.mep_load_api_promise = { youtube: [], niconico: [], bilibili: [], soundcloud: [] };
|
|
304
|
-
multi_embed_player.api_cache = { niconico: {}, bilibili: {}, soundcloud: {}, youtube: {} };
|
|
305
|
-
multi_embed_player.api_promise = { niconico: {}, bilibili: {}, soundcloud: {}, youtube: {} };
|
|
306
|
-
multi_embed_player.GDPR_accept_promise = { youtube: [], niconico: [], bilibili: [], soundcloud: [] };
|
|
307
|
-
multi_embed_player.iframe_api_class = {};
|
|
308
|
-
multi_embed_player.GDPR_accepted = { youtube: false, niconico: false, bilibili: false, soundcloud: false };
|
|
309
|
-
multi_embed_player.possible_direct_access_services = ["youtube", "soundcloud"];
|
|
310
|
-
multi_embed_player.cors_proxy = ""; // if cors_proxy is not empty string, it use instead of iframe_api_endpoint and follow gdpr
|
|
311
|
-
multi_embed_player.tearms_policy_service = {
|
|
312
|
-
"youtube": "https://www.youtube.com/t/terms",
|
|
313
|
-
"niconico": "https://account.nicovideo.jp/rules/account?language=en-us",
|
|
314
|
-
"bilibili": "https://www.bilibili.com/blackboard/protocal/activity-lc1L-pIoh.html",
|
|
315
|
-
"soundcloud": "https://soundcloud.com/pages/privacy"
|
|
316
|
-
};
|
|
317
|
-
multi_embed_player.follow_GDPR = false;
|
|
318
|
-
//# sourceMappingURL=multi_embed_player.js.map
|