先安装插件composer require fof/formatting。编辑文件FormatterConfigurator.php
public function configureFormatter(Configuring $event)
{
foreach ($this->plugins as $plugin) {
$enabled = $this->settings->get('fof-formatting.plugin.'.strtolower($plugin));
if ($enabled) {
if ($plugin == 'MediaEmbed') {
//www.music163.com
$event->configurator->MediaEmbed->add(
'music163',
[
'host' => 'music.163.com',
'extract' => "!music\\.163\\.com/outchain/player\\?type=(?'type'\\d+)&id=(?'id'\\d+)&auto=(?'auto'\\d+)&height=(?'height'\\d+)!",
'iframe' => [
'width' => "100%",
'height' => 430,
'src' => '//music.163.com/outchain/player?type={@type}&id={@id}&auto={@auto}&height={@height}'
]
]
);
//www.bilibili.com
$event->configurator->MediaEmbed->add(
'bilibili',
[
'host' => 'www.bilibili.com',
'extract' => [
"!www.bilibili.com/video/(?'bid'\\w+)!",
"!www.bilibili.com/video/(?'bid'\\w+)\\?p=(?'page'\\w+)!"
],
'iframe' => [
'width' => 800,
'height' => 500,
'src' => '//player.bilibili.com/player.html?bvid={@bid}&page={@page}'
]
]
);
//v.qq.com
$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'
]
]
);
//www.huya.com
$event->configurator->MediaEmbed->add(
'huya',
[
'host' => 'v.huya.com',
'extract' => [
"!huya\\.com/play/(?'id'\\d+)\\.html!",
],
'flash' => [
'width' => 760,
'height' => 450,
'src' => 'https://vhuya-static.huya.com/video/vppp.swf?&auto_play=0&vid={@id}'
]
]
);
//www.douyu.com
$event->configurator->MediaEmbed->add(
'douyu',
[
'host' => 'v.douyu.com',
'extract' => [
"!douyu\\.com/show/(?'id'\\w+)!",
],
'iframe' => [
'width' => 760,
'height' => 450,
'src' => 'https://v.douyu.com/video/share/index?vid={@id}'
]
]
);
//www.missevan.com
$event->configurator->MediaEmbed->add(
'missevan',
[
'host' => 'www.missevan.com',
'extract' => [
"!missevan\\.com/albumiframe/(?'id'\\d+)!",
],
'iframe' => [
'width' => 720,
'height' => 450,
'src' => 'https://www.missevan.com/albumiframe/{@id}?autoplay=false&playlist=true'
]
]
);
//www.acfun.cn
$event->configurator->MediaEmbed->add(
'acfun',
[
'host' => 'www.acfun.cn',
'extract' => [
"!www.acfun.cn/v/(?'bid'\\w+)!",
"!www.acfun.cn/v/(?'bid'\\w+)!"
],
'iframe' => [
'width' => 800,
'height' => 500,
'src' => 'https://www.acfun.cn/player/{@bid}'
]
]
);
// www.youku.com
$event->configurator->MediaEmbed->add(
'youku',
[
'host' => 'youku.com',
'extract' => [
"!youku\\.com/v_show/id_\\w+/(?'id'\\w+)==\\.html!",
],
'iframe' => [
'width' => 760,
'height' => 450,
'src' => 'https://player.youku.com/embed/{@id}'
]
]
);
(new MediaPack())->configure($event->configurator);
} else {
$event->configurator->$plugin;
}
}
}
}
}