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:
parent
fd02965fe9
commit
6c92bfc2d3
1 changed files with 16 additions and 2 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue