mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-06-26 04:34:56 +00:00
Compare commits
No commits in common. "a795c9eb4a80cf1f84b5916454e99c17fea4b0fd" and "f7db477465ff7bfd53cbd0220ba298ca04572784" have entirely different histories.
a795c9eb4a
...
f7db477465
@ -1,3 +1,4 @@
|
|||||||
|
import datetime as dt
|
||||||
import itertools
|
import itertools
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
@ -274,7 +275,7 @@ class LinkedInLearningCourseIE(LinkedInLearningBaseIE):
|
|||||||
course_data.get('description'))
|
course_data.get('description'))
|
||||||
|
|
||||||
|
|
||||||
class LinkedInEventsIE(LinkedInBaseIE):
|
class LinkedInEventsIE(InfoExtractor):
|
||||||
IE_NAME = 'linkedin:events'
|
IE_NAME = 'linkedin:events'
|
||||||
_VALID_URL = r'https?://(?:www\.)?linkedin\.com/events/(?P<id>[\w-]+)'
|
_VALID_URL = r'https?://(?:www\.)?linkedin\.com/events/(?P<id>[\w-]+)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
@ -307,10 +308,6 @@ class LinkedInEventsIE(LinkedInBaseIE):
|
|||||||
},
|
},
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def _real_initialize(self):
|
|
||||||
if not self._get_cookies('https://www.linkedin.com/').get('li_at'):
|
|
||||||
self.raise_login_required()
|
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
event_id = self._match_id(url)
|
event_id = self._match_id(url)
|
||||||
webpage = self._download_webpage(url, event_id)
|
webpage = self._download_webpage(url, event_id)
|
||||||
@ -328,11 +325,25 @@ class LinkedInEventsIE(LinkedInBaseIE):
|
|||||||
|
|
||||||
if live_status == 'is_upcoming':
|
if live_status == 'is_upcoming':
|
||||||
player_data = {}
|
player_data = {}
|
||||||
if event_time := traverse_obj(meta_data, ('displayEventTime', {str})):
|
dt_params = traverse_obj(meta_data, ('startDateTime', {
|
||||||
message = f'This live event is scheduled for {event_time}'
|
'year': ('dateOn', 'year'),
|
||||||
|
'month': ('dateOn', 'month'),
|
||||||
|
'day': ('dateOn', 'day'),
|
||||||
|
'hour': ('timeOfDay', 'hour'),
|
||||||
|
'minute': ('timeOfDay', 'minute'),
|
||||||
|
'second': ('timeOfDay', 'second'),
|
||||||
|
}), expected_type=int_or_none)
|
||||||
|
|
||||||
|
if len(dt_params) == 6:
|
||||||
|
start_time = dt.datetime(**dt_params, tzinfo=dt.timezone.utc)
|
||||||
|
# Extracted as release_timestamp for --wait-for-video support
|
||||||
|
player_data['liveStreamCreatedAt'] = start_time.timestamp() * 1000
|
||||||
|
message = f'This live event will begin at {start_time.strftime("%Y-%m-%d %H:%M:%S %Z")}'
|
||||||
else:
|
else:
|
||||||
message = 'This live event has not yet started'
|
message = 'This live event has not yet started'
|
||||||
|
|
||||||
self.raise_no_formats(message, expected=True, video_id=event_id)
|
self.raise_no_formats(message, expected=True, video_id=event_id)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# TODO: Add support for audio-only live events
|
# TODO: Add support for audio-only live events
|
||||||
player_data = traverse_obj(base_data, (
|
player_data = traverse_obj(base_data, (
|
||||||
@ -366,16 +377,13 @@ class LinkedInEventsIE(LinkedInBaseIE):
|
|||||||
'formats': formats,
|
'formats': formats,
|
||||||
'subtitles': subtitles,
|
'subtitles': subtitles,
|
||||||
'live_status': live_status,
|
'live_status': live_status,
|
||||||
|
**traverse_obj(player_data, {
|
||||||
|
'duration': ('duration', {int_or_none(scale=1000)}),
|
||||||
|
'release_timestamp': ('liveStreamCreatedAt', {int_or_none(scale=1000)}),
|
||||||
|
}),
|
||||||
**traverse_obj(meta_data, {
|
**traverse_obj(meta_data, {
|
||||||
'title': ('name', {str}),
|
'title': ('name', {str}),
|
||||||
'description': ('description', 'text', {str}),
|
'description': ('description', 'text', {str}),
|
||||||
'timestamp': ('createdAt', {int_or_none(scale=1000)}),
|
'timestamp': ('createdAt', {int_or_none(scale=1000)}),
|
||||||
# timeRange.start is available when the stream is_upcoming
|
|
||||||
'release_timestamp': ('timeRange', 'start', {int_or_none(scale=1000)}),
|
|
||||||
}),
|
|
||||||
**traverse_obj(player_data, {
|
|
||||||
'duration': ('duration', {int_or_none(scale=1000)}),
|
|
||||||
# liveStreamCreatedAt is only available when the stream is_live or was_live
|
|
||||||
'release_timestamp': ('liveStreamCreatedAt', {int_or_none(scale=1000)}),
|
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user