Spodcast/spodcast/app.py
Frank de Lange 0877f04cb1 Spodcast v0.5.0 which:
- fixes #13 (Cannot download episodes anymore)
 - uses _librespot-python_ interfaces instead of raw web API access (needed to fix #13)
 - can not yet determine decrypted file size for Spotify-hosted episodes (which used to work) so will only look at the file name to determine whether an episode has already been downloaded. To retry corrupted downloads just remove the partially downloaded file and try again.
2022-06-30 16:52:41 +00:00

30 lines
1.2 KiB
Python

import logging
from itertools import islice
from librespot.audio.decoders import AudioQuality
from librespot.metadata import ShowId, EpisodeId
from spodcast.podcast import download_episode, get_episodes
from spodcast.utils import regex_input_for_urls
from spodcast.spodcast import Spodcast
log = logging.getLogger(__name__)
def client(args) -> None:
Spodcast(args)
Spodcast.DOWNLOAD_QUALITY = AudioQuality.NORMAL
if args.urls:
for spotify_url in args.urls:
episode_id_str, show_id_str = regex_input_for_urls(spotify_url)
log.debug(f"episode_id_str {episode_id_str}. show_id_str {show_id_str}")
if episode_id_str is not None:
episode_id = EpisodeId.from_base62(episode_id_str)
log.debug("episode_id: %s", episode_id)
download_episode(episode_id)
elif show_id_str is not None:
show_id = ShowId.from_base62(show_id_str)
log.debug("show_id: %s", show_id)
for episode_id in islice(get_episodes(show_id), Spodcast.CONFIG.get_max_episodes()):
log.debug("episode_id: %s", episode_id)
download_episode(episode_id)