]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/zype.py
d/rules: Drop makefile mangling
[youtubedl] / youtube_dl / extractor / zype.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7
8
9 class ZypeIE(InfoExtractor):
10 _VALID_URL = r'https?://player\.zype\.com/embed/(?P<id>[\da-fA-F]+)\.js\?.*?api_key=[^&]+'
11 _TEST = {
12 'url': 'https://player.zype.com/embed/5b400b834b32992a310622b9.js?api_key=jZ9GUhRmxcPvX7M3SlfejB6Hle9jyHTdk2jVxG7wOHPLODgncEKVdPYBhuz9iWXQ&autoplay=false&controls=true&da=false',
13 'md5': 'eaee31d474c76a955bdaba02a505c595',
14 'info_dict': {
15 'id': '5b400b834b32992a310622b9',
16 'ext': 'mp4',
17 'title': 'Smoky Barbecue Favorites',
18 'thumbnail': r're:^https?://.*\.jpe?g',
19 },
20 }
21
22 @staticmethod
23 def _extract_urls(webpage):
24 return [
25 mobj.group('url')
26 for mobj in re.finditer(
27 r'<script[^>]+\bsrc=(["\'])(?P<url>(?:https?:)?//player\.zype\.com/embed/[\da-fA-F]+\.js\?.*?api_key=.+?)\1',
28 webpage)]
29
30 def _real_extract(self, url):
31 video_id = self._match_id(url)
32
33 webpage = self._download_webpage(url, video_id)
34
35 title = self._search_regex(
36 r'video_title\s*[:=]\s*(["\'])(?P<value>(?:(?!\1).)+)\1', webpage,
37 'title', group='value')
38
39 m3u8_url = self._search_regex(
40 r'(["\'])(?P<url>(?:(?!\1).)+\.m3u8(?:(?!\1).)*)\1', webpage,
41 'm3u8 url', group='url')
42
43 formats = self._extract_m3u8_formats(
44 m3u8_url, video_id, 'mp4', entry_protocol='m3u8_native',
45 m3u8_id='hls')
46 self._sort_formats(formats)
47
48 thumbnail = self._search_regex(
49 r'poster\s*[:=]\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, 'thumbnail',
50 default=False, group='url')
51
52 return {
53 'id': video_id,
54 'title': title,
55 'thumbnail': thumbnail,
56 'formats': formats,
57 }