mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 14:45:14 +00:00 
			
		
		
		
	[extractor] Add _perform_login function (#2943)
				
					
				
			* Adds new functions `_initialize_pre_login` and `_perform_login` as part of the extractor API * Adds `ie.supports_login` to the public API
This commit is contained in:
		| @@ -12,11 +12,6 @@ from test.helper import FakeYDL, is_download_test | ||||
| from yt_dlp.extractor import IqiyiIE | ||||
|  | ||||
|  | ||||
| class IqiyiIEWithCredentials(IqiyiIE): | ||||
|     def _get_login_info(self): | ||||
|         return 'foo', 'bar' | ||||
|  | ||||
|  | ||||
| class WarningLogger(object): | ||||
|     def __init__(self): | ||||
|         self.messages = [] | ||||
| @@ -40,8 +35,8 @@ class TestIqiyiSDKInterpreter(unittest.TestCase): | ||||
|         If `sign` is incorrect, /validate call throws an HTTP 556 error | ||||
|         ''' | ||||
|         logger = WarningLogger() | ||||
|         ie = IqiyiIEWithCredentials(FakeYDL({'logger': logger})) | ||||
|         ie._login() | ||||
|         ie = IqiyiIE(FakeYDL({'logger': logger})) | ||||
|         ie._perform_login('foo', 'bar') | ||||
|         self.assertTrue('unable to log in:' in logger.messages[0]) | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -7,18 +7,19 @@ import unittest | ||||
| sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | ||||
|  | ||||
|  | ||||
| from yt_dlp.extractor import ( | ||||
|     gen_extractors, | ||||
| ) | ||||
| from yt_dlp.extractor import gen_extractor_classes | ||||
| from yt_dlp.extractor.common import InfoExtractor | ||||
|  | ||||
| NO_LOGIN = InfoExtractor._perform_login | ||||
|  | ||||
|  | ||||
| class TestNetRc(unittest.TestCase): | ||||
|     def test_netrc_present(self): | ||||
|         for ie in gen_extractors(): | ||||
|             if not hasattr(ie, '_login'): | ||||
|         for ie in gen_extractor_classes(): | ||||
|             if ie._perform_login is NO_LOGIN: | ||||
|                 continue | ||||
|             self.assertTrue( | ||||
|                 hasattr(ie, '_NETRC_MACHINE'), | ||||
|                 ie._NETRC_MACHINE, | ||||
|                 'Extractor %s supports login, but is missing a _NETRC_MACHINE property' % ie.IE_NAME) | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 pukkandan
					pukkandan