Skip to content

Commit

Permalink
Add field live_status
Browse files Browse the repository at this point in the history
  • Loading branch information
pukkandan committed Jul 21, 2021
1 parent f2baf41 commit 17441f3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 18 additions & 1 deletion YoutubeDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -2036,7 +2036,7 @@ def sanitize_numeric_fields(info):
elif thumbnails:
info_dict['thumbnail'] = thumbnails[-1]['url']

if 'display_id' not in info_dict and 'id' in info_dict:
if info_dict.get('display_id') is None and 'id' in info_dict:
info_dict['display_id'] = info_dict['id']

for ts_key, date_key in (
Expand All @@ -2052,6 +2052,23 @@ def sanitize_numeric_fields(info):
except (ValueError, OverflowError, OSError):
pass

live_keys = ('is_live', 'was_live')
live_status = info_dict.get('live_status')
if live_status is None:
for key in live_keys:
if info_dict.get(key) is False:
continue
if info_dict.get(key):
live_status = key
break
if all(info_dict.get(key) is False for key in live_keys):
live_status = 'not_live'
if live_status:
info_dict['live_status'] = live_status
for key in live_keys:
if info_dict.get(key) is None:
info_dict[key] = (live_status == key)

# Auto generate title fields corresponding to the *_number fields when missing
# in order to always have clean titles. This is very common for TV series.
for field in ('chapter', 'season', 'episode'):
Expand Down
2 changes: 2 additions & 0 deletions extractor/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ class InfoExtractor(object):
live stream that goes on instead of a fixed-length video.
was_live: True, False, or None (=unknown). Whether this video was
originally a live stream.
live_status: 'is_live', 'upcoming', 'was_live', 'not_live' or None (=unknown)
If absent, automatically set from is_live, was_live
start_time: Time in seconds where the reproduction should start, as
specified in the URL.
end_time: Time in seconds where the reproduction should end, as
Expand Down

0 comments on commit 17441f3

Please sign in to comment.