aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_all_urls.py6
-rw-r--r--test/test_playlists.py33
-rw-r--r--test/test_utils.py28
3 files changed, 56 insertions, 11 deletions
diff --git a/test/test_all_urls.py b/test/test_all_urls.py
index e9458b2e3..bd77b7c30 100644
--- a/test/test_all_urls.py
+++ b/test/test_all_urls.py
@@ -10,6 +10,7 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import get_testcases
from youtube_dl.extractor import (
+ FacebookIE,
gen_extractors,
JustinTVIE,
YoutubeIE,
@@ -87,12 +88,15 @@ class TestAllURLsMatching(unittest.TestCase):
assertExtractId('http://www.youtube.com/watch?v=BaW_jenozKcsharePLED17F32AD9753930', 'BaW_jenozKc')
assertExtractId('BaW_jenozKc', 'BaW_jenozKc')
+ def test_facebook_matching(self):
+ self.assertTrue(FacebookIE.suitable(u'https://www.facebook.com/Shiniknoh#!/photo.php?v=10153317450565268'))
+
def test_no_duplicates(self):
ies = gen_extractors()
for tc in get_testcases():
url = tc['url']
for ie in ies:
- if type(ie).__name__ in ['GenericIE', tc['name'] + 'IE']:
+ if type(ie).__name__ in ('GenericIE', tc['name'] + 'IE'):
self.assertTrue(ie.suitable(url), '%s should match URL %r' % (type(ie).__name__, url))
else:
self.assertFalse(ie.suitable(url), '%s should not match URL %r' % (type(ie).__name__, url))
diff --git a/test/test_playlists.py b/test/test_playlists.py
index 87ca401e5..1b7b4e3d8 100644
--- a/test/test_playlists.py
+++ b/test/test_playlists.py
@@ -12,6 +12,7 @@ from test.helper import FakeYDL
from youtube_dl.extractor import (
+ AcademicEarthCourseIE,
DailymotionPlaylistIE,
DailymotionUserIE,
VimeoChannelIE,
@@ -26,7 +27,8 @@ from youtube_dl.extractor import (
BambuserChannelIE,
BandcampAlbumIE,
SmotriCommunityIE,
- SmotriUserIE
+ SmotriUserIE,
+ IviCompilationIE
)
@@ -158,5 +160,34 @@ class TestPlaylists(unittest.TestCase):
self.assertEqual(result['title'], u'Inspector')
self.assertTrue(len(result['entries']) >= 9)
+ def test_AcademicEarthCourse(self):
+ dl = FakeYDL()
+ ie = AcademicEarthCourseIE(dl)
+ result = ie.extract(u'http://academicearth.org/courses/building-dynamic-websites/')
+ self.assertIsPlaylist(result)
+ self.assertEqual(result['id'], u'building-dynamic-websites')
+ self.assertEqual(result['title'], u'Building Dynamic Websites')
+ self.assertEqual(result['description'], u"Today's websites are increasingly dynamic. Pages are no longer static HTML files but instead generated by scripts and database calls. User interfaces are more seamless, with technologies like Ajax replacing traditional page reloads. This course teaches students how to build dynamic websites with Ajax and with Linux, Apache, MySQL, and PHP (LAMP), one of today's most popular frameworks. Students learn how to set up domain names with DNS, how to structure pages with XHTML and CSS, how to program in JavaScript and PHP, how to configure Apache and MySQL, how to design and query databases with SQL, how to use Ajax with both XML and JSON, and how to build mashups. The course explores issues of security, scalability, and cross-browser support and also discusses enterprise-level deployments of websites, including third-party hosting, virtualization, colocation in data centers, firewalling, and load-balancing.")
+ self.assertEqual(len(result['entries']), 10)
+
+ def test_ivi_compilation(self):
+ dl = FakeYDL()
+ ie = IviCompilationIE(dl)
+ result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel')
+ self.assertIsPlaylist(result)
+ self.assertEqual(result['id'], u'dezhurnyi_angel')
+ self.assertEqual(result['title'], u'Дежурный ангел (2010 - 2012)')
+ self.assertTrue(len(result['entries']) >= 36)
+
+ def test_ivi_compilation_season(self):
+ dl = FakeYDL()
+ ie = IviCompilationIE(dl)
+ result = ie.extract('http://www.ivi.ru/watch/dezhurnyi_angel/season2')
+ self.assertIsPlaylist(result)
+ self.assertEqual(result['id'], u'dezhurnyi_angel/season2')
+ self.assertEqual(result['title'], u'Дежурный ангел (2010 - 2012) 2 сезон')
+ self.assertTrue(len(result['entries']) >= 20)
+
+
if __name__ == '__main__':
unittest.main()
diff --git a/test/test_utils.py b/test/test_utils.py
index 0fa66beec..e5778cd83 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -13,20 +13,21 @@ import xml.etree.ElementTree
#from youtube_dl.utils import htmlentity_transform
from youtube_dl.utils import (
- timeconvert,
- sanitize_filename,
- unescapeHTML,
- orderedSet,
DateRange,
- unified_strdate,
+ encodeFilename,
find_xpath_attr,
get_meta_content,
- xpath_with_ns,
- smuggle_url,
- unsmuggle_url,
+ orderedSet,
+ sanitize_filename,
shell_quote,
- encodeFilename,
+ smuggle_url,
str_to_int,
+ timeconvert,
+ unescapeHTML,
+ unified_strdate,
+ unsmuggle_url,
+ url_basename,
+ xpath_with_ns,
)
if sys.version_info < (3, 0):
@@ -181,6 +182,15 @@ class TestUtil(unittest.TestCase):
self.assertEqual(str_to_int('123,456'), 123456)
self.assertEqual(str_to_int('123.456'), 123456)
+ def test_url_basename(self):
+ self.assertEqual(url_basename(u'http://foo.de/'), u'')
+ self.assertEqual(url_basename(u'http://foo.de/bar/baz'), u'baz')
+ self.assertEqual(url_basename(u'http://foo.de/bar/baz?x=y'), u'baz')
+ self.assertEqual(url_basename(u'http://foo.de/bar/baz#x=y'), u'baz')
+ self.assertEqual(url_basename(u'http://foo.de/bar/baz/'), u'baz')
+ self.assertEqual(
+ url_basename(u'http://media.w3.org/2010/05/sintel/trailer.mp4'),
+ u'trailer.mp4')
if __name__ == '__main__':
unittest.main()