mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-21 20:46:36 -05:00
[linkedin] Don't login multiple times
This commit is contained in:
parent
5b6cb56207
commit
da48320075
1 changed files with 6 additions and 0 deletions
|
@ -19,6 +19,7 @@
|
|||
class LinkedInLearningBaseIE(InfoExtractor):
|
||||
_NETRC_MACHINE = 'linkedin'
|
||||
_LOGIN_URL = 'https://www.linkedin.com/uas/login?trk=learning'
|
||||
_logged_in = False
|
||||
|
||||
def _call_api(self, course_slug, fields, video_slug=None, resolution=None):
|
||||
query = {
|
||||
|
@ -34,6 +35,8 @@ def _call_api(self, course_slug, fields, video_slug=None, resolution=None):
|
|||
})
|
||||
sub = ' %dp' % resolution
|
||||
api_url = 'https://www.linkedin.com/learning-api/detailedCourses'
|
||||
if not self._get_cookies(api_url).get('JSESSIONID'):
|
||||
self.raise_login_required()
|
||||
return self._download_json(
|
||||
api_url, video_slug, 'Downloading%s JSON metadata' % sub, headers={
|
||||
'Csrf-Token': self._get_cookies(api_url)['JSESSIONID'].value,
|
||||
|
@ -50,6 +53,8 @@ def _get_video_id(self, video_data, course_slug, video_slug):
|
|||
return self._get_urn_id(video_data) or '%s/%s' % (course_slug, video_slug)
|
||||
|
||||
def _real_initialize(self):
|
||||
if self._logged_in:
|
||||
return
|
||||
email, password = self._get_login_info()
|
||||
if email is None:
|
||||
return
|
||||
|
@ -72,6 +77,7 @@ def _real_initialize(self):
|
|||
login_submit_page, 'error', default=None)
|
||||
if error:
|
||||
raise ExtractorError(error, expected=True)
|
||||
LinkedInLearningBaseIE._logged_in = True
|
||||
|
||||
|
||||
class LinkedInLearningIE(LinkedInLearningBaseIE):
|
||||
|
|
Loading…
Reference in a new issue