@@ -124,15 +124,18 @@ class PodcastSeason:
124124
125125
126126def podcast_public_path (record : dict [str , Any ]) -> str :
127- """Return the canonical season/episode podcast URL without a file extension ."""
127+ """Return the checked canonical podcast detail path ."""
128128
129- season = _podcast_number (record , "season" )
130- episode = _podcast_number (record , "episode" )
131- title = record .get ("title" )
132- if not isinstance (title , str ) or not title .strip ():
133- raise ImproperlyConfigured ("Public podcast title is required for its URL." )
134- key = f"s{ season :02d} e{ episode :02d} "
135- return f"/podcast/{ key } /{ event_title_slug (title )} "
129+ slug = record .get ("slug" )
130+ public_path = record .get ("public_path" )
131+ if (
132+ not isinstance (slug , str )
133+ or not slug
134+ or not isinstance (public_path , str )
135+ or public_path != f"/podcast/{ slug } .html"
136+ ):
137+ raise ImproperlyConfigured ("Public podcast canonical path is invalid." )
138+ return public_path
136139
137140
138141def _podcast_number (record : dict [str , Any ], field : str ) -> int :
@@ -320,61 +323,6 @@ def _apply_runtime_event_public_paths(
320323 )
321324
322325
323- def _replace_exact_public_paths (value : Any , replacements : dict [str , str ]) -> Any :
324- if isinstance (value , str ):
325- return replacements .get (value , value )
326- if isinstance (value , list ):
327- return [_replace_exact_public_paths (item , replacements ) for item in value ]
328- if isinstance (value , dict ):
329- return {key : _replace_exact_public_paths (item , replacements ) for key , item in value .items ()}
330- return value
331-
332-
333- def _apply_runtime_podcast_public_paths (projection : dict [str , Any ]) -> None :
334- """Expose season/episode podcast paths while retaining `.html` source routes as aliases."""
335-
336- replacements : dict [str , str ] = {}
337- podcasts : list [dict [str , Any ]] = []
338- for raw_podcast in projection ["podcasts" ]:
339- podcast = dict (raw_podcast )
340- canonical = podcast_public_path (podcast )
341- replacements [podcast ["public_path" ]] = canonical
342- podcast ["public_path" ] = canonical
343- podcasts .append (podcast )
344- if len ({podcast ["public_path" ] for podcast in podcasts }) != len (podcasts ):
345- raise ImproperlyConfigured ("Public podcast canonical paths are not unique." )
346- projection ["podcasts" ] = tuple (podcasts )
347- projection ["podcasts_by_path" ] = {podcast ["public_path" ]: podcast for podcast in podcasts }
348- projection ["podcasts_by_slug" ] = {
349- slug : projection ["podcasts_by_path" ].get (podcast_public_path (podcast ), podcast )
350- for slug , podcast in projection ["podcasts_by_slug" ].items ()
351- }
352-
353- for person in projection ["people" ]:
354- relationships = person .get ("relationships" , ())
355- person ["relationships" ] = tuple (
356- {
357- ** relationship ,
358- "public_path" : replacements .get (
359- relationship .get ("public_path" ), relationship .get ("public_path" , "" )
360- ),
361- }
362- for relationship in relationships
363- )
364-
365- projection ["wiki_graph" ] = _replace_exact_public_paths (projection ["wiki_graph" ], replacements )
366- projection ["wiki_search" ] = _replace_exact_public_paths (projection ["wiki_search" ], replacements )
367-
368- route_manifest = projection ["editorial_route_migration" ]
369- projection ["editorial_route_aliases_by_path" ] = {
370- item ["source_path" ]: {
371- ** item ,
372- "final_path" : replacements .get (item ["final_path" ], item ["final_path" ]),
373- }
374- for item in route_manifest ["aliases" ]
375- }
376-
377-
378326def _expected_editorial_routes (
379327 projection : dict [str , Any ],
380328) -> tuple [list [dict [str , Any ]], list [dict [str , Any ]]]:
@@ -700,7 +648,6 @@ def _adapted_public_projection(
700648 }
701649 for person in source ["people" ]
702650 )
703- _apply_runtime_podcast_public_paths (projection )
704651 _apply_runtime_event_public_paths (projection , runtime_identities )
705652 # The adapters mutate copied people records; refresh their lookup indexes as well so detail
706653 # pages and relationship tests do not retain references to the checked source records.
0 commit comments