]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/twitcasting.py
debian/{compat,control}: Update to debhelper compatibility level 12.
[youtubedl] / youtube_dl / extractor / twitcasting.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6 import re
7
8
9 class TwitCastingIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:[^/]+\.)?twitcasting\.tv/(?P<uploader_id>[^/]+)/movie/(?P<id>\d+)'
11 _TEST = {
12 'url': 'https://twitcasting.tv/ivetesangalo/movie/2357609',
13 'md5': '745243cad58c4681dc752490f7540d7f',
14 'info_dict': {
15 'id': '2357609',
16 'ext': 'mp4',
17 'title': 'Recorded Live #2357609',
18 'uploader_id': 'ivetesangalo',
19 'description': "Moi! I'm live on TwitCasting from my iPhone.",
20 'thumbnail': r're:^https?://.*\.jpg$',
21 },
22 'params': {
23 'skip_download': True,
24 },
25 }
26
27 def _real_extract(self, url):
28 mobj = re.match(self._VALID_URL, url)
29 video_id = mobj.group('id')
30 uploader_id = mobj.group('uploader_id')
31
32 webpage = self._download_webpage(url, video_id)
33
34 title = self._html_search_regex(
35 r'(?s)<[^>]+id=["\']movietitle[^>]+>(.+?)</',
36 webpage, 'title', default=None) or self._html_search_meta(
37 'twitter:title', webpage, fatal=True)
38
39 m3u8_url = self._search_regex(
40 (r'data-movie-url=(["\'])(?P<url>(?:(?!\1).)+)\1',
41 r'(["\'])(?P<url>http.+?\.m3u8.*?)\1'),
42 webpage, 'm3u8 url', group='url')
43
44 formats = self._extract_m3u8_formats(
45 m3u8_url, video_id, ext='mp4', entry_protocol='m3u8_native',
46 m3u8_id='hls')
47
48 thumbnail = self._og_search_thumbnail(webpage)
49 description = self._og_search_description(
50 webpage, default=None) or self._html_search_meta(
51 'twitter:description', webpage)
52
53 return {
54 'id': video_id,
55 'title': title,
56 'description': description,
57 'thumbnail': thumbnail,
58 'uploader_id': uploader_id,
59 'formats': formats,
60 }