diff --git a/larigira/audiogen_podcast.py b/larigira/audiogen_podcast.py index b18d738..88ae56e 100644 --- a/larigira/audiogen_podcast.py +++ b/larigira/audiogen_podcast.py @@ -6,11 +6,11 @@ import sys from subprocess import CalledProcessError, check_output import requests - -from larigira.fsutils import download_http from lxml import html from pytimeparse.timeparse import timeparse +from larigira.fsutils import download_http + def delta_humanreadable(tdelta): if tdelta is None: @@ -35,8 +35,9 @@ def get_duration(url): url, ] ).split(b"\n") - except CalledProcessError as exc: - raise ValueError("error probing `%s`" % url) from exc + except CalledProcessError: + logging.exception("error probing `%s`", url) + return 0 duration = next(l for l in lineout if l.startswith(b"duration=")) value = duration.split(b"=")[1] return int(float(value)) @@ -45,9 +46,7 @@ def get_duration(url): class Audio(object): def __init__(self, url, duration=None, date=None): self.url = url - if duration is None: - duration = get_duration(url.encode("utf-8")) - self.duration = duration + self._duration = duration self.date = date self.end_date = datetime.datetime( 9999, 12, 31, tzinfo=datetime.timezone.utc @@ -58,9 +57,16 @@ class Audio(object): def __repr__(self): return "