FEATURE: bilibili embedded video

This commit is contained in:
FarseaSH 2022-06-05 17:43:24 +08:00
parent 8d5ac2c8dc
commit 4a238a7927
2 changed files with 33 additions and 0 deletions

View file

@ -250,6 +250,22 @@ p{
}
}
.bilibili-video {
position: relative;
max-width: 85%;
height: 0;
padding-bottom: 45%;
margin-bottom: 10px;
iframe {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
}
}
// for the note info
.moment-note{
display: flex;

View file

@ -37,6 +37,17 @@
{{ $netease_music_song_id = replaceRE `(https?://)?music\.163\.com/song\?id=([0-9]*)([-a-zA-Z0-9()@:%\+.~#?&/=_]*)` "$2" .a }}
{{ end }}
{{/* 2.2 bilibili video */}}
{{ $bilibili_video_url := "0" }}
{{ if eq 1 (len (findRE `(https?://)?player\.bilibili\.com/player\.html.*` .a)) }}
{{ $resource_type = "bilibili_video" }}
{{ $bilibili_video_url = .a }}
{{ end }}
{{ if eq 1 (len (findRE `<iframe src="(//player\.bilibili.com/player\.html\?aid=.*&bvid=.*&cid=.*&page=1)" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>` .a)) }}
{{ $resource_type = "bilibili_video" }}
{{ $bilibili_video_url = replaceRE `<iframe src="(//player\.bilibili.com/player\.html\?aid=.*&bvid=.*&cid=.*&page=1)" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>` "$1" .a }}
{{ end }}
{{/* BEGIN generate output */}}
{{/* PART 1 default link */}}
@ -67,3 +78,9 @@
src="//music.163.com/outchain/player?type=2&id={{ $netease_music_song_id }}&auto=1&height=66">
</iframe>
{{ end }}
{{ if eq "bilibili_video" $resource_type}}
<div class="bilibili-video">
<iframe src="{{ $bilibili_video_url }}" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"></iframe>
</div>
{{ end }}