Skip to content

Commit

Permalink
fix: deprecate auto refresh cache
Browse files Browse the repository at this point in the history
  • Loading branch information
lostb1t committed Jul 10, 2024
1 parent cf885e4 commit 109ed6d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ run:
REPLEX_VIDEO_TRANSCODE_FALLBACK_FOR="4k" \
REPLEX_AUTO_SELECT_VERSION=0 \
REPLEX_FORCE_MAXIMUM_QUALITY=1 \
REPLEX_CACHE_ROWS=0 \
REPLEX_CACHE_ROWS=1 \
REPLEX_CACHE_ROWS_REFRESH=0 \
REPLEX_HERO_ROWS="home.movies.recent,movies.recent,movie.recentlyadded,movie.topunwatched,movie.recentlyviewed,hub.movie.recentlyreleased,home.television.recent,tv.inprogress,tv.recentlyaired" \
REPLEX_PORT=8000 \
REPLEX_INCLUDE_WATCHED=0 \
Expand All @@ -31,7 +32,7 @@ run:
REPLEX_DISABLE_LEAF_COUNT=0 \
REPLEX_DISABLE_USER_STATE=0 \
REPLEX_ENABLE_CONSOLE=0 \
REPLEX_CACHE_TTL=0 \
REPLEX_CACHE_TTL=600 \
REPLEX_NTF_WATCHLIST_FORCE=1 \
RUST_LOG="info,replex=info" \
RUSTFLAGS=-Awarnings \
Expand Down
14 changes: 1 addition & 13 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub struct Config {
deserialize_with = "figment::util::bool_from_str_or_int"
)]
pub cache_rows: bool,
#[deprecated]
#[serde(
default = "default_as_true",
deserialize_with = "figment::util::bool_from_str_or_int"
Expand Down Expand Up @@ -133,28 +134,15 @@ impl Config {
}

pub fn dynamic(req: &salvo::Request) -> Figment {
// dbg!(&req);
// use base64::{Engine as _, alphabet, engine::{self, general_purpose}};
// use base32::{decode, CrockfordBase32};
// use crockford::decode;
let host = req.headers().get("HOST").unwrap().to_str().unwrap();
let mut config = Config::figment();
if host.contains("replex.stream") {
use data_encoding::BASE32;
let val: Vec<&str> = host.split(".replex.stream").collect();
let owned_val = val[0].to_ascii_uppercase().to_owned();
// dbg!(&val);
// let mut decoded_host: String = String::new();
// let decoded_host = general_purpose::STANDARD
// .decode(val[0]).unwrap();
// let decoded_host = decode(CrockfordBase32, &owned_val[..]);
// let decoded_host: String = crockford::decode(val[0].to_uppercase()).unwrap().to_string();
let mut output = vec![0; BASE32.decode_len(owned_val.len()).unwrap()];
let len = BASE32.decode_mut(owned_val.as_bytes(), &mut output).unwrap();
// dbg!(std::str::from_utf8(&output[0 .. len]).unwrap());
config = config.join(("host", std::str::from_utf8(&output[0 .. len]).unwrap()));
// config = config.join(("host", decoded_host));

}
config
// Figment::new().merge(Env::prefixed("REPLEX_"))
Expand Down
5 changes: 3 additions & 2 deletions src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub fn route() -> Router {
// .unwrap(),
// );

//let default_cache = default_cache()
let mut router = Router::with_hoop(Cors::permissive().into_handler())
.hoop(Logger::new())
.hoop(should_skip)
Expand Down Expand Up @@ -148,13 +149,13 @@ pub fn route() -> Router {
.push(
Router::new()
.path(PLEX_HUBS_PROMOTED)
.hoop(auto_refresh_cache())
.hoop(default_cache())
.get(transform_hubs_home),
)
.push(
Router::new()
.path(format!("{}/<id>", PLEX_HUBS_SECTIONS))
.hoop(auto_refresh_cache())
.hoop(default_cache())
.get(get_hubs_sections),
)
.push(
Expand Down

0 comments on commit 109ed6d

Please sign in to comment.