mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-09 16:38:50 +00:00
[RadioMelodieBridge] Replace JS Audio Player (#2233)
The Javascript Audio Player is replaced by the plain <audio> HTML tag
This commit is contained in:
parent
3637777070
commit
f5f0b77805
@ -23,6 +23,9 @@ class RadioMelodieBridge extends BridgeAbstract {
|
|||||||
if($element->tag == 'a') {
|
if($element->tag == 'a') {
|
||||||
$articleURL = self::URI . $element->href;
|
$articleURL = self::URI . $element->href;
|
||||||
$article = getSimpleHTMLDOM($articleURL);
|
$article = getSimpleHTMLDOM($articleURL);
|
||||||
|
$this->rewriteAudioPlayers($article);
|
||||||
|
// Reload the modified content
|
||||||
|
$article = str_get_html($article->save());
|
||||||
$textDOM = $article->find('article', 0);
|
$textDOM = $article->find('article', 0);
|
||||||
|
|
||||||
// Initialise arrays
|
// Initialise arrays
|
||||||
@ -96,6 +99,7 @@ class RadioMelodieBridge extends BridgeAbstract {
|
|||||||
$textDOM = defaultLinkTo($textDOM, self::URI . '/');
|
$textDOM = defaultLinkTo($textDOM, self::URI . '/');
|
||||||
|
|
||||||
$article->save();
|
$article->save();
|
||||||
|
//$this->rewriteAudioPlayers($textDOM);
|
||||||
$text = $textDOM->innertext;
|
$text = $textDOM->innertext;
|
||||||
$item['content'] = '<h1>' . $item['title'] . '</h1>' . $dateHTML . '<br/>' . $header . $text;
|
$item['content'] = '<h1>' . $item['title'] . '</h1>' . $dateHTML . '<br/>' . $header . $text;
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
@ -113,4 +117,30 @@ class RadioMelodieBridge extends BridgeAbstract {
|
|||||||
return self::URI . '/' . $params['image'];
|
return self::URI . '/' . $params['image'];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function to rewrite Audio Players to use the <audio> tag and not the javascript audio player
|
||||||
|
*/
|
||||||
|
private function rewriteAudioPlayers($html)
|
||||||
|
{
|
||||||
|
// Find all audio Players
|
||||||
|
$audioPlayers = $html->find('div[class=audioPlayer]');
|
||||||
|
|
||||||
|
foreach($audioPlayers as $audioPlayer) {
|
||||||
|
// Get the javascript content below the player
|
||||||
|
$js = $audioPlayer->next_sibling();
|
||||||
|
|
||||||
|
// Extract the audio file URL
|
||||||
|
preg_match('/wavesurfer[0-9]+.load\(\'(.*)\'\)/m', $js->innertext, $urls);
|
||||||
|
|
||||||
|
// Create the plain HTML <audio> content to play this audio file
|
||||||
|
$content = '<audio style="width: 100%" src="' . $urls[1] . '" controls ></audio>';
|
||||||
|
|
||||||
|
// Replace the <script> tag by the <audio> tag
|
||||||
|
$js->outertext = $content;
|
||||||
|
// Remove the initial Audio Player
|
||||||
|
$audioPlayer->outertext = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user