Skip to content

Commit

Permalink
fixed regex error on certain bugs, view counts, and rating
Browse files Browse the repository at this point in the history
  • Loading branch information
nficano committed May 1, 2019
1 parent 4b4136b commit 5f4016b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
14 changes: 12 additions & 2 deletions pytube/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,12 @@ def rating(self):
:rtype: str
"""
return self.player_config_args['player_response']['videoDetails']['averageRating']
return (
self.player_config_args
.get('player_response', {})
.get('videoDetails', {})
.get('averageRating')
)

@property
def length(self):
Expand All @@ -287,7 +292,12 @@ def views(self):
:rtype: str
"""
return self.player_config_args['player_response']['videoDetails']['viewCount']
return (
self.player_config_args
.get('player_response', {})
.get('videoDetails', {})
.get('viewCount')
)

def register_on_progress_callback(self, func):
"""Register a download progress callback function post initialization.
Expand Down
5 changes: 2 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ commit = True
tag = True
current_version = 9.4.0
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+))?
serialize =
serialize =
{major}.{minor}.{patch}

[metadata]
Expand All @@ -15,9 +15,8 @@ description-file = README.md

[coverage:run]
source = pytube
omit =
omit =
pytube/compat.py

[flake8]
ignore = W605

0 comments on commit 5f4016b

Please sign in to comment.