logo

youtube-dl

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

cmt.py (2173B)


  1. from __future__ import unicode_literals
  2. from .mtv import MTVIE
  3. class CMTIE(MTVIE):
  4. IE_NAME = 'cmt.com'
  5. _VALID_URL = r'https?://(?:www\.)?cmt\.com/(?:videos|shows|(?:full-)?episodes|video-clips)/(?P<id>[^/]+)'
  6. _TESTS = [{
  7. 'url': 'http://www.cmt.com/videos/garth-brooks/989124/the-call-featuring-trisha-yearwood.jhtml#artist=30061',
  8. 'md5': 'e6b7ef3c4c45bbfae88061799bbba6c2',
  9. 'info_dict': {
  10. 'id': '989124',
  11. 'ext': 'mp4',
  12. 'title': 'Garth Brooks - "The Call (featuring Trisha Yearwood)"',
  13. 'description': 'Blame It All On My Roots',
  14. },
  15. 'skip': 'Video not available',
  16. }, {
  17. 'url': 'http://www.cmt.com/videos/misc/1504699/still-the-king-ep-109-in-3-minutes.jhtml#id=1739908',
  18. 'md5': 'e61a801ca4a183a466c08bd98dccbb1c',
  19. 'info_dict': {
  20. 'id': '1504699',
  21. 'ext': 'mp4',
  22. 'title': 'Still The King Ep. 109 in 3 Minutes',
  23. 'description': 'Relive or catch up with Still The King by watching this recap of season 1, episode 9.',
  24. 'timestamp': 1469421000.0,
  25. 'upload_date': '20160725',
  26. },
  27. }, {
  28. 'url': 'http://www.cmt.com/shows/party-down-south/party-down-south-ep-407-gone-girl/1738172/playlist/#id=1738172',
  29. 'only_matching': True,
  30. }, {
  31. 'url': 'http://www.cmt.com/full-episodes/537qb3/nashville-the-wayfaring-stranger-season-5-ep-501',
  32. 'only_matching': True,
  33. }, {
  34. 'url': 'http://www.cmt.com/video-clips/t9e4ci/nashville-juliette-in-2-minutes',
  35. 'only_matching': True,
  36. }]
  37. def _extract_mgid(self, webpage):
  38. mgid = self._search_regex(
  39. r'MTVN\.VIDEO\.contentUri\s*=\s*([\'"])(?P<mgid>.+?)\1',
  40. webpage, 'mgid', group='mgid', default=None)
  41. if not mgid:
  42. mgid = self._extract_triforce_mgid(webpage)
  43. return mgid
  44. def _real_extract(self, url):
  45. video_id = self._match_id(url)
  46. webpage = self._download_webpage(url, video_id)
  47. mgid = self._extract_mgid(webpage)
  48. return self.url_result('http://media.mtvnservices.com/embed/%s' % mgid)