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