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.

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