aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2019-03-17 09:07:47 +0700
committerSergey M․ <dstftw@gmail.com>2019-03-17 09:07:47 +0700
commit0dc41787af0fb011f01d88c1f2ecb686a8416df5 (patch)
tree42bdaecb36f30b6be28de42a5a94471d42f8c3db /youtube_dl/utils.py
parente5cfb779ea0814971324d693e02f8c4d4ca78600 (diff)
[utils] Introduce parse_bitrate
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 630dab8eb..f2726a579 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -1798,6 +1798,14 @@ def parse_resolution(s):
return {}
+def parse_bitrate(s):
+ if not isinstance(s, compat_str):
+ return
+ mobj = re.search(r'\b(\d+)\s*kbps', s)
+ if mobj:
+ return int(mobj.group(1))
+
+
def month_by_name(name, lang='en'):
""" Return the number of a month by (locale-independently) English name """