diff --git a/.gitignore b/.gitignore
index c0319ce..e1dbdc1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,4 @@ yarn-error.log*
js/
build/
coverage/
+utils/docker-ci
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f3cf005..492fbda 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
## 1.1.0 - 2021-04
+### Changed
+- Simplify jsonSerialize keys to match API naming
+ [#266](https://git.project-insanity.org/onny/nextcloud-app-radio/-/issues/266) @onny
+- Update npm modules
+ [#269](https://git.project-insanity.org/onny/nextcloud-app-radio/-/issues/269) @onny
+
## 1.0.3 - 2021-03
### Added
diff --git a/appinfo/routes.php b/appinfo/routes.php
index 1290f1c..444e792 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -26,6 +26,7 @@ return [
'favorite' => ['url' => '/api/favorites'],
'recent' => ['url' => '/api/recent'],
'export' => ['url' => '/export'],
+ 'station' => ['url' => '/station'],
],
'routes' => [
diff --git a/lib/Controller/StationController.php b/lib/Controller/StationController.php
new file mode 100644
index 0000000..db19859
--- /dev/null
+++ b/lib/Controller/StationController.php
@@ -0,0 +1,104 @@
+
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see .
+ *
+ */
+
+namespace OCA\Radio\Controller;
+
+use OCA\Radio\AppInfo\Application;
+use OCA\Radio\Service\RecentService;
+use OCP\AppFramework\Controller;
+use OCP\AppFramework\Http\DataResponse;
+use OCP\IRequest;
+
+class StationController extends Controller {
+ /** @var StationController */
+ private $service;
+
+ /** @var RadioBrowserApiService */
+ private $radiobrowserapi;
+
+ /** @var string */
+ private $userId;
+
+ use Errors;
+
+ public function __construct(IRequest $request,
+ RecentService $service,
+ RadioBrowserApiService $radiobrowserapi,
+ $userId) {
+ parent::__construct(Application::APP_ID, $request);
+ $this->service = $service;
+ $this->radiobrowserapi = $radiobrowserapi;
+ $this->userId = $userId;
+ }
+
+ /**
+ * @NoAdminRequired
+ */
+ public function index(): DataResponse {
+ return new DataResponse($this->service->findAll($this->userId));
+ }
+
+ /**
+ * @NoAdminRequired
+ */
+ public function show(int $id): DataResponse {
+ return $this->handleNotFound(function () use ($id) {
+ return $this->service->find($id, $this->userId);
+ });
+ }
+
+ /**
+ * @NoAdminRequired
+ */
+ public function create(string $stationuuid, string $name, string $favicon, string $urlresolved,
+ string $bitrate, string $country, string $language, string $homepage,
+ string $codec, string $tags): DataResponse {
+ return new DataResponse($this->service->create($stationuuid, $name,
+ $favicon, $urlresolved, $bitrate, $country, $language, $homepage, $codec,
+ $tags, $this->userId));
+ }
+
+ /**
+ * @NoAdminRequired
+ */
+ public function update(int $id, string $stationuuid, string $name,
+ string $favicon, string $urlresolved, string $bitrate, string $country,
+ string $language, string $homepage, string $codec, string $tags): DataResponse {
+ return $this->handleNotFound(function () use ($id, $stationuuid, $name,
+ $favicon, $urlresolved, $bitrate, $country, $language, $homepage, $codec,
+ $tags) {
+ return $this->service->update($id, $stationuuid, $name, $favicon,
+ $urlresolved, $bitrate, $country, $language, $homepage, $codec,
+ $tags, $this->userId);
+ });
+ }
+
+ /**
+ * @NoAdminRequired
+ */
+ public function destroy(int $id): DataResponse {
+ return $this->handleNotFound(function () use ($id) {
+ return $this->service->delete($id, $this->userId);
+ });
+ }
+}
diff --git a/lib/Db/Station.php b/lib/Db/Station.php
index 24be828..2157a5e 100644
--- a/lib/Db/Station.php
+++ b/lib/Db/Station.php
@@ -46,7 +46,7 @@ class Station extends Entity implements JsonSerializable {
'stationuuid' => $this->stationuuid,
'name' => $this->name,
'favicon' => $this->favicon,
- 'urlresolved' => $this->urlresolved,
+ 'url_resolved' => $this->urlresolved,
'bitrate' => $this->bitrate,
'country' => $this->country,
'language' => $this->language,
diff --git a/lib/Service/RadioBrowserApiService.php b/lib/Service/RadioBrowserApiService.php
new file mode 100644
index 0000000..efe435a
--- /dev/null
+++ b/lib/Service/RadioBrowserApiService.php
@@ -0,0 +1,153 @@
+
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see .
+ *
+ */
+
+declare(strict_types=1);
+
+namespace OCA\Radio\Service;
+
+use OCP\IURLGenerator;
+use OCP\Http\Client\IClientService;
+
+use function urlencode;
+
+class RadioBrowserApiService {
+
+ /** @var IClientService */
+ private $clientService;
+
+ /** @var IURLGenerator */
+ private $url;
+
+ public $baseUrl = "https://api.fyyd.de/0.2";
+
+ public function __construct(
+ IClientService $clientService,
+ IURLGenerator $url
+ ) {
+ $this->clientService = $clientService;
+ $this->url = $url;
+ }
+
+ public function queryEpisodes(int $podcast_id, int $count = 20, int $page = 0) {
+
+ $url = $this->baseUrl . "/podcast/episodes";
+
+ $options['query'] = [
+ 'podcast_id' => $podcast_id,
+ 'count' => $count,
+ 'page' => $page
+ ];
+
+ $client = $this->clientService->newClient();
+ try {
+ $response = $client->get($url, $options);
+ } catch (Exception $e) {
+ $this->logger->error("Could not search for podcasts: " . $e->getMessage());
+ throw $e;
+ }
+ $body = $response->getBody();
+
+ $parsed = json_decode($body, true);
+
+ return $parsed;
+ }
+
+ public function queryEpisode(int $episode_id) {
+
+ $url = $this->baseUrl . "/episode";
+
+ $options['query'] = [
+ 'episode_id' => $episode_id,
+ ];
+
+ $client = $this->clientService->newClient();
+ try {
+ $response = $client->get($url, $options);
+ } catch (Exception $e) {
+ $this->logger->error("Could not search for podcasts: " . $e->getMessage());
+ throw $e;
+ }
+ $body = $response->getBody();
+ $parsed = json_decode($body, true);
+
+ return $parsed;
+ }
+
+ public function queryPodcast(int $podcast_id) {
+
+ $url = $this->baseUrl . "/podcast";
+
+ $options['query'] = [
+ 'podcast_id' => $podcast_id,
+ ];
+
+ $client = $this->clientService->newClient();
+ try {
+ $response = $client->get($url, $options);
+ } catch (Exception $e) {
+ $this->logger->error("Could not search for podcasts: " . $e->getMessage());
+ throw $e;
+ }
+ $body = $response->getBody();
+ $parsed = json_decode($body, true);
+
+ return $parsed;
+ }
+
+ public function queryCategory(string $category, int $count = 20,
+ int $page = 0) {
+
+ if ($category === 'hot') {
+ $url = $this->baseUrl . "/feature/podcast/hot";
+ $options['query'] = [
+ 'count' => $count,
+ 'page' => $page,
+ ];
+ } else if ($category === 'latest') {
+ $url = $this->baseUrl . "/podcast/latest";
+ $options['query'] = [
+ 'count' => $count,
+ 'page' => $page,
+ ];
+ } else {
+ $url = $this->baseUrl . "/category";
+ $options['query'] = [
+ 'count' => $count,
+ 'page' => $page,
+ 'category_id' => $category,
+ ];
+ }
+
+ $client = $this->clientService->newClient();
+ try {
+ $response = $client->get($url, $options);
+ } catch (Exception $e) {
+ $this->logger->error("Could not search for podcasts: " . $e->getMessage());
+ throw $e;
+ }
+ $body = $response->getBody();
+ $parsed = json_decode($body, true);
+
+ return $parsed;
+ }
+}
diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue
index bca22ac..e0d36b2 100644
--- a/src/components/Sidebar.vue
+++ b/src/components/Sidebar.vue
@@ -34,7 +34,7 @@
{{ t('radio', 'Stream URL') }}
-
+
{{ t('radio', 'Copy link to clipboard') }}
@@ -108,13 +108,6 @@ export default {
},
},
computed: {
- urlResolved() {
- if (this.sidebarStation.url_resolved) {
- return this.sidebarStation.url_resolved
- } else {
- return this.sidebarStation.urlresolved
- }
- },
stationTags() {
if (this.sidebarStation.tags) {
return this.sidebarStation.tags.replaceAll(',', ', ')
@@ -127,7 +120,7 @@ export default {
this.$emit('toggleSidebar')
},
copyLink() {
- this.$copyText(this.urlResolved).then(
+ this.$copyText(this.sidebarStation.url_resolved).then(
function() {
showSuccess(t('radio', 'Link copied to clipboard'))
},
diff --git a/src/services/RadioApi.js b/src/services/RadioApi.js
index a9bc936..86c5da9 100644
--- a/src/services/RadioApi.js
+++ b/src/services/RadioApi.js
@@ -33,16 +33,10 @@ export class RadioApi {
}
addFavorite(station) {
- let stationSrc = ''
- if (!station.url_resolved) {
- stationSrc = station.urlresolved
- } else {
- stationSrc = station.url_resolved
- }
station = {
id: -1,
name: station.name.toString(),
- urlresolved: stationSrc.toString(),
+ url_resolved: station.url_resolved.toString(),
favicon: station.favicon.toString(),
stationuuid: station.stationuuid.toString(),
bitrate: station.bitrate.toString(),
@@ -100,16 +94,10 @@ export class RadioApi {
}
addRecent(station) {
- let stationSrc = ''
- if (!station.url_resolved) {
- stationSrc = station.urlresolved
- } else {
- stationSrc = station.url_resolved
- }
station = {
id: -1,
name: station.name.toString(),
- urlresolved: stationSrc.toString(),
+ url_resolved: station.url_resolved.toString(),
favicon: station.favicon.toString(),
stationuuid: station.stationuuid.toString(),
bitrate: station.bitrate.toString(),
diff --git a/src/store/player.js b/src/store/player.js
index f2c4f8d..56f17a1 100644
--- a/src/store/player.js
+++ b/src/store/player.js
@@ -120,7 +120,7 @@ export default ({
context.commit('setBuffering', true)
context.commit('setTitle', station.name)
context.commit('setPausing', false)
- player.doPlay(station.url_resolved || station.urlresolved)
+ player.doPlay(station.url_resolved)
},
},
diff --git a/src/views/Favorites.vue b/src/views/Favorites.vue
index 7642743..9e026eb 100644
--- a/src/views/Favorites.vue
+++ b/src/views/Favorites.vue
@@ -254,7 +254,7 @@ export default {
e.preventDefault()
const station = {
name: this.station.name,
- urlresolved: this.station.streamUrl,
+ url_resolved: this.station.streamUrl,
favicon: this.station.faviconUrl,
stationuuid: this.uuidv4(),
bitrate: '',
diff --git a/src/views/Main.vue b/src/views/Main.vue
index a1035dd..3a95ab9 100644
--- a/src/views/Main.vue
+++ b/src/views/Main.vue
@@ -147,7 +147,8 @@ export default {
= document.getElementById('app-content-vue').scrollHeight
const tableHeight = height
if (tableHeight < contentHeight) {
- this.preFill()
+ // this.preFill()
+ console.log('prefill')
}
},