mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-04-27 19:15:53 +00:00
Compare commits
2 Commits
f7db477465
...
a795c9eb4a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a795c9eb4a | ||
|
|
5333967dd9 |
@ -1,4 +1,3 @@
|
||||
import datetime as dt
|
||||
import itertools
|
||||
import json
|
||||
import re
|
||||
@ -275,7 +274,7 @@ class LinkedInLearningCourseIE(LinkedInLearningBaseIE):
|
||||
course_data.get('description'))
|
||||
|
||||
|
||||
class LinkedInEventsIE(InfoExtractor):
|
||||
class LinkedInEventsIE(LinkedInBaseIE):
|
||||
IE_NAME = 'linkedin:events'
|
||||
_VALID_URL = r'https?://(?:www\.)?linkedin\.com/events/(?P<id>[\w-]+)'
|
||||
_TESTS = [{
|
||||
@ -308,6 +307,10 @@ class LinkedInEventsIE(InfoExtractor):
|
||||
},
|
||||
}]
|
||||
|
||||
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):
|
||||
event_id = self._match_id(url)
|
||||
webpage = self._download_webpage(url, event_id)
|
||||
@ -325,25 +328,11 @@ class LinkedInEventsIE(InfoExtractor):
|
||||
|
||||
if live_status == 'is_upcoming':
|
||||
player_data = {}
|
||||
dt_params = traverse_obj(meta_data, ('startDateTime', {
|
||||
'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")}'
|
||||
if event_time := traverse_obj(meta_data, ('displayEventTime', {str})):
|
||||
message = f'This live event is scheduled for {event_time}'
|
||||
else:
|
||||
message = 'This live event has not yet started'
|
||||
|
||||
self.raise_no_formats(message, expected=True, video_id=event_id)
|
||||
|
||||
else:
|
||||
# TODO: Add support for audio-only live events
|
||||
player_data = traverse_obj(base_data, (
|
||||
@ -377,13 +366,16 @@ class LinkedInEventsIE(InfoExtractor):
|
||||
'formats': formats,
|
||||
'subtitles': subtitles,
|
||||
'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, {
|
||||
'title': ('name', {str}),
|
||||
'description': ('description', 'text', {str}),
|
||||
'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