Skip to content

Commit

Permalink
Skip incomplete EPG events to avoid errors
Browse files Browse the repository at this point in the history
I noticed epg.py sometimes fails with an error like this:

    AttributeError: 'Event' object has no attribute 'genre'

or:

    AttributeError: 'Nonetype' object has no attribute 'total_seconds'

Evidently some EPG events lack fields. This fixes the issue
by Ignoring these incomplete events.

Signed-off-by: Fujimoto Seiji <[email protected]>
  • Loading branch information
Fujimoto Seiji committed Jul 6, 2022
1 parent 1b1bf18 commit babcaac
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ariblib/command/epg.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ def extract_epg(ts, threshold=5):

events = [Event(section, e) for e in section.events]
for event in events:
# The key to uniquely identify each program.
key = (str(event.start_time), str(event.title))
count[key] += 1
programs[key] = dump_json(event)
duration = getattr(event, "duration", None)
genre = getattr(event, "genre", None)
if duration and genre:
# The key to uniquely identify each program.
key = (str(event.start_time), str(event.title))
count[key] += 1
programs[key] = dump_json(event)

for key in sorted(programs):
# EPG info is transmitted once per second over network, and we
Expand Down

0 comments on commit babcaac

Please sign in to comment.