mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-10-27 05:21:34 +01:00
Normalize www.youtube.com links to this domain
Links to (non-www) youtube.com work as well, but they get redirected to the www variant anyways.
This commit is contained in:
@@ -37,7 +37,7 @@ class GenshinImpactBridge extends BridgeAbstract
|
|||||||
if (preg_match($exp_youtube, $article_html, $matches)) {
|
if (preg_match($exp_youtube, $article_html, $matches)) {
|
||||||
// Replace the YouTube embed with a YouTube link
|
// Replace the YouTube embed with a YouTube link
|
||||||
$yt_embed = $article_html->find('div[class="ttr-video-frame"]', 0);
|
$yt_embed = $article_html->find('div[class="ttr-video-frame"]', 0);
|
||||||
$yt_link = sprintf('<a href="https://youtube.com/watch?v=%1$s">https://youtube.com/watch?v=%1$s</a>', $matches[1]);
|
$yt_link = sprintf('<a href="https://www.youtube.com/watch?v=%1$s">https://www.youtube.com/watch?v=%1$s</a>', $matches[1]);
|
||||||
$article_html = str_replace($yt_embed, $yt_link, $article_html);
|
$article_html = str_replace($yt_embed, $yt_link, $article_html);
|
||||||
}
|
}
|
||||||
$item = [];
|
$item = [];
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ class WebfailBridge extends BridgeAbstract
|
|||||||
. '"></a>';
|
. '"></a>';
|
||||||
} elseif (!is_null($article->find('div.wf-video', 0))) { // Video type
|
} elseif (!is_null($article->find('div.wf-video', 0))) { // Video type
|
||||||
$videoId = $this->getVideoId($article->find('div.wf-play', 0)->onclick);
|
$videoId = $this->getVideoId($article->find('div.wf-play', 0)->onclick);
|
||||||
$item['uri'] = 'https://youtube.com/watch?v=' . $videoId;
|
$item['uri'] = 'https://www.youtube.com/watch?v=' . $videoId;
|
||||||
$item['content'] = '<a href="'
|
$item['content'] = '<a href="'
|
||||||
. $item['uri']
|
. $item['uri']
|
||||||
. '"><img src="http://img.youtube.com/vi/'
|
. '"><img src="http://img.youtube.com/vi/'
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class YorushikaBridge extends BridgeAbstract
|
|||||||
if (preg_match($exp_youtube, $art_html, $matches)) {
|
if (preg_match($exp_youtube, $art_html, $matches)) {
|
||||||
// Replace the YouTube embed with a YouTube link
|
// Replace the YouTube embed with a YouTube link
|
||||||
$yt_embed = $art_html->find('iframe[src*="youtube.com"]', 0);
|
$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]);
|
$yt_link = sprintf('<a href="https://www.youtube.com/watch?v=%1$s">https://www.youtube.com/watch?v=%1$s</a>', $matches[1]);
|
||||||
$art_html = str_replace($yt_embed, $yt_link, $art_html);
|
$art_html = str_replace($yt_embed, $yt_link, $art_html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user