0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-16 01:25:06 +00:00

[drtv] Allow fractional timestamps (Fixes #4059)

This commit is contained in:
Philipp Hagemeister 2014-10-29 20:10:00 +01:00
parent 50c8266ef0
commit 6ad4013d40
3 changed files with 5 additions and 7 deletions

View file

@ -289,6 +289,7 @@ def test_parse_iso8601(self):
self.assertEqual(parse_iso8601('2014-03-23T23:04:26+0100'), 1395612266) self.assertEqual(parse_iso8601('2014-03-23T23:04:26+0100'), 1395612266)
self.assertEqual(parse_iso8601('2014-03-23T22:04:26+0000'), 1395612266) self.assertEqual(parse_iso8601('2014-03-23T22:04:26+0000'), 1395612266)
self.assertEqual(parse_iso8601('2014-03-23T22:04:26Z'), 1395612266) self.assertEqual(parse_iso8601('2014-03-23T22:04:26Z'), 1395612266)
self.assertEqual(parse_iso8601('2014-03-23T22:04:26.1234Z'), 1395612266)
def test_strip_jsonp(self): def test_strip_jsonp(self):
stripped = strip_jsonp('cb ([ {"id":"532cb",\n\n\n"x":\n3}\n]\n);') stripped = strip_jsonp('cb ([ {"id":"532cb",\n\n\n"x":\n3}\n]\n);')

View file

@ -1,7 +1,5 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import re
from .subtitles import SubtitlesInfoExtractor from .subtitles import SubtitlesInfoExtractor
from .common import ExtractorError from .common import ExtractorError
from ..utils import parse_iso8601 from ..utils import parse_iso8601
@ -25,8 +23,7 @@ class DRTVIE(SubtitlesInfoExtractor):
} }
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) video_id = self._match_id(url)
video_id = mobj.group('id')
programcard = self._download_json( programcard = self._download_json(
'http://www.dr.dk/mu/programcard/expanded/%s' % video_id, video_id, 'Downloading video JSON') 'http://www.dr.dk/mu/programcard/expanded/%s' % video_id, video_id, 'Downloading video JSON')
@ -35,7 +32,7 @@ def _real_extract(self, url):
title = data['Title'] title = data['Title']
description = data['Description'] description = data['Description']
timestamp = parse_iso8601(data['CreatedTime'][:-5]) timestamp = parse_iso8601(data['CreatedTime'])
thumbnail = None thumbnail = None
duration = None duration = None

View file

@ -925,7 +925,7 @@ def parse_iso8601(date_str, delimiter='T'):
return None return None
m = re.search( m = re.search(
r'Z$| ?(?P<sign>\+|-)(?P<hours>[0-9]{2}):?(?P<minutes>[0-9]{2})$', r'(\.[0-9]+)?(?:Z$| ?(?P<sign>\+|-)(?P<hours>[0-9]{2}):?(?P<minutes>[0-9]{2})$)',
date_str) date_str)
if not m: if not m:
timezone = datetime.timedelta() timezone = datetime.timedelta()