summary refs log tree commit diff
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2014-03-02 19:59:34 +0700
committerSergey M․ <dstftw@gmail.com>2014-03-02 19:59:34 +0700
commitfb8b8fdd628ef8f88f4e596c197f47c9fb42d93f (patch)
treec6f1f833a2ee1f842719489b5d3dd1f12668b97a
parent5a0b26252ef50e640e2b85c6adeec1dd1d6ed899 (diff)
downloadyoutube-dl-fb8b8fdd628ef8f88f4e596c197f47c9fb42d93f.tar.gz
youtube-dl-fb8b8fdd628ef8f88f4e596c197f47c9fb42d93f.tar.xz
youtube-dl-fb8b8fdd628ef8f88f4e596c197f47c9fb42d93f.zip
[tvigle] Add support for tvigle.ru
-rw-r--r--youtube_dl/extractor/__init__.py1
-rw-r--r--youtube_dl/extractor/tvigle.py69
2 files changed, 70 insertions, 0 deletions
diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py
index 776d076eb..5a6635f8d 100644
--- a/youtube_dl/extractor/__init__.py
+++ b/youtube_dl/extractor/__init__.py
@@ -238,6 +238,7 @@ from .tube8 import Tube8IE
 from .tudou import TudouIE
 from .tumblr import TumblrIE
 from .tutv import TutvIE
+from .tvigle import TvigleIE
 from .tvp import TvpIE
 from .unistra import UnistraIE
 from .ustream import UstreamIE, UstreamChannelIE
diff --git a/youtube_dl/extractor/tvigle.py b/youtube_dl/extractor/tvigle.py
new file mode 100644
index 000000000..eb826613d
--- /dev/null
+++ b/youtube_dl/extractor/tvigle.py
@@ -0,0 +1,69 @@
+# encoding: utf-8
+from __future__ import unicode_literals
+
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+    unified_strdate,
+    clean_html,
+)
+
+
+class TvigleIE(InfoExtractor):
+    IE_NAME = 'tvigle'
+    IE_DESC = 'Интернет-телевидение Tvigle.ru'
+    _VALID_URL = r'http://(?:www\.)?tvigle\.ru/category/.+?video=(?P<id>\d+)'
+
+    _TEST = {
+        'url': 'http://www.tvigle.ru/category/cinema/1608/?video=503081',
+        'md5': '09afba4616666249f087efc6dcf83cb3',
+        'info_dict': {
+            'id': '503081',
+            'ext': 'flv',
+            'title': 'Брат 2 ',
+            'description': 'md5:f5a42970f50648cee3d7ad740f3ae769',
+            'upload_date': '20110919',
+        }
+    }
+
+    def _real_extract(self, url):
+        mobj = re.match(self._VALID_URL, url)
+        video_id = mobj.group('id')
+
+        video_data = self._download_xml(
+            'http://www.tvigle.ru/xml/single.php?obj=%s' % video_id, video_id, 'Downloading video XML')
+
+        video = video_data.find('./video')
+
+        title = video.get('name')
+        description = video.get('anons')
+        if description:
+            description = clean_html(description)
+        thumbnail = video_data.get('img')
+        upload_date = unified_strdate(video.get('date'))
+        like_count = video.get('vtp')
+
+        formats = []
+        for num, (format_id, format_note) in enumerate([['low_file', 'SQ'], ['file', 'HQ'], ['hd', 'HD 720']]):
+            video_url = video.get(format_id)
+            if not video_url:
+                continue
+            formats.append({
+                'url': video_url,
+                'format_id': format_id,
+                'format_note': format_note,
+                'quality': num,
+            })
+
+        self._sort_formats(formats)
+
+        return {
+            'id': video_id,
+            'title': title,
+            'description': description,
+            'thumbnail': thumbnail,
+            'upload_date': upload_date,
+            'like_count': like_count,
+            'formats': formats,
+        }
\ No newline at end of file