mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-12 01:48:48 +00:00
add support for more media types as enclosures, handle result of /tex… (#2324)
This commit is contained in:
parent
3a9e528301
commit
55acf661b9
@ -344,7 +344,7 @@ abstract class XPathAbstract extends BridgeAbstract {
|
|||||||
protected function provideFeedIcon(DOMXPath $xpath) {
|
protected function provideFeedIcon(DOMXPath $xpath) {
|
||||||
$icon = $xpath->query($this->getParam('feed_icon'));
|
$icon = $xpath->query($this->getParam('feed_icon'));
|
||||||
if(count($icon) === 1) {
|
if(count($icon) === 1) {
|
||||||
return $this->cleanImageUrl($this->getItemValueOrNodeValue($icon));
|
return $this->cleanMediaUrl($this->getItemValueOrNodeValue($icon));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,7 +511,7 @@ abstract class XPathAbstract extends BridgeAbstract {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function formatItemEnclosures($value) {
|
protected function formatItemEnclosures($value) {
|
||||||
return array($this->cleanImageUrl($value));
|
return array($this->cleanMediaUrl($value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -527,12 +527,13 @@ abstract class XPathAbstract extends BridgeAbstract {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $imageUrl
|
* @param $mediaUrl
|
||||||
* @return string|void
|
* @return string|void
|
||||||
*/
|
*/
|
||||||
protected function cleanImageUrl($imageUrl)
|
protected function cleanMediaUrl($mediaUrl)
|
||||||
{
|
{
|
||||||
$result = preg_match('~(?:http(?:s)?:)?[\/a-zA-Z0-9\-_\.]+\.(?:jpg|gif|png|jpeg|ico){1}~', $imageUrl, $matches);
|
$pattern = '~(?:http(?:s)?:)?[\/a-zA-Z0-9\-_\.\%]+\.(?:jpg|gif|png|jpeg|ico|mp3){1}~i';
|
||||||
|
$result = preg_match($pattern, $mediaUrl, $matches);
|
||||||
if(1 !== $result) {
|
if(1 !== $result) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -551,6 +552,8 @@ abstract class XPathAbstract extends BridgeAbstract {
|
|||||||
return trim($item->nodeValue);
|
return trim($item->nodeValue);
|
||||||
} elseif ($item instanceof DOMAttr) {
|
} elseif ($item instanceof DOMAttr) {
|
||||||
return trim($item->value);
|
return trim($item->value);
|
||||||
|
} elseif ($item instanceof DOMText) {
|
||||||
|
return trim($item->wholeText);
|
||||||
}
|
}
|
||||||
} elseif(is_string($typedResult) && strlen($typedResult) > 0) {
|
} elseif(is_string($typedResult) && strlen($typedResult) > 0) {
|
||||||
return trim($typedResult);
|
return trim($typedResult);
|
||||||
|
Loading…
Reference in New Issue
Block a user