summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2013-10-15 01:33:20 +0200
committerPhilipp Hagemeister <phihag@phihag.de>2013-10-15 01:33:20 +0200
commit7cf67fbe29684f9681aa591a6eaeb43a5c6b5cb2 (patch)
tree8074ce190729542a4ad3e0add60aa57f406a27b4
parent3ddf1a6d01f73ca5a1c8320a5e0f51b9ab976e8c (diff)
downloadyoutube-dl-7cf67fbe29684f9681aa591a6eaeb43a5c6b5cb2.tar.gz
youtube-dl-7cf67fbe29684f9681aa591a6eaeb43a5c6b5cb2.tar.xz
youtube-dl-7cf67fbe29684f9681aa591a6eaeb43a5c6b5cb2.zip
[sztvhu] Simplify
-rw-r--r--youtube_dl/extractor/sztvhu.py45
1 files changed, 24 insertions, 21 deletions
diff --git a/youtube_dl/extractor/sztvhu.py b/youtube_dl/extractor/sztvhu.py
index 486f93d26..cd3e203e6 100644
--- a/youtube_dl/extractor/sztvhu.py
+++ b/youtube_dl/extractor/sztvhu.py
@@ -5,37 +5,40 @@ import re
 from .common import InfoExtractor
 from ..utils import determine_ext
 
+
 class SztvHuIE(InfoExtractor):
-    _VALID_URL = r'(?:http://)?(?:(?:www\.)?sztv\.hu|www\.tvszombathely\.hu)/([^/]+)/(?P<name>.+)'
+    _VALID_URL = r'(?:http://)?(?:(?:www\.)?sztv\.hu|www\.tvszombathely\.hu)/(?:[^/]+)/.+-(?P<id>[0-9]+)'
     _TEST = {
         u'url': u'http://sztv.hu/hirek/cserkeszek-nepszerusitettek-a-kornyezettudatos-eletmodot-a-savaria-teren-20130909',
-        u'file': u'130909zoldnap.mp4',
-        u'md5': u'0047eacedc0afd1ceeac99e69173a07e',
+        u'file': u'20130909.mp4',
+        u'md5': u'a6df607b11fb07d0e9f2ad94613375cb',
         u'info_dict': {
             u"title": u"Cserkészek népszerűsítették a környezettudatos életmódot a Savaria téren",
-            u"description" : u'A zöld nap játékos ismeretterjesztő programjait a Magyar Cserkész Szövetség szervezte, akik az ország nyolc városában adják át tudásukat az érdeklődőknek. A PET...',
+            u"description": u'A zöld nap játékos ismeretterjesztő programjait a Magyar Cserkész Szövetség szervezte, akik az ország nyolc városában adják át tudásukat az érdeklődőknek. A PET...',
         }
     }
 
     def _real_extract(self, url):
         mobj = re.match(self._VALID_URL, url)
-        name = mobj.group('name')
-        webpage = self._download_webpage(url, name)
-#        file = self._search_regex(r'var fileHtml5 = "...:(.*?)";',
-        file = self._search_regex(r'file: "...:(.*?)",',
-                                webpage, 'video file')
-        title = self._html_search_regex(r'<meta name="title" content="([^"]*)"',
-                                webpage, 'video title').rsplit(' - ', 2)[0]
-        description = self._html_search_regex(r'<meta name="description" content="([^"]*)"/>',
-                                webpage, 'video description')
+        video_id = mobj.group('id')
+        webpage = self._download_webpage(url, video_id)
+        video_file = self._search_regex(
+            r'file: "...:(.*?)",', webpage, 'video file')
+        title = self._html_search_regex(
+            r'<meta name="title" content="([^"]*) - [^-]*"',
+            webpage, 'video title')
+        description = self._html_search_regex(
+            r'<meta name="description" content="([^"]*)"/>',
+            webpage, 'video description', fatal=False)
         thumbnail = self._og_search_thumbnail(webpage)
 
-        video_url = 'http://media.sztv.hu/vod/' + file
+        video_url = 'http://media.sztv.hu/vod/' + video_file
 
-        return {'id': name,
-                'url' : video_url,
-                'title': title,
-                'ext': determine_ext(video_url),
-                'description': description,
-                'thumbnail': thumbnail,
-                }
+        return {
+            'id': video_id,
+            'url': video_url,
+            'title': title,
+            'ext': determine_ext(video_url),
+            'description': description,
+            'thumbnail': thumbnail,
+        }