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.

52 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|clip)/(?P<movie>.+?)/(?P<trailer_name>.+)'
  5. _TEST = {
  6. u'url': u'http://www.traileraddict.com/trailer/prince-avalanche/trailer',
  7. u'file': u'76184.mp4',
  8. u'md5': u'57e39dbcf4142ceb8e1f242ff423fd71',
  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. name = mobj.group('movie') + '/' + mobj.group('trailer_name')
  17. webpage = self._download_webpage(url, name)
  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. # Presence of (no)watchplus function indicates HD quality is available
  24. if re.search(r'function (no)?watchplus()', webpage):
  25. fvar = "fvarhd"
  26. else:
  27. fvar = "fvar"
  28. info_url = "http://www.traileraddict.com/%s.php?tid=%s" % (fvar, str(video_id))
  29. info_webpage = self._download_webpage(info_url, video_id , "Downloading the info webpage")
  30. final_url = self._search_regex(r'&fileurl=(.+)',
  31. info_webpage, 'Download url').replace('%3F','?')
  32. thumbnail_url = self._search_regex(r'&image=(.+?)&',
  33. info_webpage, 'thumbnail url')
  34. ext = final_url.split('.')[-1].split('?')[0]
  35. return [{
  36. 'id' : video_id,
  37. 'url' : final_url,
  38. 'ext' : ext,
  39. 'title' : title,
  40. 'thumbnail' : thumbnail_url,
  41. 'description' : self._og_search_description(webpage),
  42. 'view_count' : view_count,
  43. }]