You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
5.7 KiB

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