Mattwmaster58 commited on
Commit
2ede878
·
1 Parent(s): b5f636a

fix streams.get_by_itag function. (#288)

Browse files
Files changed (2) hide show
  1. pytube/query.py +2 -2
  2. tests/test_query.py +1 -0
pytube/query.py CHANGED
@@ -187,7 +187,7 @@ class StreamQuery:
187
  def get_by_itag(self, itag):
188
  """Get the corresponding :class:`Stream <Stream>` for a given itag.
189
 
190
- :param str itag:
191
  YouTube format identifier code.
192
  :rtype: :class:`Stream <Stream>` or None
193
  :returns:
@@ -196,7 +196,7 @@ class StreamQuery:
196
 
197
  """
198
  try:
199
- return self.itag_index[itag]
200
  except KeyError:
201
  pass
202
 
 
187
  def get_by_itag(self, itag):
188
  """Get the corresponding :class:`Stream <Stream>` for a given itag.
189
 
190
+ :param str int itag:
191
  YouTube format identifier code.
192
  :rtype: :class:`Stream <Stream>` or None
193
  :returns:
 
196
 
197
  """
198
  try:
199
+ return self.itag_index[int(itag)]
200
  except KeyError:
201
  pass
202
 
tests/test_query.py CHANGED
@@ -111,6 +111,7 @@ def test_get_by_itag(cipher_signature):
111
  :class:`Stream <Stream>`.
112
  """
113
  assert cipher_signature.streams.get_by_itag(22).itag == '22'
 
114
 
115
 
116
  def test_get_by_non_existent_itag(cipher_signature):
 
111
  :class:`Stream <Stream>`.
112
  """
113
  assert cipher_signature.streams.get_by_itag(22).itag == '22'
114
+ assert cipher_signature.streams.get_by_itag('22').itag == '22'
115
 
116
 
117
  def test_get_by_non_existent_itag(cipher_signature):