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.

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