From 88c69dfe56daa8a7621fc9b3a82a890d31ff998f Mon Sep 17 00:00:00 2001 From: Uchechukwu Orji Date: Thu, 10 Oct 2024 14:25:34 +0100 Subject: [PATCH] skip download of speaker image if url is "-" --- CHANGELOG.md | 1 + src/ted2zim/scraper.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a8c271..ef2cfbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Restore functionality to resist temporary bad TED responses when parsing video pages (#209) - Retry video data extraction if `videoData` is missing from page data (#226) +- Skip download of speaker image if URL is "-" (#224) ## [3.0.2] - 2024-06-24 diff --git a/src/ted2zim/scraper.py b/src/ted2zim/scraper.py index 475a0f7..794d9ff 100644 --- a/src/ted2zim/scraper.py +++ b/src/ted2zim/scraper.py @@ -1033,9 +1033,15 @@ def download_speaker_image( ) if not downloaded_from_cache: try: - # download an image of the speaker + # Before downloading a speaker image, check if the URL exists. + # Sometimes, the URL from TED is "-" which is invalid. if not video_speaker: logger.debug("Speaker doesn't have an image") + elif video_speaker == "-": + logger.error( + f"Invalid speaker image URL {video_speaker!r} for " + f"{video_title}" + ) else: logger.debug(f"Downloading Speaker image for {video_title}") self.download_jpeg_image_and_convert(