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.

49 lines
2.2 KiB

  1. import re
  2. from .common import InfoExtractor
  3. class TrailerAddictIE(InfoExtractor):
  4. _VALID_URL = r'(?:http://)?(?:www\.)?traileraddict\.com/trailer/([^/]+)/(?:trailer|feature-trailer)'
  5. _TEST = {
  6. u'url': u'http://www.traileraddict.com/trailer/prince-avalanche/trailer',
  7. u'file': u'76184.mp4',
  8. u'md5': u'41365557f3c8c397d091da510e73ceb4',
  9. u'info_dict': {
  10. u"title": u"Prince Avalanche Trailer",
  11. u"description": u"Trailer for Prince Avalanche.Two highway road workers spend the summer of 1988 away from their city lives. The isolated landscape becomes a place of misadventure as the men find themselves at odds with each other and the women they left behind."
  12. }
  13. }
  14. def _real_extract(self, url):
  15. mobj = re.match(self._VALID_URL, url)
  16. video_id = mobj.group(1)
  17. webpage = self._download_webpage(url, video_id)
  18. title = self._search_regex(r'<title>(.+?)</title>',
  19. webpage, 'video title').replace(' - Trailer Addict','')
  20. view_count = self._search_regex(r'Views: (.+?)<br />',
  21. webpage, 'Views Count')
  22. description = self._search_regex(r'<meta property="og:description" content="(.+?)" />',
  23. webpage, 'video description')
  24. video_id = self._search_regex(r'<meta property="og:video" content="(.+?)" />',
  25. webpage, 'Video id').split('=')[1]
  26. info_url = "http://www.traileraddict.com/fvar.php?tid=%s" %(str(video_id))
  27. info_webpage = self._download_webpage(info_url, video_id , "Downloading the info webpage")
  28. final_url = self._search_regex(r'&fileurl=(.+)',
  29. info_webpage, 'Download url').replace('%3F','?')
  30. thumbnail_url = self._search_regex(r'&image=(.+?)&',
  31. info_webpage, 'thumbnail url')
  32. ext = final_url.split('.')[-1].split('?')[0]
  33. return [{
  34. 'id' : video_id,
  35. 'url' : final_url,
  36. 'ext' : ext,
  37. 'title' : title,
  38. 'thumbnail' : thumbnail_url,
  39. 'description' : description,
  40. 'view_count' : view_count,
  41. }]