aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/yt_data_extract/common.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2019-12-19 20:12:37 -0800
committerJames Taylor <user234683@users.noreply.github.com>2019-12-19 20:12:37 -0800
commit4a3529df9577b660a2f493ab63ef08f10320b38e (patch)
tree8867f9a46d639349aa756dccf2e28194cb43448e /youtube/yt_data_extract/common.py
parentd1d908d5b1aadb0dc75b25df1a47789c021f89e2 (diff)
downloadyt-local-4a3529df9577b660a2f493ab63ef08f10320b38e.tar.lz
yt-local-4a3529df9577b660a2f493ab63ef08f10320b38e.tar.xz
yt-local-4a3529df9577b660a2f493ab63ef08f10320b38e.zip
Extraction: Move stuff around in files and put underscores in front of internal helper function names
Move get_captions_url in watch_extraction to bottom next to other exported, public functions
Diffstat (limited to 'youtube/yt_data_extract/common.py')
-rw-r--r--youtube/yt_data_extract/common.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/youtube/yt_data_extract/common.py b/youtube/yt_data_extract/common.py
index 459b5e9..4681a86 100644
--- a/youtube/yt_data_extract/common.py
+++ b/youtube/yt_data_extract/common.py
@@ -322,7 +322,7 @@ item_types = {
'channelAboutFullMetadataRenderer',
}
-def traverse_browse_renderer(renderer):
+def _traverse_browse_renderer(renderer):
for tab in get(renderer, 'tabs', (), types=(list, tuple)):
tab_renderer = multi_deep_get(tab, ['tabRenderer'], ['expandableTabRenderer'], default=None, types=dict)
if tab_renderer is None:
@@ -332,24 +332,24 @@ def traverse_browse_renderer(renderer):
print('Could not find tab with content')
return {}
-def traverse_standard_list(renderer):
+def _traverse_standard_list(renderer):
renderer_list = multi_deep_get(renderer, ['contents'], ['items'], default=(), types=(list, tuple))
continuation = deep_get(renderer, 'continuations', 0, 'nextContinuationData', 'continuation')
return renderer_list, continuation
# these renderers contain one inside them
nested_renderer_dispatch = {
- 'singleColumnBrowseResultsRenderer': traverse_browse_renderer,
- 'twoColumnBrowseResultsRenderer': traverse_browse_renderer,
+ 'singleColumnBrowseResultsRenderer': _traverse_browse_renderer,
+ 'twoColumnBrowseResultsRenderer': _traverse_browse_renderer,
'twoColumnSearchResultsRenderer': lambda renderer: get(renderer, 'primaryContents', {}, types=dict),
}
# these renderers contain a list of renderers inside them
nested_renderer_list_dispatch = {
- 'sectionListRenderer': traverse_standard_list,
- 'itemSectionRenderer': traverse_standard_list,
- 'gridRenderer': traverse_standard_list,
- 'playlistVideoListRenderer': traverse_standard_list,
+ 'sectionListRenderer': _traverse_standard_list,
+ 'itemSectionRenderer': _traverse_standard_list,
+ 'gridRenderer': _traverse_standard_list,
+ 'playlistVideoListRenderer': _traverse_standard_list,
'singleColumnWatchNextResults': lambda r: (deep_get(r, 'results', 'results', 'contents', default=[], types=(list, tuple)), None),
}
@@ -411,6 +411,5 @@ def extract_items(response, item_types=item_types):
current_iter = iter_stack.pop() # go back up the stack
except IndexError:
return items, ctoken
-
else:
return [], None