@@ -113,7 +113,7 @@ impl TransformBuilder {
113
113
' outer: for mut item in metadata {
114
114
for filter in self . filters . clone ( ) {
115
115
// dbg!("filtering");
116
- if ! filter
116
+ if filter
117
117
. filter_metadata (
118
118
item,
119
119
self . plex_client . clone ( ) ,
@@ -126,26 +126,24 @@ impl TransformBuilder {
126
126
}
127
127
128
128
if !item. children ( ) . is_empty ( ) {
129
- // dbg!(item.test().len());
130
129
let childs = self . apply_to_metadata ( item. children_mut ( ) ) . await ;
131
- // dbg!(childs.len());
132
- // dbg!(&item.test());
133
130
item. set_children ( childs) ;
134
- // item.set_children(self.apply_to_metadata(item.test()).await);
135
131
}
136
132
137
133
filtered_childs. push ( item. to_owned ( ) ) ;
138
134
}
139
135
140
136
return filtered_childs;
141
- // dbg!(&metadata.len());
142
137
}
143
138
144
- // TODO: join async filters
145
139
pub async fn apply_to (
146
140
self ,
147
141
container : & mut MediaContainerWrapper < MediaContainer > ,
148
142
) {
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
+
149
147
for t in self . transforms . clone ( ) {
150
148
let futures =
151
149
container. media_container . children_mut ( ) . iter_mut ( ) . map (
@@ -173,11 +171,6 @@ impl TransformBuilder {
173
171
// dbg!(container.media_container.size);
174
172
}
175
173
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
-
181
174
if container. media_container . size . is_some ( ) {
182
175
container. media_container . size = Some (
183
176
container
@@ -249,34 +242,25 @@ impl Filter for HubRestrictionsFilter {
249
242
let config: Config = Config :: figment ( ) . extract ( ) . unwrap ( ) ;
250
243
251
244
if !config. hub_restrictions {
252
- return true ;
253
- }
245
+ return false ;
246
+ }
254
247
255
248
if item. is_hub ( ) && !item. is_collection_hub ( ) {
256
- return true ;
249
+ return false ;
257
250
}
258
251
259
252
if !item. is_hub ( ) {
260
- return true ;
253
+ return false ;
261
254
}
262
255
263
256
if !item. size . unwrap ( ) == 0 {
264
- return false ;
257
+ return true ;
265
258
}
266
-
259
+
267
260
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 ( )
274
262
} ) ;
275
263
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
-
280
264
//let start = Instant::now();
281
265
let mut custom_collections = plex_client
282
266
. clone ( )
@@ -295,7 +279,7 @@ impl Filter for HubRestrictionsFilter {
295
279
. map ( |c| c. rating_key . clone ( ) . unwrap ( ) )
296
280
. collect ( ) ;
297
281
298
- custom_collections_ids. contains (
282
+ ! custom_collections_ids. contains (
299
283
& item
300
284
. hub_identifier
301
285
. clone ( )
@@ -723,6 +707,7 @@ impl Transform for HubStyleTransform {
723
707
// TODO: Check why tries to load non existing collectiin? my guess is no access
724
708
let is_hero =
725
709
item. is_hero ( plex_client. clone ( ) ) . await . unwrap_or ( false ) ;
710
+
726
711
if is_hero {
727
712
let mut style = ClientHeroStyle :: from_context ( options. clone ( ) ) ;
728
713
@@ -980,21 +965,24 @@ impl Transform for HubKeyTransform {
980
965
plex_client : PlexClient ,
981
966
options : PlexContext ,
982
967
) {
983
-
968
+
984
969
if item. is_hub ( )
985
970
&& item. key . is_some ( )
986
971
&& !item. key . clone ( ) . unwrap ( ) . starts_with ( "/replex" )
987
972
{
988
973
// might already been set by the mixings
989
974
// setting an url argument crashes client. So we use the path
975
+ let old_key = item. key . clone ( ) . unwrap ( ) ;
990
976
item. key = Some ( format ! (
991
977
"/replex/{}{}" ,
992
978
item. style
993
979
. clone( )
994
980
. unwrap_or( Style :: Shelf . to_string( ) . to_lowercase( ) ) ,
995
- item . key . clone ( ) . unwrap ( )
981
+ old_key
996
982
) ) ;
983
+ tracing:: debug!( old_key = old_key, key = & item. key, "Replacing hub key" ) ;
997
984
}
985
+
998
986
}
999
987
}
1000
988
0 commit comments