diff options
author | James Taylor <user234683@users.noreply.github.com> | 2019-12-26 19:39:48 -0800 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2019-12-26 19:39:48 -0800 |
commit | 0c6a37e9aacf19405c3daf2b7993f55c8b8e421a (patch) | |
tree | 43fd9863d9cf8a8d3329c968d01820a0dfc35eea /youtube/yt_data_extract | |
parent | 8e8a1b70b698ce56fe6f4d2be87d91d71001bb11 (diff) | |
download | yt-local-0c6a37e9aacf19405c3daf2b7993f55c8b8e421a.tar.lz yt-local-0c6a37e9aacf19405c3daf2b7993f55c8b8e421a.tar.xz yt-local-0c6a37e9aacf19405c3daf2b7993f55c8b8e421a.zip |
extract_items: allow extracting items that are normally dug into for more
By checking first if it's in item_types rather than checking if it can be dug into first.
For example: this allows extracting things like sectionListRenderer
Diffstat (limited to 'youtube/yt_data_extract')
-rw-r--r-- | youtube/yt_data_extract/common.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/youtube/yt_data_extract/common.py b/youtube/yt_data_extract/common.py index 3dda8eb..8d91f26 100644 --- a/youtube/yt_data_extract/common.py +++ b/youtube/yt_data_extract/common.py @@ -376,8 +376,12 @@ def extract_items_from_renderer(renderer, item_types=_item_types): # mode 2: dig into the current renderer key, value = list(renderer.items())[0] + # the renderer is an item + if key in item_types: + items.append(renderer) + # has a list in it, add it to the iter stack - if key in nested_renderer_list_dispatch: + elif key in nested_renderer_list_dispatch: renderer_list, continuation = nested_renderer_list_dispatch[key](value) if renderer_list: iter_stack.append(current_iter) @@ -390,10 +394,6 @@ def extract_items_from_renderer(renderer, item_types=_item_types): renderer = nested_renderer_dispatch[key](value) continue # don't reset renderer to None - # the renderer is an item - elif key in item_types: - items.append(renderer) - renderer = None def extract_items(response, item_types=_item_types): |