Verified Commit 21972d96 authored by Agate's avatar Agate 💬

See #170: fixed several feed parsing issues, again 2

parent d591292a
Pipeline #9934 passed with stages
in 7 minutes and 54 seconds
......@@ -989,3 +989,5 @@ PODCASTS_THIRD_PARTY_VISIBILITY = env("PODCASTS_THIRD_PARTY_VISIBILITY", default
PODCASTS_RSS_FEED_REFRESH_DELAY = env.int(
"PODCASTS_RSS_FEED_REFRESH_DELAY", default=60 * 60 * 24
)
# maximum items loaded through XML feed
PODCASTS_RSS_FEED_MAX_ITEMS = env.int("PODCASTS_RSS_FEED_MAX_ITEMS", default=250)
......@@ -366,8 +366,10 @@ def get_channel_from_rss_url(url):
)
)
if parsed_feed.feed.get("rights"):
track_defaults["copyright"] = parsed_feed.feed.rights
for entry in entries:
track_defaults["copyright"] = parsed_feed.feed.rights[
: music_models.MAX_LENGTHS["COPYRIGHT"]
]
for entry in entries[: settings.PODCASTS_RSS_FEED_MAX_ITEMS]:
logger.debug("Importing feed item %s", entry.id)
s = RssFeedItemSerializer(data=entry)
if not s.is_valid():
......@@ -510,7 +512,9 @@ class RssFeedSerializer(serializers.Serializer):
**artist_kwargs,
defaults={
"attributed_to": service_actor,
"name": validated_data["title"],
"name": validated_data["title"][
: music_models.MAX_LENGTHS["ARTIST_NAME"]
],
"content_category": "podcast",
},
)
......@@ -695,12 +699,16 @@ class RssFeedItemSerializer(serializers.Serializer):
{
"disc_number": validated_data.get("itunes_season", 1),
"position": validated_data.get("itunes_episode", 1),
"title": validated_data["title"],
"title": validated_data["title"][
: music_models.MAX_LENGTHS["TRACK_TITLE"]
],
"artist": channel.artist,
}
)
if "rights" in validated_data:
track_defaults["rights"] = validated_data["rights"]
track_defaults["rights"] = validated_data["rights"][
: music_models.MAX_LENGTHS["COPYRIGHT"]
]
if "published_parsed" in validated_data:
track_defaults["creation_date"] = datetime.datetime.fromtimestamp(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment