mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-01-09 21:17:27 +03:00
feat(reddit): support video (#4380)
This commit is contained in:
parent
152e96d3d0
commit
7d544f1fab
1 changed files with 18 additions and 5 deletions
|
@ -234,11 +234,14 @@ class RedditBridge extends BridgeAbstract
|
||||||
} elseif ($data->is_video) {
|
} elseif ($data->is_video) {
|
||||||
// Video
|
// Video
|
||||||
|
|
||||||
// Higher index -> Higher resolution
|
if ($data->media->reddit_video) {
|
||||||
end($data->preview->images[0]->resolutions);
|
$item['content'] = $this->createVideoContent($data->media->reddit_video);
|
||||||
$index = key($data->preview->images[0]->resolutions);
|
} else {
|
||||||
|
// Higher index -> Higher resolution
|
||||||
$item['content'] = $this->createFigureLink($data->url, $data->preview->images[0]->resolutions[$index]->url, 'Video');
|
end($data->preview->images[0]->resolutions);
|
||||||
|
$index = key($data->preview->images[0]->resolutions);
|
||||||
|
$item['content'] = $this->createFigureLink($data->url, $data->preview->images[0]->resolutions[$index]->url, 'Video');
|
||||||
|
}
|
||||||
} elseif (isset($data->media) && $data->media->type == 'youtube.com') {
|
} elseif (isset($data->media) && $data->media->type == 'youtube.com') {
|
||||||
// Youtube link
|
// Youtube link
|
||||||
$item['content'] = $this->createFigureLink($data->url, $data->media->oembed->thumbnail_url, 'YouTube');
|
$item['content'] = $this->createFigureLink($data->url, $data->media->oembed->thumbnail_url, 'YouTube');
|
||||||
|
@ -318,6 +321,16 @@ class RedditBridge extends BridgeAbstract
|
||||||
return sprintf('<a href="%s">%s</a>', $href, $text);
|
return sprintf('<a href="%s">%s</a>', $href, $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function createVideoContent(\stdClass $video): string
|
||||||
|
{
|
||||||
|
return <<<HTML
|
||||||
|
<video width="$video->width" height="$video->height" controls>
|
||||||
|
<source src="$video->fallback_url" type="video/mp4">
|
||||||
|
Your browser does not support the video tag.
|
||||||
|
</video>
|
||||||
|
HTML;
|
||||||
|
}
|
||||||
|
|
||||||
public function detectParameters($url)
|
public function detectParameters($url)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue