You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.8 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. int_or_none,
  5. parse_iso8601,
  6. )
  7. class CCCIE(InfoExtractor):
  8. IE_NAME = 'media.ccc.de'
  9. _VALID_URL = r'https?://(?:www\.)?media\.ccc\.de/v/(?P<id>[^/?#&]+)'
  10. _TESTS = [{
  11. 'url': 'https://media.ccc.de/v/30C3_-_5443_-_en_-_saal_g_-_201312281830_-_introduction_to_processor_design_-_byterazor#video',
  12. 'md5': '3a1eda8f3a29515d27f5adb967d7e740',
  13. 'info_dict': {
  14. 'id': '1839',
  15. 'ext': 'mp4',
  16. 'title': 'Introduction to Processor Design',
  17. 'description': 'md5:df55f6d073d4ceae55aae6f2fd98a0ac',
  18. 'thumbnail': r're:^https?://.*\.jpg$',
  19. 'upload_date': '20131228',
  20. 'timestamp': 1388188800,
  21. 'duration': 3710,
  22. }
  23. }, {
  24. 'url': 'https://media.ccc.de/v/32c3-7368-shopshifting#download',
  25. 'only_matching': True,
  26. }]
  27. def _real_extract(self, url):
  28. display_id = self._match_id(url)
  29. webpage = self._download_webpage(url, display_id)
  30. event_id = self._search_regex(r"data-id='(\d+)'", webpage, 'event id')
  31. event_data = self._download_json('https://media.ccc.de/public/events/%s' % event_id, event_id)
  32. formats = []
  33. for recording in event_data.get('recordings', []):
  34. recording_url = recording.get('recording_url')
  35. if not recording_url:
  36. continue
  37. language = recording.get('language')
  38. folder = recording.get('folder')
  39. format_id = None
  40. if language:
  41. format_id = language
  42. if folder:
  43. if language:
  44. format_id += '-' + folder
  45. else:
  46. format_id = folder
  47. vcodec = 'h264' if 'h264' in folder else (
  48. 'none' if folder in ('mp3', 'opus') else None
  49. )
  50. formats.append({
  51. 'format_id': format_id,
  52. 'url': recording_url,
  53. 'width': int_or_none(recording.get('width')),
  54. 'height': int_or_none(recording.get('height')),
  55. 'filesize': int_or_none(recording.get('size'), invscale=1024 * 1024),
  56. 'language': language,
  57. 'vcodec': vcodec,
  58. })
  59. self._sort_formats(formats)
  60. return {
  61. 'id': event_id,
  62. 'display_id': display_id,
  63. 'title': event_data['title'],
  64. 'description': event_data.get('description'),
  65. 'thumbnail': event_data.get('thumb_url'),
  66. 'timestamp': parse_iso8601(event_data.get('date')),
  67. 'duration': int_or_none(event_data.get('length')),
  68. 'tags': event_data.get('tags'),
  69. 'formats': formats,
  70. }