예제 #1
0
def download_podcast(directory: RadioDirectory, channel: Channel,
                     podcast: Podcast) -> Podcast:
    location = download_location(directory, channel, podcast)
    url = get_podcast_audio_link(podcast)

    # TODO: This takes some time, especially when there are a lot to
    # download. I could have this spawn threads, or add priorities,
    # and so on. For now, since it runs every few hours, and is more
    # of a push than a pull situation for the user, I'm leaving it
    # simple
    success = _download_from_url(url, location)

    if success:
        return podcast._replace(status=NewStatus())
    else:
        return podcast
예제 #2
0
 def apply_delete_on_right_podcast(channel: Channel,
                                   podcast: Podcast) -> Podcast:
     if get_podcast_id(podcast) == podcast_id:
         _delete_podcast_file(radio.directory, channel, podcast)
         podcast = podcast._replace(status=DeletedStatus())
     return podcast