Skip to content

Commit 4c6ca79

Browse files
committed
Enable Nextcloud >= version 31
1 parent dbaaf7e commit 4c6ca79

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

Setup.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ The image of [Radio DNS](https://hub.docker.com/r/kimbtechnologies/radio_dns) is
8282
- `CONF_IM_EXPORT_TOKEN` (optional) Define a token for use with the Im- & Export web interface *Im- & Export* [↓](#im---export).
8383
- `CONF_USE_LOGO_CACHE` (optional, default `false`) Cache logos of radio stations. This will make sure logos are served without https and convert svg files to png (assuming [`rsvg-convert`](https://pkgs.alpinelinux.org/package/v3.19/community/x86_64/rsvg-convert) is available on system). Logos are stored in `./media/`.
8484
- `CONF_FAVORITE_ITEMS` (optional, default empty) Comma separated list of items to be favorites and shown on top of list by radio, e.g., `Radio,Radio-Browser`
85+
- `CONF_LEGACY_NEXTCLOUD` (optional, default `false`) Set to `true` if your are using Nextcloud streams and the Nextcloud server is running a version below 31
8586
- **Attention:** Optional parameters have a leading `____` in the default `env.json`, make sure to remove them.
8687
- The `CONF_REDIS_*` values are ignored and `CONF_USE_JSON_CACHE` is always `true`.
8788
- Make sure, that *Radio-API* is available at port `80` for requests with the hostname `*.wifiradiofrontier.com` and `CONF_DOMAIN`.

docker-compose.dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ services:
3232
- CONF_IM_EXPORT_TOKEN=LP75Djdj195DL8SZnfY3
3333
- CONF_USE_LOGO_CACHE=true
3434
#- CONF_FAVORITE_ITEMS=Radio,Radio-Browser
35+
#- CONF_LEGACY_NEXTCLOUD=false # set to true for using nextcloud streams with nextcloud version < 31
3536
depends_on:
3637
- redis
3738
redis:

php/classes/Config.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474
!empty($ENV['CONF_FAVORITE_ITEMS']) ?
7575
strval($ENV['CONF_FAVORITE_ITEMS']) : ''
7676
);
77+
define(
78+
'ENV_LEGACY_NEXTCLOUD',
79+
!empty($ENV['CONF_LEGACY_NEXTCLOUD']) && $ENV['CONF_LEGACY_NEXTCLOUD'] == 'true'
80+
);
7781

7882
// IP on reverse proxy setup
7983
if( !empty($_SERVER['HTTP_X_REAL_IP']) ){
@@ -148,6 +152,11 @@ class Config {
148152
*/
149153
const FAVORITE_ITEMS = ENV_FAVORITE_ITEMS;
150154

155+
/**
156+
* Nextcloud version 31.0.0 changes how files can be downloaded from shares, use the old way required by older version of Nextcloud servers?
157+
*/
158+
const LEGACY_NEXTCLOUD = ENV_LEGACY_NEXTCLOUD;
159+
151160
/**
152161
* Store redis cache for ALLOWED_DOMAINS
153162
*/

php/classes/PodcastLoader.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ private static function loadFromNextcloud( string $url ) : array {
7373
// get filename
7474
$filename = urldecode(substr( $href, strrpos( $href, '/' ) + 1 ));
7575
// get streaming/ web url
76-
$streamurl = $server . ($useindex ? '/index.php' : '') . '/s/'. $share .'/download?path=%2F&files=' . rawurlencode( $filename );
76+
if(Config::LEGACY_NEXTCLOUD){ // old NC share download link (before v31)
77+
$streamurl = $server . ($useindex ? '/index.php' : '') . '/s/'. $share .'/download?path=%2F&files=' . rawurlencode( $filename );
78+
}
79+
else{ // new NC share download link (starting v31)
80+
$streamurl = $server . '/public.php/dav/files/' . $share . '/' . rawurlencode( $filename );
81+
}
7782

7883
// is this an audio file?
7984
if( str_starts_with($mime, 'audio/') ){

php/data/env.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"____CONF_IM_EXPORT_TOKEN" : "aToken",
1414
"____CONF_USE_LOGO_CACHE" : "true",
1515
"____CONF_FAVORITE_ITEMS" : "Radio,Radio-Browser",
16+
"____CONF_LEGACY_NEXTCLOUD" : "false",
1617
"_comment-4" : "Remove the ____ prefix for using optional config-values."
1718
}

0 commit comments

Comments
 (0)