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

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
segler-alex committed Dec 11, 2019
2 parents 892657e + 887e53e commit 22f973c
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 210 deletions.
88 changes: 44 additions & 44 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "Radio-Browser Server with REST API"
license = "agpl-3.0"
name = "radiobrowser-api-rust"
readme = "README.md"
version = "0.5.0"
version = "0.5.1"
edition = "2018"

[dependencies]
Expand All @@ -24,7 +24,7 @@ reqwest = "0.9.22"
rouille = "3.0.0"
serde = "1.0.103"
serde_derive ="1.0.103"
serde_json = "1.0.42"
serde_json = "1.0.44"
threadpool = "1.7.1"
toml = "0.5.5"
url = "2.1.0"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ This is the radio browser server part providing the API on http://www.radio-brow

Send me feature requests, bug reports or extend it yourself. I license it freely, you could also start your own server if you wish.

You can find the API documentation on http://www.radio-browser.info/webservice
You can find the API documentation on http://www.radio-browser.info/gui/#!/api

## Setup
You can do a native setup or a docker setup

### easy all in one docker setup with automatic tls from lets encrypt
* This has been tested on ubuntu 18.04
### easy all-in-one docker setup with automatic TLS from Let's Encrypt
* This has been tested on Ubuntu 18.04
* Automatic redirect from HTTP to HTTPS
* Automatic generation and update of lets encrypt certificates
* Automatic generation and update of Let's Encrypt certificates
* Automatic start on reboot
* Automatic fetch of station changes and check information from main server at http://api.radio-browser.info

Expand Down
27 changes: 8 additions & 19 deletions src/api/data/station.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ pub struct Station {
pub stationuuid: String,
pub name: String,
pub url: String,
#[serde(skip_serializing)]
pub urlcache: String,
pub url_resolved: String,
pub homepage: String,
pub favicon: String,
pub tags: String,
Expand All @@ -46,7 +45,6 @@ pub struct Station {
pub state: String,
pub language: String,
pub votes: i32,
pub negativevotes: i32,
pub lastchangetime: String,
pub ip: String,
pub codec: String,
Expand All @@ -67,7 +65,7 @@ impl Station {
stationuuid: String,
name: String,
url: String,
urlcache: String,
url_resolved: String,
homepage: String,
favicon: String,
tags: String,
Expand All @@ -76,7 +74,6 @@ impl Station {
state: String,
language: String,
votes: i32,
negativevotes: i32,
lastchangetime: String,
ip: String,
codec: String,
Expand All @@ -95,7 +92,7 @@ impl Station {
stationuuid,
name,
url,
urlcache,
url_resolved,
homepage,
favicon,
tags,
Expand All @@ -104,7 +101,6 @@ impl Station {
state,
language,
votes,
negativevotes,
lastchangetime,
ip,
codec,
Expand All @@ -126,7 +122,7 @@ impl Station {
id: station.id,
stationuuid: station.stationuuid,
name: station.name,
url: station.urlcache,
url: station.url_resolved,
};
}

Expand All @@ -141,6 +137,7 @@ impl Station {
xml.attr_esc("stationuuid", &entry.stationuuid)?;
xml.attr_esc("name", &entry.name)?;
xml.attr_esc("url", &entry.url)?;
xml.attr_esc("url_resolved", &entry.url_resolved)?;
xml.attr_esc("homepage", &entry.homepage)?;
xml.attr_esc("favicon", &entry.favicon)?;
xml.attr_esc("tags", &entry.tags)?;
Expand All @@ -150,8 +147,6 @@ impl Station {
xml.attr_esc("language", &entry.language)?;
let station_votes_str = format!("{}", entry.votes);
xml.attr_esc("votes", &station_votes_str)?;
let station_negativevotes_str = format!("{}", entry.negativevotes);
xml.attr_esc("negativevotes", &station_negativevotes_str)?;
let station_lastchangetime_str = format!("{}", entry.lastchangetime);
xml.attr_esc("lastchangetime", &station_lastchangetime_str)?;
xml.attr_esc("ip", &entry.ip)?;
Expand Down Expand Up @@ -188,7 +183,7 @@ impl Station {
j.push_str(&item.name);
j.push_str("\r\n");
if use_cached_url {
j.push_str(&item.urlcache);
j.push_str(&item.url_resolved);
} else {
j.push_str(&item.url);
}
Expand All @@ -212,7 +207,7 @@ impl Station {
j.push_str(&i_str);
j.push_str("=");
if use_cached_url {
j.push_str(&item.urlcache);
j.push_str(&item.url_resolved);
} else {
j.push_str(&item.url);
}
Expand Down Expand Up @@ -276,10 +271,6 @@ impl Station {
schema:name "votes" ;
schema:value "{votes}"
] ;
schema:PropertyValue [
schema:name "negativevotes" ;
schema:value "{negativevotes}"
] ;
schema:PropertyValue [
schema:name "lastchangetime" ;
schema:value "{lastchangetime}"
Expand Down Expand Up @@ -341,7 +332,6 @@ impl Station {
state = self.state,
language = self.language,
votes = self.votes,
negativevotes = self.negativevotes,
ip = self.ip,
codec = self.codec,
bitrate = self.bitrate,
Expand Down Expand Up @@ -419,7 +409,6 @@ impl From<&StationHistoryCurrent> for Station {
state: item.state.clone(),
language: item.language.clone(),
votes: item.votes,
negativevotes: item.negativevotes,
lastchangetime: item.lastchangetime.clone(),
ip: item.ip.clone(),
bitrate: 0,
Expand All @@ -431,7 +420,7 @@ impl From<&StationHistoryCurrent> for Station {
lastcheckok: 0,
lastcheckoktime: String::from(""),
lastchecktime: String::from(""),
urlcache: String::from(""),
url_resolved: String::from(""),
}
}
}
32 changes: 2 additions & 30 deletions src/api/data/station_add_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,23 @@
pub struct StationAddResult {
ok: bool,
message: String,
id: u64,
uuid: String,
stream_check_ok: bool,
stream_check_bitrate: u32,
stream_check_codec: String,
favicon_check_done: bool,
favicon_check_ok: bool,
favicon_check_url: String,
uuid: String
}

impl StationAddResult {
pub fn new_ok(id: u64, stationuuid: String) -> StationAddResult {
pub fn new_ok(stationuuid: String) -> StationAddResult {
StationAddResult{
ok: true,
message: "added station successfully".to_string(),
id: id,
uuid: stationuuid,
stream_check_ok: false,
stream_check_bitrate: 0,
stream_check_codec: "".to_string(),
favicon_check_done: false,
favicon_check_ok: false,
favicon_check_url: "".to_string(),
}
}

pub fn new_err(err: &str) -> StationAddResult {
StationAddResult{
ok: false,
message: err.to_string(),
id: 0,
uuid: "".to_string(),
stream_check_ok: false,
stream_check_bitrate: 0,
stream_check_codec: "".to_string(),
favicon_check_done: false,
favicon_check_ok: false,
favicon_check_url: "".to_string(),
}
}

Expand All @@ -49,14 +28,7 @@ impl StationAddResult {
xml.begin_elem("status")?;
xml.attr_esc("ok", &self.ok.to_string())?;
xml.attr_esc("message", &self.ok.to_string())?;
xml.attr_esc("id", &self.id.to_string())?;
xml.attr_esc("uuid", &self.uuid)?;
xml.attr_esc("stream_check_ok", &self.stream_check_ok.to_string())?;
xml.attr_esc("stream_check_bitrate", &self.stream_check_bitrate.to_string())?;
xml.attr_esc("stream_check_codec", &self.stream_check_codec)?;
xml.attr_esc("favicon_check_done", &self.favicon_check_done.to_string())?;
xml.attr_esc("favicon_check_ok", &self.favicon_check_ok.to_string())?;
xml.attr_esc("favicon_check_url", &self.favicon_check_url.to_string())?;
xml.end_elem()?;
xml.end_elem()?;
xml.close()?;
Expand Down
8 changes: 0 additions & 8 deletions src/api/data/station_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub struct StationHistoryV0 {
state: String,
language: String,
votes: String,
negativevotes: String,
lastchangetime: String,
ip: String,
}
Expand All @@ -33,7 +32,6 @@ pub struct StationHistoryCurrent {
pub state: String,
pub language: String,
pub votes: i32,
pub negativevotes: i32,
pub lastchangetime: String,
pub ip: String,
}
Expand All @@ -54,7 +52,6 @@ impl From<StationHistoryV0> for StationHistoryCurrent {
state: item.state,
language: item.language,
votes: item.votes.parse().unwrap(),
negativevotes: item.negativevotes.parse().unwrap(),
lastchangetime: item.lastchangetime,
ip: item.ip,
}
Expand All @@ -77,7 +74,6 @@ impl From<&StationHistoryV0> for StationHistoryCurrent {
state: item.state.clone(),
language: item.language.clone(),
votes: item.votes.parse().unwrap(),
negativevotes: item.negativevotes.parse().unwrap(),
lastchangetime: item.lastchangetime.clone(),
ip: item.ip.clone(),
}
Expand All @@ -99,7 +95,6 @@ impl StationHistoryCurrent {
state: String,
language: String,
votes: i32,
negativevotes: i32,
lastchangetime: String,
ip: String,
) -> Self {
Expand All @@ -117,7 +112,6 @@ impl StationHistoryCurrent {
state,
language,
votes,
negativevotes,
lastchangetime,
ip,
}
Expand All @@ -141,8 +135,6 @@ impl StationHistoryCurrent {
xml.attr_esc("language", &entry.language)?;
let station_votes_str = format!("{}", entry.votes);
xml.attr_esc("votes", &station_votes_str)?;
let station_negativevotes_str = format!("{}", entry.negativevotes);
xml.attr_esc("negativevotes", &station_negativevotes_str)?;
let station_lastchangetime_str = format!("{}", entry.lastchangetime);
xml.attr_esc("lastchangetime", &station_lastchangetime_str)?;
xml.attr_esc("ip", &entry.ip)?;
Expand Down
Loading

0 comments on commit 22f973c

Please sign in to comment.