enhance test cases and fix UDN style

This commit is contained in:
RPing 2015-11-18 17:54:40 +08:00
parent 8bf47118ef
commit 8c3665f5de
4 changed files with 13 additions and 18 deletions

View File

@ -70,7 +70,6 @@ class TestAllURLsMatching(unittest.TestCase):
def test_youtube_search_matching(self):
self.assertMatch('http://www.youtube.com/results?search_query=making+mustard', ['youtube:search_url'])
self.assertMatch('https://www.youtube.com/results?baz=bar&search_query=youtube-dl+test+video&filters=video&lclk=video', ['youtube:search_url'])
self.assertMatch('https://www.youtube.com/results?lclk=week&search_query=making+mustard&filters=week', ['youtube:search:date'])
def test_youtube_extract(self):
assertExtractId = lambda url, id: self.assertEqual(YoutubeIE.extract_id(url), id)
@ -139,10 +138,10 @@ class TestAllURLsMatching(unittest.TestCase):
self.assertMatch('http://news.cts.com.tw/cts/life/201511/201511151683198.html#.VkssxbNZOHs', ['CtsNews'])
self.assertMatch('http://news.cts.com.tw/cts/international/201511/201511171683689.html#.Vksv_bNZOHs', ['CtsNews'])
def test_UDN(self):
def test_udn(self):
self.assertMatch('https://video.udn.com/news/398685', ['UDN'])
self.assertMatch('https://video.udn.com/embed/news/300040', ['UDNEmbed'])
self.assertMatch('https://video.udn.com/play/news/303776', ['UDNEmbed'])
self.assertMatch('https://video.udn.com/embed/news/300040', ['UDN'])
self.assertMatch('https://video.udn.com/play/news/303776', ['UDN'])
def test_xuite(self):
self.assertMatch('http://vlog.xuite.net/play/T2lMdGpZLTk0NDA1MS5mbHY=', ['Xuite'])
@ -153,7 +152,9 @@ class TestAllURLsMatching(unittest.TestCase):
def test_mlb(self):
self.assertMatch('http://m.mlb.com/video/topic/9674738/v529001783/111015-mlbcom-fastcast-gold-gloves-announced', ['MLB'])
self.assertMatch('http://mlb.mlb.com/shared/video/embed/m-internal-embed.html?content_id=75609783&property=mlb&autoplay=true&hashmode=false&siteSection=mlb/multimedia/article_118550098/article_embed&club=mlb', ['MLB'])
self.assertMatch('http://washington.nationals.mlb.com/mlb/gameday/index.jsp?c_id=was&gid=2015_05_09_atlmlb_wasmlb_1&lang=en&content_id=108309983&mode=video#', ['MLB'])
self.assertMatch('http://m.mlb.com/video/v34577915/bautista-on-derby-captaining-duties-his-performance', ['MLB'])
if __name__ == '__main__':
unittest.main()

View File

@ -706,10 +706,7 @@ from .udemy import (
UdemyIE,
UdemyCourseIE
)
from .udn import (
UDNEmbedIE,
UDNIE
)
from .udn import UDNIE
from .ultimedia import UltimediaIE
from .unistra import UnistraIE
from .urort import UrortIE

View File

@ -42,7 +42,7 @@ from .sportbox import SportBoxEmbedIE
from .smotri import SmotriIE
from .myvi import MyviIE
from .condenast import CondeNastIE
from .udn import UDNEmbedIE
from .udn import UDNIE
from .senateisvp import SenateISVPIE
from .bliptv import BlipTVIE
from .svt import SVTIE

View File

@ -10,9 +10,9 @@ from ..utils import (
from ..compat import compat_urlparse
class UDNEmbedIE(InfoExtractor):
class UDNIE(InfoExtractor):
IE_DESC = '聯合影音'
_VALID_URL = r'https?://video\.udn\.com/(?:embed|play)/news/(?P<id>\d+)'
_VALID_URL = r'https?://video\.udn\.com/((?:embed|play)/)?news/(?P<id>\d+)'
_TESTS = [{
'url': 'http://video.udn.com/embed/news/300040',
'md5': 'de06b4c90b042c128395a88f0384817e',
@ -32,12 +32,12 @@ class UDNEmbedIE(InfoExtractor):
}]
def _real_extract(self, url):
video_id = self._match_id(url)
if isinstance(self, UDNIE):
if "embed" not in url and "play" not in url:
p = url.index("com/") + 4
url = url[:p] + "embed/" + url[p:]
video_id = self._match_id(url)
page = self._download_webpage(url, video_id)
options = json.loads(js_to_json(self._html_search_regex(
@ -77,6 +77,3 @@ class UDNEmbedIE(InfoExtractor):
'title': options['title'],
'thumbnail': thumbnail
}
class UDNIE(UDNEmbedIE):
_VALID_URL = r'https?://video\.udn\.com/news/(?P<id>\d+)'