1 from __future__ import unicode_literals
5 from .common import InfoExtractor
6 from ..utils import ExtractorError
9 class TinyPicIE(InfoExtractor):
11 IE_DESC = 'tinypic.com videos'
12 _VALID_URL = r'https?://(?:.+?\.)?tinypic\.com/player\.php\?v=(?P<id>[^&]+)&s=\d+'
16 'url': 'http://tinypic.com/player.php?v=6xw7tc%3E&s=5#.UtqZmbRFCM8',
17 'md5': '609b74432465364e72727ebc6203f044',
21 'title': 'shadow phenomenon weird',
25 'url': 'http://de.tinypic.com/player.php?v=dy90yh&s=8',
26 'only_matching': True,
30 def _real_extract(self, url):
31 mobj = re.match(self._VALID_URL, url)
32 video_id = mobj.group('id')
34 webpage = self._download_webpage(url, video_id, 'Downloading page')
36 mobj = re.search(r'(?m)fo\.addVariable\("file",\s"(?P<fileid>[\da-z]+)"\);\n'
37 r'\s+fo\.addVariable\("s",\s"(?P<serverid>\d+)"\);', webpage)
39 raise ExtractorError('Video %s does not exist' % video_id, expected=True)
41 file_id = mobj.group('fileid')
42 server_id = mobj.group('serverid')
44 KEYWORDS_SUFFIX = ', Video, images, photos, videos, myspace, ebay, video hosting, photo hosting'
45 keywords = self._html_search_meta('keywords', webpage, 'title')
46 title = keywords[:-len(KEYWORDS_SUFFIX)] if keywords.endswith(KEYWORDS_SUFFIX) else ''
48 video_url = 'http://v%s.tinypic.com/%s.flv' % (server_id, file_id)
49 thumbnail = 'http://v%s.tinypic.com/%s_th.jpg' % (server_id, file_id)
54 'thumbnail': thumbnail,