ccc.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # encoding: utf-8
  2. import re
  3. import json
  4. from .common import InfoExtractor
  5. from ..utils import (
  6. unified_strdate,
  7. )
  8. class ComCarCoffIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?comediansincarsgettingcoffee\.com/(?P<id>[a-z0-9\-]+)/?'
  10. _TESTS = [
  11. {
  12. 'url': 'http://comediansincarsgettingcoffee.com/miranda-sings-happy-thanksgiving-miranda/',
  13. 'info_dict': {
  14. 'id': 'miranda-sings-happy-thanksgiving-miranda',
  15. 'upload_date': '20141127',
  16. 'title': 'Happy Thanksgiving Miranda',
  17. 'description': 'Jerry Seinfeld and his special guest Miranda Sings cruise around town in search of coffee, complaining and apologizing along the way.',
  18. 'thumbnail': 'http://ccc.crackle.com/images/s5e4_thumb.jpg',
  19. },
  20. }
  21. ]
  22. def _real_extract(self, url):
  23. display_id = self._match_id(url)
  24. webpage = self._download_webpage(url, display_id)
  25. full_data = json.loads(self._search_regex(
  26. r'<script type="application/json" id="videoData">(?P<json>.+?)</script>',
  27. webpage, 'json'))
  28. video_id = full_data['activeVideo']['video']
  29. video_data = full_data['videos'][video_id]
  30. return {
  31. 'id': video_id,
  32. 'display_id': display_id,
  33. 'title': video_data['title'],
  34. 'description': video_data['description'],
  35. # XXX: the original datum is a full ISO timestamp... why convert it to a worse format?
  36. 'upload_date': unified_strdate(video_data['pubDate']),
  37. 'thumbnail': video_data['images']['thumb'],
  38. # XXX: what do we do with video_data['images']['poster']?
  39. 'formats': self._extract_m3u8_formats(video_data['mediaUrl'], video_id),
  40. }