Skip to content
This repository was archived by the owner on Oct 8, 2023. It is now read-only.

Commit d00ef26

Browse files
author
sailor
committed
Merge branch 'master' into stable
2 parents e871f41 + 299171c commit d00ef26

File tree

12 files changed

+152
-122
lines changed

12 files changed

+152
-122
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [0.6.11] 2020-02-17
10+
### Added
11+
- API: Added stationuuid to m3u output
12+
13+
### Fixed
14+
- API: Filter order column for extra tables
15+
916
## [0.6.10] 2020-02-01
1017
### Fixed
1118
- API: Wrong links in docs

Cargo.lock

Lines changed: 93 additions & 102 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description = "Radio-Browser Server with REST API"
44
license = "agpl-3.0"
55
name = "radiobrowser-api-rust"
66
readme = "README.md"
7-
version = "0.6.10"
7+
version = "0.6.11"
88
edition = "2018"
99

1010
[dependencies]
@@ -25,7 +25,7 @@ reqwest = "0.9.24"
2525
rouille = "3.0.0"
2626
serde = "1.0.104"
2727
serde_derive ="1.0.104"
28-
serde_json = "1.0.45"
28+
serde_json = "1.0.48"
2929
threadpool = "1.7.1"
3030
toml = "0.5.6"
3131
url = "2.1.1"

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ docker stack deploy -c docker-compose-traefik.yml rb
8080
# download distribution
8181
mkdir -p radiobrowser
8282
cd radiobrowser
83-
wget https://github.com/segler-alex/radiobrowser-api-rust/releases/download/0.6.10/radiobrowser-dist.tar.gz
83+
wget https://github.com/segler-alex/radiobrowser-api-rust/releases/download/0.6.11/radiobrowser-dist.tar.gz
8484
tar -zxf radiobrowser-dist.tar.gz
8585

8686
# config database
@@ -101,7 +101,7 @@ sudo systemctl start radiobrowser
101101
* create database and database user
102102

103103
```bash
104-
wget https://github.com/segler-alex/radiobrowser-api-rust/releases/download/0.6.10/radiobrowser-api-rust_0.6.10_amd64.deb
104+
wget https://github.com/segler-alex/radiobrowser-api-rust/releases/download/0.6.11/radiobrowser-api-rust_0.6.10_amd64.deb
105105
sudo apt install default-mysql-server
106106
sudo dpkg -i radiobrowser-api-rust_0.6.10_amd64.deb
107107
cat /usr/share/radiobrowser/init.sql | mysql
@@ -193,7 +193,7 @@ cd radiobrowser-api-rust
193193
# checkout stable
194194
git checkout stable
195195
# deploy, change email adress, for ssl with certbot
196-
ansible-playbook -e "email=test@example.com" -e "version=0.6.10" -e "ansible_python_interpreter=auto" -i "test.example.com,test2.example.com" ansible/playbook.yml
196+
ansible-playbook -e "email=test@example.com" -e "version=0.6.11" -e "ansible_python_interpreter=auto" -i "test.example.com,test2.example.com" ansible/playbook.yml
197197
```
198198

199199
## Building

docker-compose-traefik.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "3.2"
22
services:
33
api:
44
build: ./
5-
image: segleralex/radiobrowser-api-rust:0.6.10
5+
image: segleralex/radiobrowser-api-rust:0.6.11
66
labels:
77
- "traefik.enable=true"
88
- "traefik.http.routers.api.rule=Host(`${SOURCE}`)"

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "3.0"
22
services:
33
api:
44
build: ./
5-
image: segleralex/radiobrowser-api-rust:0.6.10
5+
image: segleralex/radiobrowser-api-rust:0.6.11
66
deploy:
77
replicas: 1
88
networks:

src/api/data/station.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ impl Station {
145145
let mut j = String::with_capacity(200 * list.len());
146146
j.push_str("#EXTM3U\r\n");
147147
for item in list {
148+
j.push_str("#RADIOBROWSERUUID:");
149+
j.push_str(&item.stationuuid);
150+
j.push_str("\r\n");
151+
148152
j.push_str("#EXTINF:1,");
149153
j.push_str(&item.name);
150154
j.push_str("\r\n");

src/db/db_error.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ pub enum DbError {
88
ConnectionError(String),
99
VoteError(String),
1010
AddStationError(String),
11+
IllegalOrderError(String),
1112
}
1213

1314
impl Display for DbError {
1415
fn fmt(&self, f: &mut Formatter) -> Result {
1516
match *self {
16-
DbError::ConnectionError(ref v) => write!(f, "{}", v),
17-
DbError::VoteError(ref v) => write!(f, "{}", v),
18-
DbError::AddStationError(ref v) => write!(f, "{}", v),
17+
DbError::ConnectionError(ref v) => write!(f, "ConnectionError '{}'", v),
18+
DbError::VoteError(ref v) => write!(f, "VoteError '{}'", v),
19+
DbError::AddStationError(ref v) => write!(f, "AddStationError '{}'", v),
20+
DbError::IllegalOrderError(ref v) => write!(f, "IllegalOrderError '{}'", v),
1921
}
2022
}
2123
}

src/db/db_mysql/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,7 @@ impl DbConnection for MysqlConnection {
11481148
reverse: bool,
11491149
hidebroken: bool,
11501150
) -> Result<Vec<ExtraInfo>, Box<dyn Error>> {
1151+
let order = filter_order_1_n(&order)?;
11511152
let mut params: Vec<Value> = Vec::with_capacity(1);
11521153
let mut items = vec![];
11531154
let reverse_string = if reverse { "DESC" } else { "ASC" };
@@ -1183,6 +1184,7 @@ impl DbConnection for MysqlConnection {
11831184
reverse: bool,
11841185
hidebroken: bool,
11851186
) -> Result<Vec<ExtraInfo>, Box<dyn Error>> {
1187+
let order = filter_order_1_n(&order)?;
11861188
let query: String;
11871189
let reverse_string = if reverse { "DESC" } else { "ASC" };
11881190
let hidebroken_string = if hidebroken {
@@ -1475,4 +1477,12 @@ fn filter_order(order: &str) -> &str {
14751477
"random" => "RAND()",
14761478
_ => "Name",
14771479
}
1480+
}
1481+
1482+
fn filter_order_1_n(order: &str) -> Result<&str, Box<dyn Error>> {
1483+
match order {
1484+
"name" => Ok("name"),
1485+
"stationcount" => Ok("stationcount"),
1486+
_ => Err(Box::new(DbError::IllegalOrderError(String::from(order)))),
1487+
}
14781488
}

src/pull/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
mod api_error;
1+
mod pull_error;
22

33
use std::error::Error;
44
use std::thread;
@@ -79,7 +79,7 @@ fn pull_history(server: &str, api_version: u32, lastid: Option<String>) -> Resul
7979
Ok(list)
8080
},
8181
_ => {
82-
Err(Box::new(api_error::ApiError::UnknownApiVersion(api_version)))
82+
Err(Box::new(pull_error::PullError::UnknownApiVersion(api_version)))
8383
}
8484
}
8585
}
@@ -103,7 +103,7 @@ fn pull_checks(server: &str, api_version: u32, lastid: Option<String>) -> Result
103103
Ok(list)
104104
},
105105
_ => {
106-
Err(Box::new(api_error::ApiError::UnknownApiVersion(api_version)))
106+
Err(Box::new(pull_error::PullError::UnknownApiVersion(api_version)))
107107
}
108108
}
109109
}
@@ -127,7 +127,7 @@ fn pull_clicks(server: &str, api_version: u32, lastid: Option<String>) -> Result
127127
Ok(list)
128128
},
129129
_ => {
130-
Err(Box::new(api_error::ApiError::UnknownApiVersion(api_version)))
130+
Err(Box::new(pull_error::PullError::UnknownApiVersion(api_version)))
131131
}
132132
}
133133
}
@@ -147,7 +147,7 @@ fn pull_stations(server: &str, api_version: u32) -> Result<Vec<Station>, Box<dyn
147147
Ok(list)
148148
},
149149
_ => {
150-
Err(Box::new(api_error::ApiError::UnknownApiVersion(api_version)))
150+
Err(Box::new(pull_error::PullError::UnknownApiVersion(api_version)))
151151
}
152152
}
153153
}
@@ -241,7 +241,7 @@ fn pull_server(connection_new: &Box<dyn DbConnection>, server: &str) -> Result<(
241241
connection_new.sync_votes(list_stations)?;
242242
}
243243

244-
info!("Pull from '{}' OK (Added station changes: {}, Added station checks: {}, Added station clicks: {})", server, station_change_count, station_check_count, station_click_count);
244+
debug!("Pull from '{}' OK (Added station changes: {}, Added station checks: {}, Added station clicks: {})", server, station_change_count, station_check_count, station_click_count);
245245
Ok(())
246246
}
247247

0 commit comments

Comments
 (0)