mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-01-17 14:18:35 +01:00
[YorushikaBridge] Replace YouTube embeds with YouTube link (#3321)
This commit is contained in:
parent
fbe7cc11ec
commit
4e616c7092
@ -62,9 +62,9 @@ class YorushikaBridge extends BridgeAbstract
|
||||
$url = $art->find('a.clearfix', 0)->href;
|
||||
|
||||
// Get article date
|
||||
$exp = '/\d+\.\d+\.\d+/';
|
||||
$exp_date = '/\d+\.\d+\.\d+/';
|
||||
$date = $art->find('.date', 0)->plaintext;
|
||||
preg_match($exp, $date, $matches);
|
||||
preg_match($exp_date, $date, $matches);
|
||||
$date = date_create_from_format('Y.m.d', $matches[0]);
|
||||
$date = date_format($date, 'd.m.Y');
|
||||
|
||||
@ -72,6 +72,15 @@ class YorushikaBridge extends BridgeAbstract
|
||||
$art_html = getSimpleHTMLDOMCached($url)->find('.text.inview', 0);
|
||||
$art_html = defaultLinkTo($art_html, $this->getURI());
|
||||
|
||||
// Check if article contains a embed YouTube video
|
||||
$exp_youtube = '/https:\/\/[w\.]+youtube\.com\/embed\/([\w]+)/m';
|
||||
if (preg_match($exp_youtube, $art_html, $matches)) {
|
||||
// Replace the YouTube embed with a YouTube link
|
||||
$yt_embed = $art_html->find('iframe[src*="youtube.com"]', 0);
|
||||
$yt_link = sprintf('<a href="https://youtube.com/watch?v=%1$s">https://youtube.com/watch?v=%1$s</a>', $matches[1]);
|
||||
$art_html = str_replace($yt_embed, $yt_link, $art_html);
|
||||
}
|
||||
|
||||
|
||||
$item['uri'] = $url;
|
||||
$item['title'] = $title . ' (' . $art_category . ')';
|
||||
|
Loading…
x
Reference in New Issue
Block a user