From 146c80e2562dab0f229f13a1fbc0e8ae116d4cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Fri, 3 Oct 2014 19:37:25 +0700 Subject: [PATCH] [utils] Add parse_age_limit --- youtube_dl/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index f8dd9c72d..2615553c1 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -1574,6 +1574,13 @@ def compat_getpass(prompt, *args, **kwargs): } +def parse_age_limit(s): + if s is None: + return 0 + m = re.match(r'^(?P\d{1,2})\+?$', s) + return int(m.group('age')) if m else US_RATINGS.get(s, 0) + + def strip_jsonp(code): return re.sub(r'(?s)^[a-zA-Z0-9_]+\s*\(\s*(.*)\);?\s*?\s*$', r'\1', code)