test_youtube_misc.py 976 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env python3
  2. # Allow direct execution
  3. import os
  4. import sys
  5. import unittest
  6. sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
  7. from yt_dlp.extractor import YoutubeIE
  8. class TestYoutubeMisc(unittest.TestCase):
  9. def test_youtube_extract(self):
  10. assertExtractId = lambda url, video_id: self.assertEqual(YoutubeIE.extract_id(url), video_id)
  11. assertExtractId('http://www.youtube.com/watch?&v=BaW_jenozKc', 'BaW_jenozKc')
  12. assertExtractId('https://www.youtube.com/watch?&v=BaW_jenozKc', 'BaW_jenozKc')
  13. assertExtractId('https://www.youtube.com/watch?feature=player_embedded&v=BaW_jenozKc', 'BaW_jenozKc')
  14. assertExtractId('https://www.youtube.com/watch_popup?v=BaW_jenozKc', 'BaW_jenozKc')
  15. assertExtractId('http://www.youtube.com/watch?v=BaW_jenozKcsharePLED17F32AD9753930', 'BaW_jenozKc')
  16. assertExtractId('BaW_jenozKc', 'BaW_jenozKc')
  17. if __name__ == '__main__':
  18. unittest.main()