1
0
Fork 0
forked from blallo/rss-bridge

[RadioRai] get "final" URLs

Without this, every item has an enclosure with the same basename and
different query parameters.
This is correct, but some podcast readers (gPodder) mess it up, writing
every download to the same file.
This commit is contained in:
baz 2019-10-30 12:19:56 +01:00
parent fd02965fe9
commit 6c92bfc2d3

View file

@ -4,7 +4,7 @@ class RadioRaiBridge extends BridgeAbstract {
const MAINTAINER = 'boyska'; const MAINTAINER = 'boyska';
const NAME = 'Radio Rai'; const NAME = 'Radio Rai';
const URI = 'https://www.raiplayradio.it'; const URI = 'https://www.raiplayradio.it';
const CACHE_TIMEOUT = 1; // 10min const CACHE_TIMEOUT = 900; // 15min
const DESCRIPTION = 'Segui le trasmissioni radio rai con feed/podcast valido'; const DESCRIPTION = 'Segui le trasmissioni radio rai con feed/podcast valido';
const PARAMETERS = array( array( const PARAMETERS = array( array(
'txname' => array( 'txname' => array(
@ -13,6 +13,20 @@ class RadioRaiBridge extends BridgeAbstract {
) )
)); ));
private function getFinalURL($url) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_HEADER, true);
$ret = curl_exec($ch);
if($ret === FALSE) {
return null;
}
$redirect = curl_getinfo($ch, CURLINFO_REDIRECT_URL);
if($redirect === false) return $url;
return $redirect;
}
public function collectData(){ public function collectData(){
$html = getSimpleHTMLDOM($this->getURI()) $html = getSimpleHTMLDOM($this->getURI())
or returnServerError('No results for this query.'); or returnServerError('No results for this query.');
@ -27,7 +41,7 @@ class RadioRaiBridge extends BridgeAbstract {
$item['author'] = $this->getInput('txname'); $item['author'] = $this->getInput('txname');
$item['title'] = $title; $item['title'] = $title;
$item['content'] = $episode->plaintext; $item['content'] = $episode->plaintext;
$item['enclosures'] = [ $audiourl ]; $item['enclosures'] = [ $this::getFinalURL($audiourl) ];
$item['url'] = $this::URI . $episode->getAttribute('data-href'); $item['url'] = $this::URI . $episode->getAttribute('data-href');
$this->items[] = $item; $this->items[] = $item;