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.

60 lines
2.3 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. class TMZIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?tmz\.com/videos/(?P<id>[^/]+)/?'
  6. _TEST = {
  7. 'url': 'http://www.tmz.com/videos/0_okj015ty/',
  8. 'md5': '791204e3bf790b1426cb2db0706184c0',
  9. 'info_dict': {
  10. 'id': '0_okj015ty',
  11. 'url': 'http://tmz.vo.llnwd.net/o28/2014-03/13/0_okj015ty_0_rt8ro3si_2.mp4',
  12. 'ext': 'mp4',
  13. 'title': 'Kim Kardashian\'s Boobs Unlock a Mystery!',
  14. 'description': 'Did Kim Kardasain try to one-up Khloe by one-upping Kylie??? Or is she just showing off her amazing boobs?',
  15. 'thumbnail': r're:http://cdnbakmi\.kaltura\.com/.*thumbnail.*',
  16. }
  17. }
  18. def _real_extract(self, url):
  19. video_id = self._match_id(url)
  20. webpage = self._download_webpage(url, video_id)
  21. return {
  22. 'id': video_id,
  23. 'url': self._html_search_meta('VideoURL', webpage, fatal=True),
  24. 'title': self._og_search_title(webpage),
  25. 'description': self._og_search_description(webpage),
  26. 'thumbnail': self._html_search_meta('ThumbURL', webpage),
  27. }
  28. class TMZArticleIE(InfoExtractor):
  29. _VALID_URL = r'https?://(?:www\.)?tmz\.com/\d{4}/\d{2}/\d{2}/(?P<id>[^/]+)/?'
  30. _TEST = {
  31. 'url': 'http://www.tmz.com/2015/04/19/bobby-brown-bobbi-kristina-awake-video-concert',
  32. 'md5': 'e482a414a38db73087450e3a6ce69d00',
  33. 'info_dict': {
  34. 'id': '0_6snoelag',
  35. 'ext': 'mp4',
  36. 'title': 'Bobby Brown Tells Crowd ... Bobbi Kristina is Awake',
  37. 'description': 'Bobby Brown stunned his audience during a concert Saturday night, when he told the crowd, "Bobbi is awake. She\'s watching me."',
  38. }
  39. }
  40. def _real_extract(self, url):
  41. video_id = self._match_id(url)
  42. webpage = self._download_webpage(url, video_id)
  43. embedded_video_info_str = self._html_search_regex(
  44. r'tmzVideoEmbedV2\("([^)]+)"\);', webpage, 'embedded video info')
  45. embedded_video_info = self._parse_json(
  46. embedded_video_info_str, video_id,
  47. transform_source=lambda s: s.replace('\\', ''))
  48. return self.url_result(
  49. 'http://www.tmz.com/videos/%s/' % embedded_video_info['id'])