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.

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