From 08d461aa48c08a0f6e5410b600688387d87e9027 Mon Sep 17 00:00:00 2001 From: Zowie Date: Mon, 18 Jul 2016 14:07:24 +0200 Subject: [PATCH 1/2] Handle bytes when listing fonts in VideoClip.py I got a `TypeError` when calling `TextClip.list('font')`: ``` File "/Users/me/.virtualenvs/project/lib/python3.4/site-packages/moviepy/video/VideoClip.py", line 1177, in return [l.decode('UTF-8')[8:] for l in lines if l.startswith(" Font:")] TypeError: startswith first arg must be bytes or a tuple of bytes, not str ``` So now I'm just passing `bytes` to the `startswith` function as it's operating on bytes. Then decoding to `UTF-8` before it's returned. If I need to do anything else, let me know :) This was just a quickfix. --- moviepy/video/VideoClip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py index bcc6bb2bb..3ffead24c 100644 --- a/moviepy/video/VideoClip.py +++ b/moviepy/video/VideoClip.py @@ -1202,7 +1202,7 @@ def list(arg): lines = result.splitlines() if arg == 'font': - return [l[8:] for l in lines if l.startswith(" Font:")] + return [l.decode('UTF-8')[8:] for l in lines if l.startswith(b" Font:")] elif arg == 'color': return [l.split(" ")[1] for l in lines[2:]] From fb0233e5113a4fa659b5ad44d5bb8e74adcc4cbb Mon Sep 17 00:00:00 2001 From: Zowie Date: Wed, 22 Feb 2017 19:00:57 +0100 Subject: [PATCH 2/2] Apply changes requested in PR conversation --- moviepy/video/VideoClip.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/moviepy/video/VideoClip.py b/moviepy/video/VideoClip.py index 3ffead24c..0242f125c 100644 --- a/moviepy/video/VideoClip.py +++ b/moviepy/video/VideoClip.py @@ -1204,7 +1204,10 @@ def list(arg): if arg == 'font': return [l.decode('UTF-8')[8:] for l in lines if l.startswith(b" Font:")] elif arg == 'color': - return [l.split(" ")[1] for l in lines[2:]] + return [l.split(b" ")[0] for l in lines[2:]] + else: + raise Exception("Moviepy:Error! Argument must equal " + "'font' or 'color'") @staticmethod def search(string, arg):