Skip to content

receivers

fetch_avatar_for_person

fetch_avatar_for_person(
    sender, instance, created, raw, *args, **kwargs
)

When a person is saved, if they have an img_url but not a cached avatar send a task to retrieve it to the worker queue.

Source code in src/podcast_analyzer/receivers.py
@receiver(post_save, sender=Person)
def fetch_avatar_for_person(sender, instance, created, raw, *args, **kwargs):  # noqa: ARG001
    """
    When a person is saved, if they have an img_url but not a cached avatar
    send a task to retrieve it to the worker queue.
    """
    if not raw:
        logger.debug("Checking if this person has an img_url...")
        if instance.img_url and not instance.avatar:
            async_task("podcast_analyzer.tasks.fetch_avatar_for_person", instance)

import_podcast_on_create

import_podcast_on_create(
    sender, instance, created, raw, *args, **kwargs
)

When a podcast is created, schedule it for importing of feed data.

Source code in src/podcast_analyzer/receivers.py
@receiver(post_save, sender=Podcast)
def import_podcast_on_create(sender, instance, created, raw, *args, **kwargs):  # noqa: ARG001
    """
    When a podcast is created, schedule it for importing of feed data.
    """
    logger.debug("Checking to see if this is a new podcast...")
    if created and not raw:
        logger.debug(
            f"New podcast created! Adding a task to fetch "
            f"feed data from {instance.rss_feed}"
        )
        async_task(async_refresh_feed, podcast_id=instance.id)