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.

88 lines
2.9 KiB

  1. #!/usr/bin/env python
  2. # encoding: utf-8
  3. import sys
  4. import unittest
  5. import json
  6. # Allow direct execution
  7. import os
  8. sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
  9. from youtube_dl.extractor import (
  10. DailymotionPlaylistIE,
  11. DailymotionUserIE,
  12. VimeoChannelIE,
  13. UstreamChannelIE,
  14. SoundcloudUserIE,
  15. LivestreamIE,
  16. NHLVideocenterIE,
  17. )
  18. from youtube_dl.utils import *
  19. from helper import FakeYDL
  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. if __name__ == '__main__':
  75. unittest.main()