From 2f8274297e84e5bd9593db63e22cba4881910ecd Mon Sep 17 00:00:00 2001 From: Siarhei Siniak Date: Sat, 6 Jul 2024 23:07:57 +0300 Subject: [PATCH] [~] Refactor --- python/tasks/tiktok/utils.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/python/tasks/tiktok/utils.py b/python/tasks/tiktok/utils.py index 8f71205..aecbee0 100644 --- a/python/tasks/tiktok/utils.py +++ b/python/tasks/tiktok/utils.py @@ -7,6 +7,7 @@ from typing import ( Any, Optional, Callable, + Iterable, ) def shared_task(func: Optional[Callable[Any, Any]]=None, **kwargs: Any) -> Any: @@ -133,3 +134,21 @@ def kombu_register_json_dataclass(): content_type='application/json', content_encoding='utf-8', ) + +def grid_of_videos(paths: Iterable[str]) -> Any: + from ipywidgets import Output, GridspecLayout + from IPython import display + + grid = GridspecLayout(1, len(paths)) + + for i, filepath in enumerate(paths): + out = Output() + with out: + display.display(display.Video( + url='/files/%s' % filepath, + #embed=True + )) + + grid[0, i] = out + + return grid