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.

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