]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/airmozilla.py
669556b98fe2b4dd1f3bd041beb27a5ec48179df
[yt-dlp.git] / yt_dlp / extractor / airmozilla.py
1 import re
2
3 from .common import InfoExtractor
4 from ..utils import (
5 int_or_none,
6 parse_duration,
7 parse_iso8601,
8 )
9
10
11 class AirMozillaIE(InfoExtractor):
12 _VALID_URL = r'https?://air\.mozilla\.org/(?P<id>[0-9a-z-]+)/?'
13 _TEST = {
14 'url': 'https://air.mozilla.org/privacy-lab-a-meetup-for-privacy-minded-people-in-san-francisco/',
15 'md5': '8d02f53ee39cf006009180e21df1f3ba',
16 'info_dict': {
17 'id': '6x4q2w',
18 'ext': 'mp4',
19 'title': 'Privacy Lab - a meetup for privacy minded people in San Francisco',
20 'thumbnail': r're:https?://.*/poster\.jpg',
21 'description': 'Brings together privacy professionals and others interested in privacy at for-profits, non-profits, and NGOs in an effort to contribute to the state of the ecosystem...',
22 'timestamp': 1422487800,
23 'upload_date': '20150128',
24 'location': 'SFO Commons',
25 'duration': 3780,
26 'view_count': int,
27 'categories': ['Main', 'Privacy'],
28 }
29 }
30
31 def _real_extract(self, url):
32 display_id = self._match_id(url)
33 webpage = self._download_webpage(url, display_id)
34 video_id = self._html_search_regex(r'//vid\.ly/(.*?)/embed', webpage, 'id')
35
36 embed_script = self._download_webpage('https://vid.ly/{0}/embed'.format(video_id), video_id)
37 jwconfig = self._parse_json(self._search_regex(
38 r'initCallback\((.*)\);', embed_script, 'metadata'), video_id)['config']
39
40 info_dict = self._parse_jwplayer_data(jwconfig, video_id)
41 view_count = int_or_none(self._html_search_regex(
42 r'Views since archived: ([0-9]+)',
43 webpage, 'view count', fatal=False))
44 timestamp = parse_iso8601(self._html_search_regex(
45 r'<time datetime="(.*?)"', webpage, 'timestamp', fatal=False))
46 duration = parse_duration(self._search_regex(
47 r'Duration:\s*(\d+\s*hours?\s*\d+\s*minutes?)',
48 webpage, 'duration', fatal=False))
49
50 info_dict.update({
51 'id': video_id,
52 'title': self._og_search_title(webpage),
53 'url': self._og_search_url(webpage),
54 'display_id': display_id,
55 'description': self._og_search_description(webpage),
56 'timestamp': timestamp,
57 'location': self._html_search_regex(r'Location: (.*)', webpage, 'location', default=None),
58 'duration': duration,
59 'view_count': view_count,
60 'categories': re.findall(r'<a href=".*?" class="channel">(.*?)</a>', webpage),
61 })
62
63 return info_dict