From 0dc41787af0fb011f01d88c1f2ecb686a8416df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Sun, 17 Mar 2019 09:07:47 +0700 Subject: [utils] Introduce parse_bitrate --- youtube_dl/utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'youtube_dl') 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 """ -- cgit v1.2.3