Skip to content

Commit

Permalink
fix typing issue when videos have no votes and their vote count is No…
Browse files Browse the repository at this point in the history
…ne not 0 in metadata, resolves #50
  • Loading branch information
meeb committed Feb 17, 2021
1 parent 5348e25 commit 3567e20
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tubesync/sync/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,8 +984,12 @@ def rating(self):
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
Expand Down

0 comments on commit 3567e20

Please sign in to comment.