nficano commited on
Commit
4b4136b
·
1 Parent(s): bb4e580

fixed regex error on certain bugs, view counts, and rating

Browse files
Files changed (3) hide show
  1. .gitignore +2 -0
  2. pytube/__main__.py +2 -2
  3. pytube/extract.py +0 -7
.gitignore CHANGED
@@ -45,3 +45,5 @@ _autosummary
45
  .idea/
46
  #Pycharm stuff
47
  .idea/*
 
 
 
45
  .idea/
46
  #Pycharm stuff
47
  .idea/*
48
+
49
+ .vscode/
pytube/__main__.py CHANGED
@@ -269,7 +269,7 @@ class YouTube(object):
269
  :rtype: str
270
 
271
  """
272
- return self.player_config_args['avg_rating']
273
 
274
  @property
275
  def length(self):
@@ -287,7 +287,7 @@ class YouTube(object):
287
  :rtype: str
288
 
289
  """
290
- return self.player_config_args['view_count']
291
 
292
  def register_on_progress_callback(self, func):
293
  """Register a download progress callback function post initialization.
 
269
  :rtype: str
270
 
271
  """
272
+ return self.player_config_args['player_response']['videoDetails']['averageRating']
273
 
274
  @property
275
  def length(self):
 
287
  :rtype: str
288
 
289
  """
290
+ return self.player_config_args['player_response']['videoDetails']['viewCount']
291
 
292
  def register_on_progress_callback(self, func):
293
  """Register a download progress callback function post initialization.
pytube/extract.py CHANGED
@@ -122,19 +122,12 @@ def video_info_url(
122
  ('sts', sts),
123
  ])
124
  else:
125
- # I'm not entirely sure what ``t`` represents. Looks to represent a
126
- # boolean.
127
- t = regex_search(
128
- r'\W[\'"]?t[\'"]?: ?[\'"](.+?)[\'"]', watch_html,
129
- group=0,
130
- )
131
  params = OrderedDict([
132
  ('video_id', video_id),
133
  ('el', '$el'),
134
  ('ps', 'default'),
135
  ('eurl', quote(watch_url)),
136
  ('hl', 'en_US'),
137
- ('t', quote(t)),
138
  ])
139
  return 'https://youtube.com/get_video_info?' + urlencode(params)
140
 
 
122
  ('sts', sts),
123
  ])
124
  else:
 
 
 
 
 
 
125
  params = OrderedDict([
126
  ('video_id', video_id),
127
  ('el', '$el'),
128
  ('ps', 'default'),
129
  ('eurl', quote(watch_url)),
130
  ('hl', 'en_US'),
 
131
  ])
132
  return 'https://youtube.com/get_video_info?' + urlencode(params)
133