1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-26 02:14:32 +01:00

[ruv] Fix extractor

This commit is contained in:
Einar Jonsson 2019-01-18 17:24:13 +00:00
parent 79fec976b0
commit d2d2df03df

View File

@ -1,52 +1,66 @@
# coding: utf-8
from __future__ import unicode_literals
import re
from .common import InfoExtractor
from ..utils import (
determine_ext,
unified_timestamp,
int_or_none,
)
class RuvIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?ruv\.is/(?:sarpurinn/[^/]+|node)/(?P<id>[^/]+(?:/\d+)?)'
_VALID_URL = r'https?://(?:www\.)?ruv\.is/(?:spila/[^/]+|node)/(?P<id>[^/]+(?:/\d+)?)'
_TESTS = [{
# m3u8
'url': 'http://ruv.is/sarpurinn/ruv-aukaras/fh-valur/20170516',
'md5': '66347652f4e13e71936817102acc1724',
'url': 'http://www.ruv.is/spila/ruv/ferdastiklur/20190106',
'md5': '26ba808bf9690f6f87c1469f6b6db8ab',
'info_dict': {
'id': '1144499',
'display_id': 'fh-valur/20170516',
'id': '1338199',
'display_id': 'ferdastiklur/20190106',
'ext': 'mp4',
'title': 'FH - Valur',
'description': 'Bein útsending frá 3. leik FH og Vals í úrslitum Olísdeildar karla í handbolta.',
'timestamp': 1494963600,
'upload_date': '20170516',
'title': 'Ferðastiklur',
'episode_number': 1,
'description': 'md5:775b811c7cd3d7bf1509d5a4ff5edbcb',
'timestamp': 1546803900,
'upload_date': '20190106',
},
}, {
# m3u8
# No episode number
'url': 'http://www.ruv.is/spila/ruv/vedur/20190117',
'md5': '41cee6ef9c62955bba90b60f78a7de34',
'info_dict': {
'id': '1341887',
'display_id': 'vedur/20190117',
'ext': 'mp4',
'title': 'Veður',
'timestamp': 1547753400,
'upload_date': '20190117',
},
}, {
# mp3
'url': 'http://ruv.is/sarpurinn/ras-2/morgunutvarpid/20170619',
'md5': '395ea250c8a13e5fdb39d4670ef85378',
'url': 'http://www.ruv.is/spila/ras-1/i-ljosi-sogunnar/20190111',
'md5': 'dbee43b6d480499421a37f65910d81b4',
'info_dict': {
'id': '1153630',
'display_id': 'morgunutvarpid/20170619',
'id': '1351187',
'display_id': 'i-ljosi-sogunnar/20190111',
'ext': 'mp3',
'title': 'Morgunútvarpið',
'description': 'md5:a4cf1202c0a1645ca096b06525915418',
'timestamp': 1497855000,
'upload_date': '20170619',
'title': 'Í ljósi sögunnar',
'description': 'md5:f79146f1737e21046b4f497ffd8c01b5',
'timestamp': 1547197500,
'upload_date': '20190111',
},
}, {
'url': 'http://ruv.is/sarpurinn/ruv/frettir/20170614',
'url': 'http://www.ruv.is/spila/ruv/frettir/20190117',
'only_matching': True,
}, {
'url': 'http://www.ruv.is/node/1151854',
'url': 'http://www.ruv.is/node/1341894',
'only_matching': True,
}, {
'url': 'http://ruv.is/sarpurinn/klippa/secret-soltice-hefst-a-morgun',
'only_matching': True,
}, {
'url': 'http://ruv.is/sarpurinn/ras-1/morgunvaktin/20170619',
'url': 'http://www.ruv.is/spila/ras-1/lestin/20190117',
'only_matching': True,
}]
@ -57,10 +71,22 @@ class RuvIE(InfoExtractor):
title = self._og_search_title(webpage)
FIELD_RE = r'video\.%s\s*=\s*(["\'])(?P<url>(?:(?!\1).)+)\1'
episode = int_or_none(self._html_search_regex(
r'<h3[^>].+\((\d+)+\s*\w{2}\s*\d+\)',
webpage,
'episode number',
default=None,
))
FIELD_RE = r'sources{0}\[(?:.*src{0}(["\'])(?P<url>(?:(?!\1).)+)\1.*\])'
media_url = self._html_search_regex(
FIELD_RE % 'src', webpage, 'video URL', group='url')
FIELD_RE.format('\\s*:\\s*'),
webpage,
'video URL',
group='url',
flags=re.DOTALL,
)
video_id = self._search_regex(
r'<link\b[^>]+\bhref=["\']https?://www\.ruv\.is/node/(\d+)',
@ -98,4 +124,5 @@ class RuvIE(InfoExtractor):
'thumbnail': thumbnail,
'timestamp': timestamp,
'formats': formats,
'episode_number': episode,
}