logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

airmozilla.py (2697B)


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