diff options
author | James Taylor <user234683@users.noreply.github.com> | 2019-12-30 16:18:38 -0800 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2019-12-30 16:18:38 -0800 |
commit | 506dbb552a97ec4cc70538fc8e13ef9bfa901a4c (patch) | |
tree | dc72fde272789e5226e1ddfcebb47114712d6ebd /youtube/yt_data_extract | |
parent | 0c6a37e9aacf19405c3daf2b7993f55c8b8e421a (diff) | |
download | yt-local-506dbb552a97ec4cc70538fc8e13ef9bfa901a4c.tar.lz yt-local-506dbb552a97ec4cc70538fc8e13ef9bfa901a4c.tar.xz yt-local-506dbb552a97ec4cc70538fc8e13ef9bfa901a4c.zip |
Extraction: Correctly extract view_count for vids with 0 views.
Also change superfluous use of multi_get to item.get nearby
Diffstat (limited to 'youtube/yt_data_extract')
-rw-r--r-- | youtube/yt_data_extract/common.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/youtube/yt_data_extract/common.py b/youtube/yt_data_extract/common.py index 8d91f26..dfccdd1 100644 --- a/youtube/yt_data_extract/common.py +++ b/youtube/yt_data_extract/common.py @@ -258,7 +258,15 @@ def extract_item_info(item, additional_info={}): if info['view_count']: info['approx_view_count'] = '{:,}'.format(info['view_count']) else: - info['approx_view_count'] = extract_approx_int(multi_get(item, 'shortViewCountText')) + info['approx_view_count'] = extract_approx_int(item.get('shortViewCountText')) + + # handle case where it is "No views" + if not info['approx_view_count']: + if ('No views' in item.get('shortViewCountText', '') + or 'no views' in accessibility_label.lower()): + info['view_count'] = 0 + info['approx_view_count'] = '0' + info['duration'] = extract_str(item.get('lengthText')) elif primary_type == 'playlist': info['id'] = item.get('playlistId') |