Skip to content

Commit

Permalink
Merge pull request #54 from KIMB-technologies/logo-cache
Browse files Browse the repository at this point in the history
Logo cache
  • Loading branch information
kimbtech authored Mar 3, 2024
2 parents 5e22972 + ae96a27 commit 2035a3d
Show file tree
Hide file tree
Showing 43 changed files with 252 additions and 50 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
/php/getr.php

/data/
/media/
/redis/
.DS_Store
3 changes: 2 additions & 1 deletion Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ The image of [Radio DNS](https://hub.docker.com/r/kimbtechnologies/radio_dns) is
- You may change the folder for cache files to, e.g., a ramdisk. If you do so, use the script `./utils/backup-restore.php` to backup data which is only stored by the cache (using Docker this is done by the cron job).
- The proxy feature is provided by PHP, but might be less stable than the NGINX proxy.
- The EndURL feature uses the cURL extension of PHP (else it will error!).
- Assure, that PHP/ the webserver can write to `./data/` (and the folders configured for logs and cache files)!
- Assure, that PHP/ the webserver can write to `./data/` (and the folders configured for logs and cache files)! If you use logo caching, also `./media/` needs to be writable.
- Download the lastest source of the *Radio-API* [here](https://github.com/KIMB-technologies/Radio-API/releases/latest).
- Extract the zip and place the folder `php` in the web-root of our server (this is our `./`, other files are not needed).
- Configure *Radio-API* in `./data/env.json` (The config values are the same as for the Docker-based mode, always use strings for the values!):
Expand All @@ -80,6 +80,7 @@ The image of [Radio DNS](https://hub.docker.com/r/kimbtechnologies/radio_dns) is
- `CONF_LOG_DIR` (optional) Change the folder where log files are written to (defaults to `./data/`).
- `CONF_CACHE_DIR` (optional) Change the folder used by the file based cache (defaults to `./data/cache/`).
- `CONF_IM_EXPORT_TOKEN` (optional) Define a token for use with the Im- & Export web interface *Im- & Export* [↓](#im---export).
- `CONF_USE_LOGO_CACHE` (optional, default `false`) Cache logos of radio stations. This will make sure logos are served without https and convert svg file 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/`.
- **Attention:** Optional parameters have a leading `____` in the default `env.json`, make sure to remove them.
- The `CONF_REDIS_*` values are ignored and `CONF_USE_JSON_CACHE` is always `true`.
- Make sure, that *Radio-API* is available at port `80` for requests with the hostname `*.wifiradiofrontier.com` and `CONF_DOMAIN`.
Expand Down
4 changes: 2 additions & 2 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2.8.4
2.8
2.9.0
2.9
2
2 changes: 2 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ services:
volumes:
- ./php/:/php-code/
- ./data/:/php-code/data/
- ./media/:/php-code/media/
- ./utils/getr.php:/php-code/getr.php:ro # redis all values listing
- ./utils/backup-restore.php:/backup-restore.php:ro # backup restore tool for cache values
environment:
Expand All @@ -29,6 +30,7 @@ services:
- CONF_REDIS_HOST=redis
- CONF_STREAM_JSON=false #http://192.168.0.10:8081/list.json
- CONF_IM_EXPORT_TOKEN=LP75Djdj195DL8SZnfY3
- CONF_USE_LOGO_CACHE=true
depends_on:
- redis
redis:
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ services:
ports:
- "80:80" # make sure, Radio-API is avaliable at port 80
volumes:
- ./data/:/php-code/data/
#- ./media/:/php-code/media/:ro # directory to add images for stations
- ./data/:/php-code/data/ # directory storing data, cache, and setting od Radio-API
- ./media/:/php-code/media/ # directory storing images for stations
environment:
- CONF_DOMAIN=http://radio.example.com/ # the domain where the system is hosted
# - CONF_RADIO_DOMAIN=http://hama.wifiradiofrontier.com # different domain to use for connections of the radio (if set CONF_DOMAIN is for GUI)
Expand All @@ -23,6 +23,7 @@ services:
- CONF_STREAM_JSON=false # to disable or an url where to fetch list of own streams, e.g., http://stream.example.com/list.json
# -CONF_LOG_DIR= # set a custom directory for log files (defaults to ./data/)
# -CONF_IM_EXPORT_TOKEN= # define a token for use with the im-, export web interface at ./gui/im-export.php
- CONF_USE_LOGO_CACHE=true # cache logos (make them accessible without ssl and convert svgs to pngs for the radio, stores files in ./media/)
depends_on:
- redis

Expand Down
2 changes: 1 addition & 1 deletion php/classes/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Radio-API
* https://github.com/KIMB-technologies/Radio-API
*
* (c) 2019 - 2023 KIMB-technologies
* (c) 2019 - 2024 KIMB-technologies
* https://github.com/KIMB-technologies/
*
* released under the terms of GNU Public License Version 3
Expand Down
2 changes: 1 addition & 1 deletion php/classes/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Radio-API
* https://github.com/KIMB-technologies/Radio-API
*
* (c) 2019 - 2023 KIMB-technologies
* (c) 2019 - 2024 KIMB-technologies
* https://github.com/KIMB-technologies/
*
* released under the terms of GNU Public License Version 3
Expand Down
15 changes: 12 additions & 3 deletions php/classes/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Radio-API
* https://github.com/KIMB-technologies/Radio-API
*
* (c) 2019 - 2023 KIMB-technologies
* (c) 2019 - 2024 KIMB-technologies
* https://github.com/KIMB-technologies/
*
* released under the terms of GNU Public License Version 3
Expand Down Expand Up @@ -64,7 +64,11 @@
);
define(
'ENV_USE_JSON_CACHE',
!empty($_ENV['CONF_USE_JSON_CACHE']) && $_ENV['CONF_USE_JSON_CACHE'] == 'true'
!empty($ENV['CONF_USE_JSON_CACHE']) && $ENV['CONF_USE_JSON_CACHE'] == 'true'
);
define(
'ENV_USE_LOGO_CACHE',
!empty($ENV['CONF_USE_LOGO_CACHE']) && $ENV['CONF_USE_LOGO_CACHE'] == 'true'
);

// IP on reverse proxy setup
Expand All @@ -81,7 +85,7 @@ class Config {
/**
* The system's version.
*/
const VERSION = 'v2.8.4';
const VERSION = 'v2.9.0';

/**
* The real domain which should be used.
Expand Down Expand Up @@ -130,6 +134,11 @@ class Config {
*/
const USE_JSON_CACHE = ENV_USE_JSON_CACHE;

/**
* Cache logos and make them accessible without ssl.
*/
const USE_LOGO_CACHE = ENV_USE_LOGO_CACHE;

/**
* Store redis cache for ALLOWED_DOMAINS
*/
Expand Down
2 changes: 1 addition & 1 deletion php/classes/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Radio-API
* https://github.com/KIMB-technologies/Radio-API
*
* (c) 2019 - 2023 KIMB-technologies
* (c) 2019 - 2024 KIMB-technologies
* https://github.com/KIMB-technologies/
*
* released under the terms of GNU Public License Version 3
Expand Down
2 changes: 1 addition & 1 deletion php/classes/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Radio-API
* https://github.com/KIMB-technologies/Radio-API
*
* (c) 2019 - 2023 KIMB-technologies
* (c) 2019 - 2024 KIMB-technologies
* https://github.com/KIMB-technologies/
*
* released under the terms of GNU Public License Version 3
Expand Down
2 changes: 1 addition & 1 deletion php/classes/Id.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Radio-API
* https://github.com/KIMB-technologies/Radio-API
*
* (c) 2019 - 2023 KIMB-technologies
* (c) 2019 - 2024 KIMB-technologies
* https://github.com/KIMB-technologies/
*
* released under the terms of GNU Public License Version 3
Expand Down
2 changes: 1 addition & 1 deletion php/classes/ImExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Radio-API
* https://github.com/KIMB-technologies/Radio-API
*
* (c) 2019 - 2023 KIMB-technologies
* (c) 2019 - 2024 KIMB-technologies
* https://github.com/KIMB-technologies/
*
* released under the terms of GNU Public License Version 3
Expand Down
2 changes: 1 addition & 1 deletion php/classes/Inner.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Radio-API
* https://github.com/KIMB-technologies/Radio-API
*
* (c) 2019 - 2023 KIMB-technologies
* (c) 2019 - 2024 KIMB-technologies
* https://github.com/KIMB-technologies/
*
* released under the terms of GNU Public License Version 3
Expand Down
2 changes: 1 addition & 1 deletion php/classes/JSONCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Radio-API
* https://github.com/KIMB-technologies/Radio-API
*
* (c) 2019 - 2023 KIMB-technologies
* (c) 2019 - 2024 KIMB-technologies
* https://github.com/KIMB-technologies/
*
* released under the terms of GNU Public License Version 3
Expand Down
2 changes: 1 addition & 1 deletion php/classes/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Radio-API
* https://github.com/KIMB-technologies/Radio-API
*
* (c) 2019 - 2023 KIMB-technologies
* (c) 2019 - 2024 KIMB-technologies
* https://github.com/KIMB-technologies/
*
* released under the terms of GNU Public License Version 3
Expand Down
2 changes: 1 addition & 1 deletion php/classes/M3U.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Radio-API
* https://github.com/KIMB-technologies/Radio-API
*
* (c) 2019 - 2023 KIMB-technologies
* (c) 2019 - 2024 KIMB-technologies
* https://github.com/KIMB-technologies/
*
* released under the terms of GNU Public License Version 3
Expand Down
12 changes: 6 additions & 6 deletions php/classes/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Radio-API
* https://github.com/KIMB-technologies/Radio-API
*
* (c) 2019 - 2023 KIMB-technologies
* (c) 2019 - 2024 KIMB-technologies
* https://github.com/KIMB-technologies/
*
* released under the terms of GNU Public License Version 3
Expand All @@ -21,7 +21,8 @@ class Output {
$items = array(),
$itemsSortKeys = array(),
$prevurl = '',
$language;
$language,
$logo;

const MAX_ITEMS = 200; // to many items will cause the radio to crash (one could add paging, but until then, we remove too much items)

Expand Down Expand Up @@ -52,6 +53,7 @@ class Output {
*/
public function __construct(string $lang = 'eng'){
$this->language = array_search($lang, self::ALL_LANGUAGES) ?? 0;
$this->logo = new RadioLogo();
}

/**
Expand All @@ -65,11 +67,10 @@ public function addStation( int|string $id, string $name, string $url,
'StationName' => $this->cleanText($name, true),
);
if( !$light ){
$logo = empty($logo) || substr($logo, 0, 4) != 'http' ? Config::RADIO_DOMAIN . 'media/default.png' : $logo;
$b = array(
'StationUrl' => $this->cleanUrl($url),
'StationDesc' => $this->cleanText($desc),
'Logo' => $this->cleanUrl($logo),
'Logo' => $this->cleanUrl($this->logo->logoUrl($logo)),
'StationFormat' => 'Radio',
'StationLocation' => 'Earth',
'StationBandWidth' => 32,
Expand Down Expand Up @@ -104,12 +105,11 @@ public function addPodcast( int $podcastid, string $name, string $url, int|strin
*/
public function addEpisode( int $podcastid, int|null $episodeid, string $podcastname, string $episodename,
string $url, string $desc = '', string $logo = '', bool $top = false ) : void {
$logo = empty($logo) || substr($logo, 0, 4) != 'http' ? Config::RADIO_DOMAIN . 'media/default.png' : $logo;
$this->items[] = array(
'ItemType' => 'ShowEpisode',
'ShowEpisodeID' => $podcastid . (!is_null($episodeid) ? 'X' . $episodeid : ''),
'ShowName' => $this->cleanText($podcastname, true),
'Logo' => $this->cleanUrl($logo),
'Logo' => $this->cleanUrl($this->logo->logoUrl($logo)),
'ShowEpisodeName' => $this->cleanText($episodename, true),
'ShowEpisodeURL' => $this->cleanUrl($url),
'BookmarkShow' => '',
Expand Down
2 changes: 1 addition & 1 deletion php/classes/OwnStreams.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Radio-API
* https://github.com/KIMB-technologies/Radio-API
*
* (c) 2019 - 2023 KIMB-technologies
* (c) 2019 - 2024 KIMB-technologies
* https://github.com/KIMB-technologies/
*
* released under the terms of GNU Public License Version 3
Expand Down
2 changes: 1 addition & 1 deletion php/classes/PodcastLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Radio-API
* https://github.com/KIMB-technologies/Radio-API
*
* (c) 2019 - 2023 KIMB-technologies
* (c) 2019 - 2024 KIMB-technologies
* https://github.com/KIMB-technologies/
*
* released under the terms of GNU Public License Version 3
Expand Down
2 changes: 1 addition & 1 deletion php/classes/RadioBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Radio-API
* https://github.com/KIMB-technologies/Radio-API
*
* (c) 2019 - 2023 KIMB-technologies
* (c) 2019 - 2024 KIMB-technologies
* https://github.com/KIMB-technologies/
*
* released under the terms of GNU Public License Version 3
Expand Down
Loading

0 comments on commit 2035a3d

Please sign in to comment.