([^<>]+)<",
- page, 'view count', flags=re.MULTILINE)
- views = int(view_count_str.replace(',', ''))
+ timestamp = parse_iso8601(self._html_search_regex(
+ r"
([^<>]+)<",
+ page, 'creation time', fatal=False),
+ delimiter=' ', timezone=datetime.timedelta(hours=8))
+ view_count = str_to_int(self._html_search_regex(
+ r"
Views\s*:
\s*
([^<>]+)<",
+ page, 'view count', fatal=False))
return {
'id': video_id,
- 'url': compat_urlparse.urljoin(video_folder, fileName),
+ 'url': video_url,
'title': oembed_obj['title'],
'thumbnail': thumb_url,
'description': self._html_search_meta('description', page),
'creator': oembed_obj['author_name'],
'duration': oembed_obj['duration'],
- 'timestamp': creation_timestamp,
- 'view_count': views,
+ 'timestamp': timestamp,
+ 'view_count': view_count,
}
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 03566d2235..54fa17c388 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -666,26 +666,27 @@ class YoutubeDLHTTPSHandler(compat_urllib_request.HTTPSHandler):
req, **kwargs)
-def parse_iso8601(date_str, delimiter='T'):
+def parse_iso8601(date_str, delimiter='T', timezone=None):
""" Return a UNIX timestamp from the given date """
if date_str is None:
return None
- m = re.search(
- r'(\.[0-9]+)?(?:Z$| ?(?P\+|-)(?P[0-9]{2}):?(?P[0-9]{2})$)',
- date_str)
- if not m:
- timezone = datetime.timedelta()
- else:
- date_str = date_str[:-len(m.group(0))]
- if not m.group('sign'):
+ if timezone is None:
+ m = re.search(
+ r'(\.[0-9]+)?(?:Z$| ?(?P\+|-)(?P[0-9]{2}):?(?P[0-9]{2})$)',
+ date_str)
+ if not m:
timezone = datetime.timedelta()
else:
- sign = 1 if m.group('sign') == '+' else -1
- timezone = datetime.timedelta(
- hours=sign * int(m.group('hours')),
- minutes=sign * int(m.group('minutes')))
+ date_str = date_str[:-len(m.group(0))]
+ if not m.group('sign'):
+ timezone = datetime.timedelta()
+ else:
+ sign = 1 if m.group('sign') == '+' else -1
+ timezone = datetime.timedelta(
+ hours=sign * int(m.group('hours')),
+ minutes=sign * int(m.group('minutes')))
date_format = '%Y-%m-%d{0}%H:%M:%S'.format(delimiter)
dt = datetime.datetime.strptime(date_str, date_format) - timezone
return calendar.timegm(dt.timetuple())