test_playlists.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. )
  16. from youtube_dl.utils import *
  17. from helper import FakeYDL
  18. class TestPlaylists(unittest.TestCase):
  19. def assertIsPlaylist(self, info):
  20. """Make sure the info has '_type' set to 'playlist'"""
  21. self.assertEqual(info['_type'], 'playlist')
  22. def test_dailymotion_playlist(self):
  23. dl = FakeYDL()
  24. ie = DailymotionPlaylistIE(dl)
  25. result = ie.extract('http://www.dailymotion.com/playlist/xv4bw_nqtv_sport/1#video=xl8v3q')
  26. self.assertIsPlaylist(result)
  27. self.assertEqual(result['title'], u'SPORT')
  28. self.assertTrue(len(result['entries']) > 20)
  29. def test_dailymotion_user(self):
  30. dl = FakeYDL()
  31. ie = DailymotionUserIE(dl)
  32. result = ie.extract('http://www.dailymotion.com/user/generation-quoi/')
  33. self.assertIsPlaylist(result)
  34. self.assertEqual(result['title'], u'Génération Quoi')
  35. self.assertTrue(len(result['entries']) >= 26)
  36. def test_vimeo_channel(self):
  37. dl = FakeYDL()
  38. ie = VimeoChannelIE(dl)
  39. result = ie.extract('http://vimeo.com/channels/tributes')
  40. self.assertIsPlaylist(result)
  41. self.assertEqual(result['title'], u'Vimeo Tributes')
  42. self.assertTrue(len(result['entries']) > 24)
  43. def test_ustream_channel(self):
  44. dl = FakeYDL()
  45. ie = UstreamChannelIE(dl)
  46. result = ie.extract('http://www.ustream.tv/channel/young-americans-for-liberty')
  47. self.assertIsPlaylist(result)
  48. self.assertEqual(result['id'], u'5124905')
  49. self.assertTrue(len(result['entries']) >= 11)
  50. def test_soundcloud_user(self):
  51. dl = FakeYDL()
  52. ie = SoundcloudUserIE(dl)
  53. result = ie.extract('https://soundcloud.com/the-concept-band')
  54. self.assertIsPlaylist(result)
  55. self.assertEqual(result['id'], u'9615865')
  56. self.assertTrue(len(result['entries']) >= 12)
  57. if __name__ == '__main__':
  58. unittest.main()