From d838b1bd4a256484820af7aeb0c2711934cb00ad Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Fri, 3 Oct 2014 20:17:10 +0200 Subject: [PATCH] [utils] Default age_limit to None If we can't parse it, it means we don't have any information, not that the content is unrestricted. --- youtube_dl/extractor/common.py | 2 ++ youtube_dl/utils.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py index 611cf95f1..450c7dfd6 100644 --- a/youtube_dl/extractor/common.py +++ b/youtube_dl/extractor/common.py @@ -138,6 +138,8 @@ class InfoExtractor(object): Unless mentioned otherwise, the fields should be Unicode strings. + Unless mentioned otherwise, None is equivalent to absence of information. + Subclasses of this one should re-define the _real_initialize() and _real_extract() methods and define a _VALID_URL regexp. Probably, they should also be added to the list of extractors. diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 2615553c1..2c9081733 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -1576,9 +1576,9 @@ US_RATINGS = { def parse_age_limit(s): if s is None: - return 0 + return None m = re.match(r'^(?P\d{1,2})\+?$', s) - return int(m.group('age')) if m else US_RATINGS.get(s, 0) + return int(m.group('age')) if m else US_RATINGS.get(s, None) def strip_jsonp(code):