-
Notifications
You must be signed in to change notification settings - Fork 88
/
bootstrap.php
115 lines (114 loc) · 4.26 KB
/
bootstrap.php
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/**
* @package s9e\mediaembed
* @copyright Copyright (c) 2015 The s9e Authors
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
namespace s9e\Flarum\MediaEmbed;
use Flarum\Event\ConfigureFormatter;
use Illuminate\Events\Dispatcher;
use s9e\TextFormatter\Configurator\Bundles\MediaPack;
function subscribe(Dispatcher $events)
{
$events->listen(
ConfigureFormatter::class,
function (ConfigureFormatter $event)
{
$event->configurator->Autoimage;
$event->configurator->MediaEmbed->add(
'music163',
[
'host' => 'music.163.com',
'extract' => '!music\\.163\\.com/#/(?\'mode\'song|album|playlist)\\?id=(?\'id\'\\d+)!',
'choose' => [
'when' => [
[
'test' => '@mode = \'album\'',
'iframe' => [
'width' => 380,
'height' => 450,
'src' => '//music.163.com/outchain/player?type=1&id={@id}&auto=0&height=450'
]
],
[
'test' => '@mode = \'song\'',
'iframe' => [
'width' => 380,
'height' => 86,
'src' => '//music.163.com/outchain/player?type=2&id={@id}&auto=0&height=66'
]
]
],
'otherwise' => [
'iframe' => [
'width' => 380,
'height' => 450,
'src' => '//music.163.com/outchain/player?type=0&id={@id}&auto=0&height=450'
]
]
]
]
);
$event->configurator->MediaEmbed->add(
'youku',
[
'host' => 'v.youku.com',
'extract' => "!v\\.youku\\.com/v_show/\\id_(?'id'[-0-9A-Z_a-z]+)!",
'iframe' => [
'width' => 720,
'height' => 405,
'src' => 'https://players.youku.com/embed/{@id}'
]
]
);
$event->configurator->MediaEmbed->add(
'bilibili',
[
'host' => 'www.bilibili.com',
'extract' => [
"!www.bilibili.com/video/av(?'id'\\d+)/!",
"!www.bilibili.com/mobile/video/av(?'id'\\d+)\\.html!"
],
'iframe' => [
'width' => 760,
'height' => 450,
'src' => '//www.bilibili.com/html/player.html?aid={@id}&as_wide=1'
]
]
);
$event->configurator->MediaEmbed->add(
'open163',
[
'host' => 'open.163.com',
'extract' => "!open\\.163\\.com/movie/[^/]+/[^/]+/[^/]+/[^/]+/(?'id'\\w+)\\.html!",
'flash' => [
'width' => 760,
'height' => 450,
'src' => '//swf.ws.126.net/openplayer/v01/-0-2_{@id}-.swf'
]
]
);
$event->configurator->MediaEmbed->add(
'qq',
[
'host' => 'qq.com',
'extract' => [
"!qq\\.com/x/cover/\\w+/(?'id'\\w+)\\.html!",
"!qq\\.com/x/cover/\\w+\\.html\\?vid=(?'id'\\w+)!",
"!qq\\.com/cover/[^/]+/\\w+/(?'id'\\w+)\\.html!",
"!qq\\.com/cover/[^/]+/\\w+\\.html\\?vid=(?'id'\\w+)!",
"!qq\\.com/x/page/(?'id'\\w+)\\.html!",
"!qq\\.com/page/[^/]+/[^/]+/[^/]+/(?'id'\\w+)\\.html!"
],
'iframe' => [
'width' => 760,
'height' => 450,
'src' => '//v.qq.com/iframe/player.html?vid={@id}&tiny=0&auto=0'
]
]
);
(new MediaPack)->configure($event->configurator);
}
);
};
return __NAMESPACE__ . '\\subscribe';