Skip to content

Commit

Permalink
fix: add server admin token option
Browse files Browse the repository at this point in the history
  • Loading branch information
lostb1t committed Jul 12, 2024
1 parent 47ff8f5 commit c2647e3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Settings are set via [environment variables](https://kinsta.com/knowledgebase/wh
| Setting | Default | Description |
|---------------------------|----------|---------------------------------------------------------------------------|
| REPLEX_HOST | | Url of your plex instance. ex: http://0.0.0.0:32400 |
| REPLEX_TOKEN | | server admin token, needed for hero images |
| REPLEX_INTERLEAVE | true | Interleave home
recommendations. Rows from sifferent sections are interlewved into one. |
| REPLEX_HERO_ROWS | | Comma seperated list of hubidentifiers to make hero style, options are: <br />home.movies.recent<br />movies.recent <br />movie.recentlyadded<br />movie.topunwatched<br />movie.recentlyviewed<br />hub.movie.recentlyreleased<br />movie.recentlyreleased<br />home.television.recent<br />tv.recentlyadded<br />tv.toprated<br />tv.inprogress<br />tv.recentlyaired |
Expand Down
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ fn default_as_false() -> bool {
pub struct Config {
#[serde(deserialize_with = "deserialize_host")]
pub host: Option<String>,
pub token: Option<String>,
pub port: Option<u64>,
#[serde(
default = "default_as_true",
Expand Down
12 changes: 10 additions & 2 deletions src/plex_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ impl PlexClient {
self,
uuid: &String,
) -> Result<MediaContainerWrapper<MediaContainer>> {
let config: Config = Config::figment().extract().unwrap();
let url = format!(
"https://metadata.provider.plex.tv/library/metadata/{}",
uuid
Expand All @@ -360,10 +361,17 @@ impl PlexClient {
url.parse::<url::Url>().unwrap(),
);
let mut headers = HeaderMap::new();
let mut token = config.token.clone();
if token.is_none() {
token = Some(self.x_plex_token.clone());
};
//token = match token {
/// Some(v) => v.as_str(),
// None => self.x_plex_token.clone().as_str()
//};
headers.insert(
"X-Plex-Token",
header::HeaderValue::from_str(self.x_plex_token.clone().as_str())
.unwrap(),
header::HeaderValue::from_str(token.unwrap().as_str()).unwrap(),
);
headers.insert(
"Accept",
Expand Down

0 comments on commit c2647e3

Please sign in to comment.