better Vimeo tests; fixed a couple of VimeoIE fields
authorFilippo Valsorda <filippo.valsorda@gmail.com>
Thu, 20 Dec 2012 15:30:55 +0000 (16:30 +0100)
committerFilippo Valsorda <filippo.valsorda@gmail.com>
Thu, 20 Dec 2012 15:30:55 +0000 (16:30 +0100)
test/test_download.py
test/test_write_info_json.py
test/test_youtube_lists.py
test/test_youtube_subtitles.py
test/tests.json
youtube_dl/InfoExtractors.py
youtube_dl/utils.py

index 9a6d4d6046f2d786e9db1deb3c10d5fa593544db..1ee1b334d3b5a8f251acb23f6fc48720d776d3c0 100644 (file)
@@ -6,8 +6,8 @@ import os
 import json
 import unittest
 import sys
-import socket
 import hashlib
+import socket
 
 # Allow direct execution
 sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
@@ -25,7 +25,6 @@ cookie_processor = compat_urllib_request.HTTPCookieProcessor(jar)
 proxy_handler = compat_urllib_request.ProxyHandler()
 opener = compat_urllib_request.build_opener(proxy_handler, cookie_processor, YoutubeDLHandler())
 compat_urllib_request.install_opener(opener)
-socket.setdefaulttimeout(300) # 5 minutes should be enough (famous last words)
 
 class FileDownloader(youtube_dl.FileDownloader):
     def __init__(self, *args, **kwargs):
@@ -90,12 +89,12 @@ def generator(test_case):
             md5_for_file = _file_md5(test_case['file'])
             self.assertEqual(md5_for_file, test_case['md5'])
         info_dict = fd.processed_info_dicts[0]
-        for (info_element, value) in test_case.get('info_dict', {}).items():
+        for (info_field, value) in test_case.get('info_dict', {}).items():
             if value.startswith('md5:'):
-                md5_info_value = hashlib.md5(info_dict[info_element]).hexdigest()
+                md5_info_value = hashlib.md5(info_dict.get(info_field, '')).hexdigest()
                 self.assertEqual(value[3:], md5_info_value)
             else:
-                self.assertEqual(value, info_dict[info_element])
+                self.assertEqual(value, info_dict.get(info_field))
 
     return test_template
 
index ebf543980409873d713af192d0d42f77af610e2a..8134dda371c0e31f57a9fc199452e33808a5702b 100644 (file)
@@ -3,7 +3,6 @@
 
 import json
 import os
-import socket
 import sys
 import unittest
 
@@ -22,7 +21,6 @@ cookie_processor = compat_urllib_request.HTTPCookieProcessor(jar)
 proxy_handler = compat_urllib_request.ProxyHandler()
 opener = compat_urllib_request.build_opener(proxy_handler, cookie_processor, YoutubeDLHandler())
 compat_urllib_request.install_opener(opener)
-socket.setdefaulttimeout(300) # 5 minutes should be enough (famous last words)
 
 class FileDownloader(youtube_dl.FileDownloader):
     def __init__(self, *args, **kwargs):
index e352e5ab9ef6277f4b22bb34e0d8c0c66a65f5ea..3044e0852ab52cdaf5dc9c46177c7916dbf2e03e 100644 (file)
@@ -2,7 +2,6 @@
 
 import sys
 import unittest
-import socket
 import json
 
 # Allow direct execution
@@ -22,7 +21,6 @@ cookie_processor = compat_urllib_request.HTTPCookieProcessor(jar)
 proxy_handler = compat_urllib_request.ProxyHandler()
 opener = compat_urllib_request.build_opener(proxy_handler, cookie_processor, YoutubeDLHandler())
 compat_urllib_request.install_opener(opener)
-socket.setdefaulttimeout(300) # 5 minutes should be enough (famous last words)
 
 class FakeDownloader(object):
     def __init__(self):
index 64a391d14cdd2ff50edf7cebb53dd2146978367f..5d3566a35f5a900ac3eb613de9877228c5a40aae 100644 (file)
@@ -2,7 +2,6 @@
 
 import sys
 import unittest
-import socket
 import json
 import io
 import hashlib
@@ -24,7 +23,6 @@ cookie_processor = compat_urllib_request.HTTPCookieProcessor(jar)
 proxy_handler = compat_urllib_request.ProxyHandler()
 opener = compat_urllib_request.build_opener(proxy_handler, cookie_processor, YoutubeDLHandler())
 compat_urllib_request.install_opener(opener)
-socket.setdefaulttimeout(300) # 5 minutes should be enough (famous last words)
 
 class FakeDownloader(object):
     def __init__(self):
index 83afda985083fa635104695007bdac6e42d5df8e..d24bdf6fce45540588180fd34c225a72b361460a 100644 (file)
   },
   {
     "name": "Vimeo",
-    "md5":  "60540a4ec7cc378ec84b919c0aed5023",
-    "url":  "http://vimeo.com/14160053",
-    "file": "14160053.mp4"
+    "md5":  "8879b6cc097e987f02484baf890129e5",
+    "url":  "http://vimeo.com/56015672",
+    "file": "56015672.mp4",
+    "info_dict": {
+      "title": "youtube-dl test video - ★ \" ' 幸 / \\ ä ↭ 𝕐",
+      "uploader": "Filippo Valsorda",
+      "uploader_id": "user7108434",
+      "upload_date": "20121220",
+      "description": "This is a test case for youtube-dl.\nFor more information, see github.com/rg3/youtube-dl\nTest chars: ★ \" ' 幸 / \\ ä ↭ 𝕐"
+    }
   },
   {
     "name": "Soundcloud",
index 3eb070d4a6ef7b8104046d2f27aa2b6a3219954b..5a903233142e0f2862f3cc37cfb5978676a5cc07 100755 (executable)
@@ -1018,9 +1018,9 @@ class VimeoIE(InfoExtractor):
 
         # Extract upload date
         video_upload_date = None
-        mobj = re.search(r'<span id="clip-date" style="display:none">[^:]*: (.*?)( \([^\(]*\))?</span>', webpage)
+        mobj = re.search(r'<meta itemprop="dateCreated" content="(\d{4})-(\d{2})-(\d{2})T', webpage)
         if mobj is not None:
-            video_upload_date = mobj.group(1)
+            video_upload_date = mobj.group(1) + mobj.group(2) + mobj.group(3)
 
         # Vimeo specific: extract request signature and timestamp
         sig = config['request']['signature']
index c18c9beedb85904578dad654c624d97ccc1f68a0..463804e183117b23efd8f0e4b0ad9b132e519ddb 100644 (file)
@@ -298,7 +298,8 @@ def clean_html(html):
     """Clean an HTML snippet into a readable string"""
     # Newline vs <br />
     html = html.replace('\n', ' ')
-    html = re.sub('\s*<\s*br\s*/?\s*>\s*', '\n', html)
+    html = re.sub(r'\s*<\s*br\s*/?\s*>\s*', '\n', html)
+    html = re.sub(r'<\s*/\s*p\s*>\s*<\s*p[^>]*>', '\n', html)
     # Strip html tags
     html = re.sub('<.*?>', '', html)
     # Replace html entities