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
1.7 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import ExtractorError
  5. class TinyPicIE(InfoExtractor):
  6. IE_NAME = 'tinypic'
  7. IE_DESC = 'tinypic.com videos'
  8. _VALID_URL = r'http://tinypic\.com/player\.php\?v=(?P<id>[^&]+)&s=\d+'
  9. _TEST = {
  10. 'url': 'http://tinypic.com/player.php?v=6xw7tc%3E&s=5#.UtqZmbRFCM8',
  11. 'md5': '609b74432465364e72727ebc6203f044',
  12. 'info_dict': {
  13. 'id': '6xw7tc',
  14. 'ext': 'flv',
  15. 'title': 'shadow phenomenon weird',
  16. }
  17. }
  18. def _real_extract(self, url):
  19. mobj = re.match(self._VALID_URL, url)
  20. video_id = mobj.group('id')
  21. webpage = self._download_webpage(url, video_id, 'Downloading page')
  22. mobj = re.search(r'(?m)fo\.addVariable\("file",\s"(?P<fileid>[\da-z]+)"\);\n'
  23. '\s+fo\.addVariable\("s",\s"(?P<serverid>\d+)"\);', webpage)
  24. if mobj is None:
  25. raise ExtractorError('Video %s does not exist' % video_id, expected=True)
  26. file_id = mobj.group('fileid')
  27. server_id = mobj.group('serverid')
  28. KEYWORDS_SUFFIX = ', Video, images, photos, videos, myspace, ebay, video hosting, photo hosting'
  29. keywords = self._html_search_meta('keywords', webpage, 'title')
  30. title = keywords[:-len(KEYWORDS_SUFFIX)] if keywords.endswith(KEYWORDS_SUFFIX) else ''
  31. video_url = 'http://v%s.tinypic.com/%s.flv' % (server_id, file_id)
  32. thumbnail = 'http://v%s.tinypic.com/%s_th.jpg' % (server_id, file_id)
  33. return {
  34. 'id': file_id,
  35. 'url': video_url,
  36. 'thumbnail': thumbnail,
  37. 'title': title
  38. }