|
@@ -34,10 +34,15 @@ def fetch_metadata_from_rss(uri: str) -> dict[str, Any]:
|
|
|
logger.warning("Tried to parse uri as RSS feed, but no target found", extra=log_context)
|
|
|
return podcast_data
|
|
|
|
|
|
+ podcast_publisher = feed.feed.get("itunes_publisher")
|
|
|
+ podcast_owner = feed.feed.itunes_owner.get("name") if isinstance(feed.feed.itunes_owner, dict) else feed.feed.itunes_owner
|
|
|
+ podcast_other = feed.feed.get("managingeditor") or feed.feed.get("copyright")
|
|
|
+
|
|
|
podcast_data = {
|
|
|
"podcast_name": feed.feed.get("title", "Unknown Podcast"),
|
|
|
"podcast_description": feed.feed.get("description", ""),
|
|
|
"podcast_link": feed.feed.get("link", ""),
|
|
|
+ "podcast_producer": podcast_publisher or podcast_owner or podcast_other
|
|
|
}
|
|
|
|
|
|
for entry in feed.entries:
|
|
@@ -110,24 +115,20 @@ def get_or_create_podcast(post_data: dict) -> PodcastEpisode:
|
|
|
|
|
|
mopidy_uri = post_data.get("mopidy_uri", "")
|
|
|
parsed_data = parse_mopidy_uri(mopidy_uri)
|
|
|
-
|
|
|
- producer_dict = {"name": post_data.get("artist")}
|
|
|
-
|
|
|
- podcast_name = post_data.get("album")
|
|
|
- if not podcast_name:
|
|
|
- podcast_name = parsed_data.get("podcast_name")
|
|
|
- podcast_dict = {"name": podcast_name}
|
|
|
-
|
|
|
- episode_name = parsed_data.get("episode_filename")
|
|
|
+ producer_name = parsed_data.get("podcast_producer", post_data.get("artist", ""))
|
|
|
+ podcast_name = parsed_data.get("podcast_name", post_data.get("album", ""))
|
|
|
+ episode_name = parsed_data.get("episode_title", parsed_data.get("episode_filename", ""))
|
|
|
run_time_seconds = parsed_data.get("episode_runtime_seconds", post_data.get("run_time", 2700))
|
|
|
+
|
|
|
episode_dict = {
|
|
|
"title": episode_name,
|
|
|
- "run_time_seconds": run_time_seconds,
|
|
|
- "number": parsed_data.get("episode_num"),
|
|
|
+ "podcast_name": podcast_name,
|
|
|
+ "podcast_description": parsed_data.get("podcast_description"),
|
|
|
"pub_date": parsed_data.get("pub_date"),
|
|
|
+ "number": parsed_data.get("episode_num"),
|
|
|
"mopidy_uri": mopidy_uri,
|
|
|
+ "producer_name": producer_name,
|
|
|
+ "run_time_seconds": run_time_seconds,
|
|
|
}
|
|
|
|
|
|
- return PodcastEpisode.find_or_create(
|
|
|
- podcast_dict, producer_dict, episode_dict
|
|
|
- )
|
|
|
+ return PodcastEpisode.find_or_create(**episode_dict)
|