aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2015-01-25 02:38:47 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2015-01-25 02:43:19 +0100
commitcfb56d1af38f3e1e0251dbd8a20e3ed8884976ff (patch)
treef6a2d49083150cc057649c1f923c510a8acd0be1 /youtube_dl/utils.py
parent1e108029907ca28b75f37d2cf0bf25bcabbfbdac (diff)
downloadyoutube-dl-cfb56d1af38f3e1e0251dbd8a20e3ed8884976ff.tar.xz
Add --list-thumbnails
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index d22b03134..b8c52af74 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -1659,3 +1659,11 @@ def determine_protocol(info_dict):
return 'f4m'
return compat_urllib_parse_urlparse(url).scheme
+
+
+def render_table(header_row, data):
+ """ Render a list of rows, each as a list of values """
+ table = [header_row] + data
+ max_lens = [max(len(compat_str(v)) for v in col) for col in zip(*table)]
+ format_str = ' '.join('%-' + compat_str(ml + 1) + 's' for ml in max_lens[:-1]) + '%s'
+ return '\n'.join(format_str % tuple(row) for row in table)