projects
/
youtube-dl
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
f78c01f
)
[utils] Add parse_age_limit
author
Sergey M․
<dstftw@gmail.com>
Fri, 3 Oct 2014 12:37:25 +0000
(19:37 +0700)
committer
Sergey M․
<dstftw@gmail.com>
Fri, 3 Oct 2014 12:37:25 +0000
(19:37 +0700)
youtube_dl/utils.py
patch
|
blob
|
history
diff --git
a/youtube_dl/utils.py
b/youtube_dl/utils.py
index f8dd9c72d8e07ee7fc231b33f123df4c16b2d6d6..2615553c11117c0e24975b4583602a9595893beb 100644
(file)
--- a/
youtube_dl/utils.py
+++ b/
youtube_dl/utils.py
@@
-1574,6
+1574,13
@@
US_RATINGS = {
}
+def parse_age_limit(s):
+ if s is None:
+ return 0
+ m = re.match(r'^(?P<age>\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)