Skip to content
This repository was archived by the owner on Apr 12, 2025. It is now read-only.

Commit e554bd7

Browse files
committed
fix: #138
1 parent 6bad60f commit e554bd7

File tree

2 files changed

+20
-32
lines changed

2 files changed

+20
-32
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ run:
3333
REPLEX_ENABLE_CONSOLE=0 \
3434
REPLEX_CACHE_TTL=0 \
3535
REPLEX_HUB_RESTRICTIONS=1 \
36-
RUST_LOG="info,replex=info" \
36+
RUST_LOG="info,replex=info,replex::transform=debug" \
3737
REPLEX_NTF_WATCHLIST_FORCE=0 \
3838
RUSTFLAGS=-Awarnings \
3939
cargo watch -w src -x run

src/transform.rs

+19-31
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl TransformBuilder {
113113
'outer: for mut item in metadata {
114114
for filter in self.filters.clone() {
115115
// dbg!("filtering");
116-
if !filter
116+
if filter
117117
.filter_metadata(
118118
item,
119119
self.plex_client.clone(),
@@ -126,26 +126,24 @@ impl TransformBuilder {
126126
}
127127

128128
if !item.children().is_empty() {
129-
// dbg!(item.test().len());
130129
let childs = self.apply_to_metadata(item.children_mut()).await;
131-
// dbg!(childs.len());
132-
// dbg!(&item.test());
133130
item.set_children(childs);
134-
// item.set_children(self.apply_to_metadata(item.test()).await);
135131
}
136132

137133
filtered_childs.push(item.to_owned());
138134
}
139135

140136
return filtered_childs;
141-
// dbg!(&metadata.len());
142137
}
143138

144-
// TODO: join async filters
145139
pub async fn apply_to(
146140
self,
147141
container: &mut MediaContainerWrapper<MediaContainer>,
148142
) {
143+
let children = container.media_container.children_mut();
144+
let new_children = self.apply_to_metadata(children).await;
145+
container.media_container.set_children(new_children);
146+
149147
for t in self.transforms.clone() {
150148
let futures =
151149
container.media_container.children_mut().iter_mut().map(
@@ -173,11 +171,6 @@ impl TransformBuilder {
173171
// dbg!(container.media_container.size);
174172
}
175173

176-
// filter behind transform as transform can load in additional data
177-
let children = container.media_container.children_mut();
178-
let new_children = self.apply_to_metadata(children).await;
179-
container.media_container.set_children(new_children);
180-
181174
if container.media_container.size.is_some() {
182175
container.media_container.size = Some(
183176
container
@@ -249,34 +242,25 @@ impl Filter for HubRestrictionsFilter {
249242
let config: Config = Config::figment().extract().unwrap();
250243

251244
if !config.hub_restrictions {
252-
return true;
253-
}
245+
return false;
246+
}
254247

255248
if item.is_hub() && !item.is_collection_hub() {
256-
return true;
249+
return false;
257250
}
258251

259252
if !item.is_hub() {
260-
return true;
253+
return false;
261254
}
262255

263256
if !item.size.unwrap() == 0 {
264-
return false;
257+
return true;
265258
}
266-
259+
267260
let section_id: i64 = item.library_section_id.unwrap_or_else(|| {
268-
item.clone()
269-
.children()
270-
.get(0)
271-
.unwrap()
272-
.library_section_id
273-
.expect("Missing Library section id")
261+
item.hub_identifier.clone().unwrap().split('.').collect::<Vec<&str>>()[2].parse().unwrap()
274262
});
275263

276-
//let section_id: i64 = item.library_section_id.unwrap_or_else(|| {
277-
// item.hub_identifier.clone().unwrap().split('.').unwrap().2.parse().unwrap()
278-
//});
279-
280264
//let start = Instant::now();
281265
let mut custom_collections = plex_client
282266
.clone()
@@ -295,7 +279,7 @@ impl Filter for HubRestrictionsFilter {
295279
.map(|c| c.rating_key.clone().unwrap())
296280
.collect();
297281

298-
custom_collections_ids.contains(
282+
!custom_collections_ids.contains(
299283
&item
300284
.hub_identifier
301285
.clone()
@@ -723,6 +707,7 @@ impl Transform for HubStyleTransform {
723707
// TODO: Check why tries to load non existing collectiin? my guess is no access
724708
let is_hero =
725709
item.is_hero(plex_client.clone()).await.unwrap_or(false);
710+
726711
if is_hero {
727712
let mut style = ClientHeroStyle::from_context(options.clone());
728713

@@ -980,21 +965,24 @@ impl Transform for HubKeyTransform {
980965
plex_client: PlexClient,
981966
options: PlexContext,
982967
) {
983-
968+
984969
if item.is_hub()
985970
&& item.key.is_some()
986971
&& !item.key.clone().unwrap().starts_with("/replex")
987972
{
988973
// might already been set by the mixings
989974
// setting an url argument crashes client. So we use the path
975+
let old_key = item.key.clone().unwrap();
990976
item.key = Some(format!(
991977
"/replex/{}{}",
992978
item.style
993979
.clone()
994980
.unwrap_or(Style::Shelf.to_string().to_lowercase()),
995-
item.key.clone().unwrap()
981+
old_key
996982
));
983+
tracing::debug!(old_key = old_key, key = &item.key, "Replacing hub key");
997984
}
985+
998986
}
999987
}
1000988

0 commit comments

Comments
 (0)