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.

54 lines
1.8 KiB

  1. #!/usr/bin/env python
  2. import sys
  3. import unittest
  4. import json
  5. # Allow direct execution
  6. import os
  7. sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
  8. from youtube_dl.extractor import DailymotionPlaylistIE, VimeoChannelIE, UstreamChannelIE, SoundcloudUserIE
  9. from youtube_dl.utils import *
  10. from helper import FakeYDL
  11. class TestPlaylists(unittest.TestCase):
  12. def assertIsPlaylist(self, info):
  13. """Make sure the info has '_type' set to 'playlist'"""
  14. self.assertEqual(info['_type'], 'playlist')
  15. def test_dailymotion_playlist(self):
  16. dl = FakeYDL()
  17. ie = DailymotionPlaylistIE(dl)
  18. result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
  19. self.assertIsPlaylist(result)
  20. self.assertEqual(result['title'], u'SPORT')
  21. self.assertTrue(len(result['entries']) > 20)
  22. def test_vimeo_channel(self):
  23. dl = FakeYDL()
  24. ie = VimeoChannelIE(dl)
  25. result = ie.extract('http://vimeo.com/channels/tributes')
  26. self.assertIsPlaylist(result)
  27. self.assertEqual(result['title'], u'Vimeo Tributes')
  28. self.assertTrue(len(result['entries']) > 24)
  29. def test_ustream_channel(self):
  30. dl = FakeYDL()
  31. ie = UstreamChannelIE(dl)
  32. result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
  33. self.assertIsPlaylist(result)
  34. self.assertEqual(result['id'], u'5124905')
  35. self.assertTrue(len(result['entries']) >= 11)
  36. def test_soundcloud_user(self):
  37. dl = FakeYDL()
  38. ie = SoundcloudUserIE(dl)
  39. result = ie.extract('https://soundcloud.com/the-concept-band')
  40. self.assertIsPlaylist(result)
  41. self.assertEqual(result['id'], u'9615865')
  42. self.assertTrue(len(result['entries']) >= 12)
  43. if __name__ == '__main__':
  44. unittest.main()