test_playlists.py 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. # Allow direct execution
  4. import os
  5. import sys
  6. import unittest
  7. sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
  8. from test.helper import FakeYDL
  9. from youtube_dl.extractor import (
  10. DailymotionPlaylistIE,
  11. DailymotionUserIE,
  12. VimeoChannelIE,
  13. VimeoUserIE,
  14. VimeoAlbumIE,
  15. UstreamChannelIE,
  16. SoundcloudSetIE,
  17. SoundcloudUserIE,
  18. LivestreamIE,
  19. NHLVideocenterIE,
  20. BambuserChannelIE,
  21. BandcampAlbumIE,
  22. SmotriCommunityIE,
  23. SmotriUserIE
  24. )
  25. class TestPlaylists(unittest.TestCase):
  26. def assertIsPlaylist(self, info):
  27. """Make sure the info has '_type' set to 'playlist'"""
  28. self.assertEqual(info['_type'], 'playlist')
  29. def test_dailymotion_playlist(self):
  30. dl = FakeYDL()
  31. ie = DailymotionPlaylistIE(dl)
  32. result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
  33. self.assertIsPlaylist(result)
  34. self.assertEqual(result['title'], u'SPORT')
  35. self.assertTrue(len(result['entries']) > 20)
  36. def test_dailymotion_user(self):
  37. dl = FakeYDL()
  38. ie = DailymotionUserIE(dl)
  39. result = ie.extract('http://www.dailymotion.com/user/generation-quoi/')
  40. self.assertIsPlaylist(result)
  41. self.assertEqual(result['title'], u'Génération Quoi')
  42. self.assertTrue(len(result['entries']) >= 26)
  43. def test_vimeo_channel(self):
  44. dl = FakeYDL()
  45. ie = VimeoChannelIE(dl)
  46. result = ie.extract('http://vimeo.com/channels/tributes')
  47. self.assertIsPlaylist(result)
  48. self.assertEqual(result['title'], u'Vimeo Tributes')
  49. self.assertTrue(len(result['entries']) > 24)
  50. def test_vimeo_user(self):
  51. dl = FakeYDL()
  52. ie = VimeoUserIE(dl)
  53. result = ie.extract('http://vimeo.com/nkistudio/videos')
  54. self.assertIsPlaylist(result)
  55. self.assertEqual(result['title'], u'Nki')
  56. self.assertTrue(len(result['entries']) > 65)
  57. def test_vimeo_album(self):
  58. dl = FakeYDL()
  59. ie = VimeoAlbumIE(dl)
  60. result = ie.extract('http://vimeo.com/album/2632481')
  61. self.assertIsPlaylist(result)
  62. self.assertEqual(result['title'], u'Staff Favorites: November 2013')
  63. self.assertTrue(len(result['entries']) > 12)
  64. def test_ustream_channel(self):
  65. dl = FakeYDL()
  66. ie = UstreamChannelIE(dl)
  67. result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
  68. self.assertIsPlaylist(result)
  69. self.assertEqual(result['id'], u'5124905')
  70. self.assertTrue(len(result['entries']) >= 11)
  71. def test_soundcloud_set(self):
  72. dl = FakeYDL()
  73. ie = SoundcloudSetIE(dl)
  74. result = ie.extract('https://soundcloud.com/the-concept-band/sets/the-royal-concept-ep')
  75. self.assertIsPlaylist(result)
  76. self.assertEqual(result['title'], u'The Royal Concept EP')
  77. self.assertTrue(len(result['entries']) >= 6)
  78. def test_soundcloud_user(self):
  79. dl = FakeYDL()
  80. ie = SoundcloudUserIE(dl)
  81. result = ie.extract('https://soundcloud.com/the-concept-band')
  82. self.assertIsPlaylist(result)
  83. self.assertEqual(result['id'], u'9615865')
  84. self.assertTrue(len(result['entries']) >= 12)
  85. def test_livestream_event(self):
  86. dl = FakeYDL()
  87. ie = LivestreamIE(dl)
  88. result = ie.extract('http://new.livestream.com/tedx/cityenglish')
  89. self.assertIsPlaylist(result)
  90. self.assertEqual(result['title'], u'TEDCity2.0 (English)')
  91. self.assertTrue(len(result['entries']) >= 4)
  92. def test_nhl_videocenter(self):
  93. dl = FakeYDL()
  94. ie = NHLVideocenterIE(dl)
  95. result = ie.extract('http://video.canucks.nhl.com/videocenter/console?catid=999')
  96. self.assertIsPlaylist(result)
  97. self.assertEqual(result['id'], u'999')
  98. self.assertEqual(result['title'], u'Highlights')
  99. self.assertEqual(len(result['entries']), 12)
  100. def test_bambuser_channel(self):
  101. dl = FakeYDL()
  102. ie = BambuserChannelIE(dl)
  103. result = ie.extract('http://bambuser.com/channel/pixelversity')
  104. self.assertIsPlaylist(result)
  105. self.assertEqual(result['title'], u'pixelversity')
  106. self.assertTrue(len(result['entries']) >= 60)
  107. def test_bandcamp_album(self):
  108. dl = FakeYDL()
  109. ie = BandcampAlbumIE(dl)
  110. result = ie.extract('http://mpallante.bandcamp.com/album/nightmare-night-ep')
  111. self.assertIsPlaylist(result)
  112. self.assertEqual(result['title'], u'Nightmare Night EP')
  113. self.assertTrue(len(result['entries']) >= 4)
  114. def test_smotri_community(self):
  115. dl = FakeYDL()
  116. ie = SmotriCommunityIE(dl)
  117. result = ie.extract('http://smotri.com/community/video/kommuna')
  118. self.assertIsPlaylist(result)
  119. self.assertEqual(result['id'], u'kommuna')
  120. self.assertEqual(result['title'], u'КПРФ')
  121. self.assertTrue(len(result['entries']) >= 4)
  122. def test_smotri_user(self):
  123. dl = FakeYDL()
  124. ie = SmotriUserIE(dl)
  125. result = ie.extract('http://smotri.com/user/inspector')
  126. self.assertIsPlaylist(result)
  127. self.assertEqual(result['id'], u'inspector')
  128. self.assertEqual(result['title'], u'Inspector')
  129. self.assertTrue(len(result['entries']) >= 9)
  130. if __name__ == '__main__':
  131. unittest.main()