This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
96 lines (81 loc) · 2.92 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!doctype html>
<!--
绊爱日历项目Serverless API+OSS方案前端调用举例
作者:lwd-temp
日期:2022-03-01
-->
<html lang="zh">
<head>
<meta charset="utf-8">
<title>绊爱日历Serverless API+OSS方案Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script data-cfasync="false">
//启动vconsole
var src = '//unpkg.com/vconsole@latest/dist/vconsole.min.js';
document.write('<scr' + 'ipt src="' + src + '"></scr' + 'ipt>');
document.write('<scr' + 'ipt>var vConsole = new window.VConsole();</scr' + 'ipt>');
</script>
<link href="https://unpkg.com/[email protected]/dist/video-js.min.css" rel="stylesheet">
<script src="https://unpkg.com/[email protected]/dist/video.min.js"></script>
</head>
<body>
<p>基于哔哩哔哩用户<a href="https://space.bilibili.com/63045280">灰暗江原</a>的实现思路、源码和视频资源。</p><br>
<video-js id="ai-player"></video-js>
<script>
// 获取当前日期
var date = new Date();
// 获取当前月
var nowMonth = date.getMonth() + 1;
// 获取当前日
var strDate = date.getDate();
// 分隔符“-”
var seperator = "-";
// 对月进行处理,1-9月添加“0”
if (nowMonth >= 1 && nowMonth <= 9) {
nowMonth = "0" + nowMonth;
}
// 对日进行处理,1-9日添加“0”
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
// 拼接字符串,得到格式为(MM-dd)的日期
var nowDate = nowMonth + seperator + strDate;
console.log(nowDate);
// fetch请求
fetch('https://api.lwd-temp.top/api/kizunaai.php?id=63045280&date=' + nowDate).then(function (response) {
console.log(response);
return response.text();
}).then(function (data) {
console.log(data);
// API异常处理
if (data == 'error-00') {
alert('error-00 没有请求id');
return false;
}
else if (data == 'error-01') {
alert('error-01 请求id不存在');
return false;
}
else if (data == 'error-02') {
alert('error-02 数据错误');
return false;
}
else if (data == 'error-03') {
alert('error-03 无数据')
return false;
}
// 这里调用video.js,也可以直接用video标签,但这样似乎更方便
videojs('ai-player', {
autoplay: true,
controls: true,
preload: 'auto',
fluid: true,
sources: [{
src: data,
type: 'video/mp4'
}]
});
});
</script>
</body>
</html>