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.

46 lines
2.0 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. video_id = self._og_search_property('video', webpage, 'Video id').split('=')[1]
  23. info_url = "http://www.traileraddict.com/fvar.php?tid=%s" %(str(video_id))
  24. info_webpage = self._download_webpage(info_url, video_id , "Downloading the info webpage")
  25. final_url = self._search_regex(r'&fileurl=(.+)',
  26. info_webpage, 'Download url').replace('%3F','?')
  27. thumbnail_url = self._search_regex(r'&image=(.+?)&',
  28. info_webpage, 'thumbnail url')
  29. ext = final_url.split('.')[-1].split('?')[0]
  30. return [{
  31. 'id' : video_id,
  32. 'url' : final_url,
  33. 'ext' : ext,
  34. 'title' : title,
  35. 'thumbnail' : thumbnail_url,
  36. 'description' : self._og_search_description(webpage),
  37. 'view_count' : view_count,
  38. }]