nficano commited on
Commit
627a389
·
unverified ·
2 Parent(s): 57416a0 bfd6901

Merge pull request #311 from kaszperro/master

Browse files
Files changed (2) hide show
  1. .gitignore +3 -1
  2. pytube/query.py +7 -5
.gitignore CHANGED
@@ -39,5 +39,7 @@ _build
39
  _static
40
  _templates
41
  _autosummary
42
-
43
  .pytest_cache*
 
 
 
 
39
  _static
40
  _templates
41
  _autosummary
 
42
  .pytest_cache*
43
+
44
+ #Pycharm stuff
45
+ .idea/*
pytube/query.py CHANGED
@@ -130,14 +130,14 @@ class StreamQuery:
130
  if only_audio:
131
  filters.append(
132
  lambda s: (
133
- s.includes_audio_track and not s.includes_video_track
134
  ),
135
  )
136
 
137
  if only_video:
138
  filters.append(
139
  lambda s: (
140
- s.includes_video_track and not s.includes_audio_track
141
  ),
142
  )
143
 
@@ -167,14 +167,16 @@ class StreamQuery:
167
  attr = getattr(stream, attribute_name)
168
  if attr is None:
169
  break
170
- num = [char for char in attr if char.isdigit()]
171
  integer_attr_repr[attr] = int(''.join(num)) if num else None
172
 
173
  # if every attribute has an integer representation
174
  if integer_attr_repr and all(integer_attr_repr.values()):
175
- def key(s): return integer_attr_repr[getattr(s, attribute_name)]
 
176
  else:
177
- def key(s): return getattr(s, attribute_name)
 
178
 
179
  fmt_streams = sorted(
180
  self.fmt_streams,
 
130
  if only_audio:
131
  filters.append(
132
  lambda s: (
133
+ s.includes_audio_track and not s.includes_video_track
134
  ),
135
  )
136
 
137
  if only_video:
138
  filters.append(
139
  lambda s: (
140
+ s.includes_video_track and not s.includes_audio_track
141
  ),
142
  )
143
 
 
167
  attr = getattr(stream, attribute_name)
168
  if attr is None:
169
  break
170
+ num = ''.join(x for x in attr if x.isdigit())
171
  integer_attr_repr[attr] = int(''.join(num)) if num else None
172
 
173
  # if every attribute has an integer representation
174
  if integer_attr_repr and all(integer_attr_repr.values()):
175
+ def key(s):
176
+ return integer_attr_repr[getattr(s, attribute_name)]
177
  else:
178
+ def key(s):
179
+ return getattr(s, attribute_name)
180
 
181
  fmt_streams = sorted(
182
  self.fmt_streams,