Skip to content

Commit

Permalink
Fixed #134: account for missing speakers
Browse files Browse the repository at this point in the history
  • Loading branch information
rgaudin committed Aug 4, 2022
1 parent 341c065 commit 00435a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project are documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) (as of version 2.0.11).

## [Unreleased]

### Changed

- Fixed crash on videos without speakers (#134)

## [2.0.11] - 2022-08-01

### Changed
Expand Down
12 changes: 9 additions & 3 deletions ted2zim/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,16 @@ def extract_video_info_from_json(self, json_data):

# Extract the speaker of the TED talk
if len(json_data["speakers"]):
if "nodes" in json_data["speakers"]:
speaker_info = json_data["speakers"]["nodes"][0]
else:
if isinstance(json_data["speakers"], dict):
speaker_info = (
json_data["speakers"]["nodes"][0]
if json_data["speakers"].get("nodes", [])
else {}
)
elif isinstance(json_data["speakers"], list):
speaker_info = json_data["speakers"][0]
else:
raise IOError("Unexpected speaker JSON format: {}".format(json_data))
speaker = " ".join(
[
speaker_info.get("firstame", ""),
Expand Down

0 comments on commit 00435a8

Please sign in to comment.