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.

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