diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2014-02-06 11:29:46 +0100 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2014-02-06 11:29:46 +0100 |
commit | 5de90176d94ebfac421b5db9c897f9ac69595cda (patch) | |
tree | 160a470add8805824653b3ffa54430ec8f768f58 /youtube_dl/utils.py | |
parent | dcf3eec47a0519b424961b43c7ec1de48d2095dc (diff) |
[elpais] Add extractor
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r-- | youtube_dl/utils.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 8fa4cb67f..01c8c017d 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -751,13 +751,14 @@ class YoutubeDLHandler(compat_urllib_request.HTTPHandler): https_request = http_request https_response = http_response + def unified_strdate(date_str): """Return a string with the date in the format YYYYMMDD""" upload_date = None #Replace commas date_str = date_str.replace(',',' ') # %z (UTC offset) is only supported in python>=3.2 - date_str = re.sub(r' (\+|-)[\d]*$', '', date_str) + date_str = re.sub(r' ?(\+|-)[0-9:]*$', '', date_str) format_expressions = [ '%d %B %Y', '%B %d %Y', @@ -771,11 +772,12 @@ def unified_strdate(date_str): '%Y-%m-%dT%H:%M:%S.%fZ', '%Y-%m-%dT%H:%M:%S.%f0Z', '%Y-%m-%dT%H:%M:%S', + '%Y-%m-%dT%H:%M', ] for expression in format_expressions: try: upload_date = datetime.datetime.strptime(date_str, expression).strftime('%Y%m%d') - except: + except ValueError: pass if upload_date is None: timetuple = email.utils.parsedate_tz(date_str) |