Added rules for legacy videos that don't use m3u8 files

This commit is contained in:
Martin Hartkorn 2018-06-08 12:08:45 +02:00
parent 29b076ad6c
commit f2c7a7f1b1

View File

@ -4,7 +4,7 @@ from __future__ import unicode_literals
import re
from .once import OnceIE
from .common import InfoExtractor
from ..compat import (
compat_urllib_parse_unquote,
)
@ -15,19 +15,31 @@ from ..utils import (
)
class PietsmietIE(OnceIE):
class PietsmietIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?pietsmiet\.de/gallery/(categories|playlists)/[\w-]+/(?P<id>\d+)-.*/?'
_TEST = {
'url': 'http://www.pietsmiet.de/gallery/categories/8-frag-pietsmiet/29844-fps-912',
'info_dict': {
'id': '29844',
'ext': 'mp4',
'title': 'Was würdet ihr die Maus fragen? 🎮 Frag PietSmiet #912',
},
'params': {
'skip_download': True, # m3u8 downloads
},
}
_TESTS = [
{
'url': 'https://www.pietsmiet.de/gallery/categories/8-frag-pietsmiet/29844-fps-912',
'info_dict': {
'id': '29844',
'ext': 'mp4',
'title': 'Was würdet ihr die Maus fragen? 🎮 Frag PietSmiet #912',
},
'params': {
'skip_download': True, # m3u8 downloads
}
}, {
'url': 'https://www.pietsmiet.de/gallery/playlists/646-metal-gear-solid-1/19804-metal-gear-solid-1-sniper-wolf-rematch',
'info_dict': {
'id': '19804',
'ext': 'mp4',
'title': 'SNIPER WOLF REMATCH 🎮 Metal Gear Solid #9'
},
'params': {
'skip_download': True, # m3u8 downloads
}
}
]
def _real_extract(self, url):
page_id = self._match_id(url)
@ -39,17 +51,16 @@ class PietsmietIE(OnceIE):
formats = []
m3u8_manifest_url = data_video['sources'][0]['file']
m3u8_formats = self._extract_m3u8_formats(
m3u8_manifest_url, page_id, 'mp4', 'm3u8_native',
m3u8_id='hls')
m3u8_manifest_urls = filter(lambda x: x['file'].endswith('m3u8'), data_video['sources'])
for f in m3u8_manifest_urls:
m3u8_formats = self._extract_m3u8_formats(
f['file'], page_id, 'mp4', 'm3u8_native', m3u8_id='hls')
formats.extend(m3u8_formats)
formats.extend(m3u8_formats)
if len(data_video['sources']) > 1:
http_video = data_video['sources'][1]
label = http_video.get('label')
mp4_urls = filter(lambda x: not x['file'].endswith('m3u8'), data_video['sources'])
for m in mp4_urls:
label = m.get('label')
format_height = 0
if label:
@ -64,16 +75,16 @@ class PietsmietIE(OnceIE):
formats.append({
'format_id': 'http-{0}'.format(label),
'url': "https:{0}".format(http_video['file']),
'ext': http_video.get('type'),
'url': "https:{0}".format(m['file']),
'ext': m.get('type'),
'width': int_or_none(format_width),
'height': format_height,
'fps': 30.0,
})
else:
formats.append({
'url': "https:{0}".format(http_video['file']),
'ext': http_video.get('type'),
'url': "https:{0}".format(m['file']),
'ext': m.get('type'),
'fps': 30.0,
})