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.

78 lines
2.5 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. )
  17. from youtube_dl.utils import *
  18. from helper import FakeYDL
  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. if __name__ == '__main__':
  66. unittest.main()