aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/tinypic.py
diff options
context:
space:
mode:
authorSergey M. <dstftw@gmail.com>2014-02-03 01:20:03 +0700
committerSergey M. <dstftw@gmail.com>2014-02-03 01:20:03 +0700
commitdbe80ca7adabb23f91fbd1aaaf1151af3942eb26 (patch)
tree42206106a56f7e068f7a09227baf3be76823b85e /youtube_dl/extractor/tinypic.py
parentb58e3c8918ffde93af184fab444ee96c435353b0 (diff)
[tinypic] Add support for tinypic.com videos (Closes #2210)
Diffstat (limited to 'youtube_dl/extractor/tinypic.py')
-rw-r--r--youtube_dl/extractor/tinypic.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/youtube_dl/extractor/tinypic.py b/youtube_dl/extractor/tinypic.py
new file mode 100644
index 000000000..2246d27b2
--- /dev/null
+++ b/youtube_dl/extractor/tinypic.py
@@ -0,0 +1,50 @@
+from __future__ import unicode_literals
+
+import re
+
+from .common import InfoExtractor
+from youtube_dl.utils import ExtractorError
+
+
+class TinyPicIE(InfoExtractor):
+ IE_NAME = 'tinypic'
+ IE_DESC = 'tinypic.com videos'
+ _VALID_URL = r'http://tinypic\.com/player\.php\?v=(?P<id>[^&]+)&s=\d+'
+
+ _TEST = {
+ 'url': 'http://tinypic.com/player.php?v=6xw7tc%3E&s=5#.UtqZmbRFCM8',
+ 'md5': '609b74432465364e72727ebc6203f044',
+ 'info_dict': {
+ 'id': '6xw7tc',
+ 'ext': 'flv',
+ 'title': 'shadow phenomenon weird',
+ }
+ }
+
+ def _real_extract(self, url):
+ mobj = re.match(self._VALID_URL, url)
+ video_id = mobj.group('id')
+
+ webpage = self._download_webpage(url, video_id, 'Downloading page')
+
+ mobj = re.search(r'(?m)fo\.addVariable\("file",\s"(?P<fileid>[\da-z]+)"\);\n'
+ '\s+fo\.addVariable\("s",\s"(?P<serverid>\d+)"\);', webpage)
+ if mobj is None:
+ raise ExtractorError('Video %s does not exist' % video_id, expected=True)
+
+ file_id = mobj.group('fileid')
+ server_id = mobj.group('serverid')
+
+ KEYWORDS_SUFFIX = ', Video, images, photos, videos, myspace, ebay, video hosting, photo hosting'
+ keywords = self._html_search_meta('keywords', webpage, 'title')
+ title = keywords[:-len(KEYWORDS_SUFFIX)] if keywords.endswith(KEYWORDS_SUFFIX) else ''
+
+ video_url = 'http://v%s.tinypic.com/%s.flv' % (server_id, file_id)
+ thumbnail = 'http://v%s.tinypic.com/%s_th.jpg' % (server_id, file_id)
+
+ return {
+ 'id': file_id,
+ 'url': video_url,
+ 'thumbnail': thumbnail,
+ 'title': title
+ } \ No newline at end of file