Skip to content

Commit 3157612

Browse files
authored
Livestream exception raising
* Implements an actual check for whether a video is a livestream, and raises an exception if it is.
1 parent e776be6 commit 3157612

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

pytube/__main__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ def check_availability(self):
268268
elif status == 'ERROR':
269269
if reason == 'Video unavailable':
270270
raise exceptions.VideoUnavailable(video_id=self.video_id)
271+
elif status == 'LIVE_STREAM':
272+
raise exceptions.LiveStreamError(video_id=self.video_id)
271273

272274
@property
273275
def vid_info(self):

pytube/extract.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ def playability_status(watch_html: str) -> (str, str):
134134
"""
135135
player_response = initial_player_response(watch_html)
136136
status_dict = player_response.get('playabilityStatus', {})
137+
if 'liveStreamability' in status_dict:
138+
return 'LIVE_STREAM', 'Video is a live stream.'
137139
if 'status' in status_dict:
138140
if 'reason' in status_dict:
139141
return status_dict['status'], [status_dict['reason']]

0 commit comments

Comments
 (0)