From 3567e2060068e09dd5fff0385e9a79e8debbbae0 Mon Sep 17 00:00:00 2001 From: meeb Date: Wed, 17 Feb 2021 22:14:29 +1100 Subject: [PATCH] fix typing issue when videos have no votes and their vote count is None not 0 in metadata, resolves #50 --- tubesync/sync/models.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tubesync/sync/models.py b/tubesync/sync/models.py index 9826f9d..125055d 100644 --- a/tubesync/sync/models.py +++ b/tubesync/sync/models.py @@ -984,8 +984,12 @@ class Media(models.Model): def votes(self): field = self.get_metadata_field('upvotes') upvotes = self.loaded_metadata.get(field, 0) + if not isinstance(upvotes, int): + upvotes = 0 field = self.get_metadata_field('downvotes') downvotes = self.loaded_metadata.get(field, 0) + if not isinstance(downvotes, int): + downvotes = 0 return upvotes + downvotes @property