add export favorite stations as playlist (fixes #105)

This commit is contained in:
Jonas Heinrich 2021-03-13 13:37:15 +01:00
parent 7813cf4a51
commit 8371027730
2 changed files with 15 additions and 5 deletions

View File

@ -5,6 +5,8 @@
[#251](https://git.project-insanity.org/onny/nextcloud-app-radio/-/issues/251) @onny
- Support add stations manually
[#157](https://git.project-insanity.org/onny/nextcloud-app-radio/-/issues/157) @onny
- Export favorite radio stations as playlist
[#105](https://git.project-insanity.org/onny/nextcloud-app-radio/-/issues/105) @onny
### Fixed
- Cleanup SCSS

View File

@ -31,6 +31,7 @@ use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\IRequest;
use SimpleXMLElement;
use DOMDocument;
class ExportController extends Controller {
/** @var FavoriteService */
@ -57,12 +58,19 @@ class ExportController extends Controller {
$xml = new SimpleXMLElement('<?xml version="1.0"?><playlist></playlist>');
$xml->addAttribute('encoding', 'UTF-8');
$trackList = $xml->addChild('trackList');
$track = $trackList->addChild('track');
$track->addChild('location', 'http://localhost/test.mp3');
$track->addChild('title', 'Radio Test 404fm');
$track->addChild('image', 'http://localhost/favicon.ico');
foreach($this->service->findAll($this->userId) as $station) {
$track = $trackList->addChild('track');
$track->addChild('location', $station->getUrlresolved());
$track->addChild('title', $station->getName());
$track->addChild('image', $station->getFavicon());
}
return new ExportResponse($xml->asXML());
$dom = new DOMDocument("1.0");
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($xml->asXML());
return new ExportResponse($dom->saveXML());
}