Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle bytes when listing fonts in VideoClip.py #306

Merged
2 commits merged into from
Feb 22, 2017
Merged

Conversation

Zowie
Copy link
Contributor

@Zowie Zowie commented Jul 18, 2016

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 <listcomp>
    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.

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 <listcomp>
    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.
@mbeacom
Copy link
Collaborator

mbeacom commented Jan 30, 2017

@Zowie Hello Zowie! Thank you for the PR! Were you able to successfully test this on Python 2.x ?

@ghost
Copy link

ghost commented Feb 21, 2017

@mbeacom this does work on python2, but list('color') gives the same error. I'd modify the pull request source code, but I don't have access to do that.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modify line 1207 so that it contains:

            return [l.split(b" ")[0] for l in lines[2:]]
        else:
            raise Exception("Moviepy:Error! Argument must equal "
                            "'font' or 'color'")

@ghost
Copy link

ghost commented Feb 22, 2017

If we don't get a response from @Zowie in the new few days, I'll make another PR with the corrections I suggested.

@Zowie
Copy link
Contributor Author

Zowie commented Feb 22, 2017

Hi! Sorry for the late reply! @Earney I added your code to line 1207 :-)

@ghost
Copy link

ghost commented Feb 22, 2017

@Zowie .. awesome, I'll try to get this PR in the repo, ASAP.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes made!

@ghost
Copy link

ghost commented Feb 22, 2017

@mbeacom @Zulko this PR looks good to me. Any recommendations from you before we push this to the repo?

@Zulko
Copy link
Owner

Zulko commented Feb 22, 2017

If you're sure this works with python 2 and 3, then it's good for me.

@ghost
Copy link

ghost commented Feb 22, 2017

I will double check before pushing to the repo.

@ghost ghost merged commit df31c03 into Zulko:master Feb 22, 2017
tburrows13 pushed a commit to tburrows13/moviepy that referenced this pull request Feb 27, 2017
* Fixed copy-paste typo

Changed documentation for the color parameter to distinguish from bg_color

* Fixed missing list

(using python 3)

* fixed module hierarchy for Trajectory

* fixed addy

* small recipe

* on_color function docstring has wrong parameter

The docstring for the on_color method has a parameter of bg_color but
the function uses color as the parameter.

* Update README.rst

Changed Code Block to use Python Syntax Highlighting

* fix deprecation message

currently, the docstring is nonsense. 

```
The function ``concatenate_videoclips`` is deprecated and is kept temporarily for backwards compatibility.
Please use the new name, ``concatenate_videoclips``, instead.
```

* ImageSequenceClip: Check for fps and durations rather than fps and duration

* Add a test case.

* Add another test

* ensures int arguments to np.reshape; closes Zulko#383

* fix issue Zulko#401

*  fix issue Zulko#335

* Update maintainer section in README

* make concatenate_videoclips Python 3 compatible..  fix issue Zulko#313

* Increment release version

* CompositeVideoClip doesn't accept an argument of transparent

* move PY3 variable to compat.py

* fix movie => moviepy typo

* fix issue Zulko#341

* Fixed typo Zulko#375

Zulko#375 fixed

* fix issue Zulko#357, which makes real problem more obvious (media file does not exist

* Revert "small recipe (mirroring a video)"

* Fixed indentation

* .gitignore ignore Mac-specific files, Jetbrains settings dir

* README.rst make mention of Gitter, add PyPI and Gitter badge

* README.rst wording, formatting

* README.rst structure link targets, add co-maintainers (with @username)

* README.rst move maintainers, contributing sections; change docs x-reference name

* README.rst fix grammar

* fix issue 145.  raise Exception when concatenate method != chain or compose

* make PEP8 compatible

* fix PR Zulko#413 . (issue Zulko#357)

* create test for issue Zulko#145

* add tests/media to .gitignore

* fix Issue Zulko#385 ,  no DirectoryClip class (Zulko#434)

* fix issue Zulko#385 , no DirectoryClip class

* replace DirectoryClip with ImageSequenceClip

* fix issue 417, unicode has no attribute 'shape' error.

* add test for issue 417

* add test for issue 417

* Fixed resize documentation issue Zulko#319 (Zulko#346)

* Handle bytes when listing fonts in VideoClip.py (Zulko#306)

Handle bytes when listing fonts in VideoClip.py

* add test for PR306

* add test for PR306 (Zulko#440)

* create test file for pull requests (Zulko#433)

* Test issue 407 (video has a valid fps after concatenate function) (Zulko#443)

* Move PR test to test_PR.py file (Zulko#444)

* move PR test from test_issues.py to test_PR.py

* add code to download python_logo.png

* remove duplicate test_issue_417 function

* add testing with travis-ci (Zulko#447)

added testing via travis-ci

* put DEVNULL into compat.py (Zulko#432)

* add travis-ci badge to readme file

* pick highest fps when concatenating (Zulko#416)

* readers.py cast chunksize from float to int

* choose highest fps of clips when concatenating

* pick highest fps when concatenating

* pick highest fps when concatenating

* fps either max or none

* remove resolve markers

removed resolve markers such as HEAD, etc so that the file will compile correctly.
Remove some double blank lines, etc

* update concatenate.py; add c.fps is not None

* add test for issue 416

* fix test_issue_416
tburrows13 pushed a commit to tburrows13/moviepy that referenced this pull request Feb 27, 2017
* Fixed copy-paste typo

Changed documentation for the color parameter to distinguish from bg_color

* Fixed missing list

(using python 3)

* fixed module hierarchy for Trajectory

* fixed addy

* small recipe

* on_color function docstring has wrong parameter

The docstring for the on_color method has a parameter of bg_color but
the function uses color as the parameter.

* Update README.rst

Changed Code Block to use Python Syntax Highlighting

* fix deprecation message

currently, the docstring is nonsense. 

```
The function ``concatenate_videoclips`` is deprecated and is kept temporarily for backwards compatibility.
Please use the new name, ``concatenate_videoclips``, instead.
```

* ImageSequenceClip: Check for fps and durations rather than fps and duration

* Add a test case.

* Add another test

* ensures int arguments to np.reshape; closes Zulko#383

* fix issue Zulko#401

*  fix issue Zulko#335

* Update maintainer section in README

* make concatenate_videoclips Python 3 compatible..  fix issue Zulko#313

* Increment release version

* CompositeVideoClip doesn't accept an argument of transparent

* move PY3 variable to compat.py

* fix movie => moviepy typo

* fix issue Zulko#341

* Fixed typo Zulko#375

Zulko#375 fixed

* fix issue Zulko#357, which makes real problem more obvious (media file does not exist

* Revert "small recipe (mirroring a video)"

* Fixed indentation

* .gitignore ignore Mac-specific files, Jetbrains settings dir

* README.rst make mention of Gitter, add PyPI and Gitter badge

* README.rst wording, formatting

* README.rst structure link targets, add co-maintainers (with @username)

* README.rst move maintainers, contributing sections; change docs x-reference name

* README.rst fix grammar

* fix issue 145.  raise Exception when concatenate method != chain or compose

* make PEP8 compatible

* fix PR Zulko#413 . (issue Zulko#357)

* create test for issue Zulko#145

* add tests/media to .gitignore

* fix Issue Zulko#385 ,  no DirectoryClip class (Zulko#434)

* fix issue Zulko#385 , no DirectoryClip class

* replace DirectoryClip with ImageSequenceClip

* fix issue 417, unicode has no attribute 'shape' error.

* add test for issue 417

* add test for issue 417

* Fixed resize documentation issue Zulko#319 (Zulko#346)

* Handle bytes when listing fonts in VideoClip.py (Zulko#306)

Handle bytes when listing fonts in VideoClip.py

* add test for PR306

* add test for PR306 (Zulko#440)

* create test file for pull requests (Zulko#433)

* Test issue 407 (video has a valid fps after concatenate function) (Zulko#443)

* Move PR test to test_PR.py file (Zulko#444)

* move PR test from test_issues.py to test_PR.py

* add code to download python_logo.png

* remove duplicate test_issue_417 function

* add testing with travis-ci (Zulko#447)

added testing via travis-ci

* put DEVNULL into compat.py (Zulko#432)

* add travis-ci badge to readme file

* pick highest fps when concatenating (Zulko#416)

* readers.py cast chunksize from float to int

* choose highest fps of clips when concatenating

* pick highest fps when concatenating

* pick highest fps when concatenating

* fps either max or none

* remove resolve markers

removed resolve markers such as HEAD, etc so that the file will compile correctly.
Remove some double blank lines, etc

* update concatenate.py; add c.fps is not None

* add test for issue 416

* fix test_issue_416
tburrows13 pushed a commit that referenced this pull request Mar 2, 2017
* Changed the `col` paramater of `ColorClip` to `color` and added a DeprecationWarning if the users tries to use `col`

* Update VideoFileClip.py

* Added warnings

* Update (#3)

* Fixed copy-paste typo

Changed documentation for the color parameter to distinguish from bg_color

* Fixed missing list

(using python 3)

* fixed module hierarchy for Trajectory

* fixed addy

* small recipe

* on_color function docstring has wrong parameter

The docstring for the on_color method has a parameter of bg_color but
the function uses color as the parameter.

* Update README.rst

Changed Code Block to use Python Syntax Highlighting

* fix deprecation message

currently, the docstring is nonsense. 

```
The function ``concatenate_videoclips`` is deprecated and is kept temporarily for backwards compatibility.
Please use the new name, ``concatenate_videoclips``, instead.
```

* ImageSequenceClip: Check for fps and durations rather than fps and duration

* Add a test case.

* Add another test

* ensures int arguments to np.reshape; closes #383

* fix issue #401

*  fix issue #335

* Update maintainer section in README

* make concatenate_videoclips Python 3 compatible..  fix issue #313

* Increment release version

* CompositeVideoClip doesn't accept an argument of transparent

* move PY3 variable to compat.py

* fix movie => moviepy typo

* fix issue #341

* Fixed typo #375

#375 fixed

* fix issue #357, which makes real problem more obvious (media file does not exist

* Revert "small recipe (mirroring a video)"

* Fixed indentation

* .gitignore ignore Mac-specific files, Jetbrains settings dir

* README.rst make mention of Gitter, add PyPI and Gitter badge

* README.rst wording, formatting

* README.rst structure link targets, add co-maintainers (with @username)

* README.rst move maintainers, contributing sections; change docs x-reference name

* README.rst fix grammar

* fix issue 145.  raise Exception when concatenate method != chain or compose

* make PEP8 compatible

* fix PR #413 . (issue #357)

* create test for issue #145

* add tests/media to .gitignore

* fix Issue #385 ,  no DirectoryClip class (#434)

* fix issue #385 , no DirectoryClip class

* replace DirectoryClip with ImageSequenceClip

* fix issue 417, unicode has no attribute 'shape' error.

* add test for issue 417

* add test for issue 417

* Fixed resize documentation issue #319 (#346)

* Handle bytes when listing fonts in VideoClip.py (#306)

Handle bytes when listing fonts in VideoClip.py

* add test for PR306

* add test for PR306 (#440)

* create test file for pull requests (#433)

* Test issue 407 (video has a valid fps after concatenate function) (#443)

* Move PR test to test_PR.py file (#444)

* move PR test from test_issues.py to test_PR.py

* add code to download python_logo.png

* remove duplicate test_issue_417 function

* add testing with travis-ci (#447)

added testing via travis-ci

* put DEVNULL into compat.py (#432)

* add travis-ci badge to readme file

* pick highest fps when concatenating (#416)

* readers.py cast chunksize from float to int

* choose highest fps of clips when concatenating

* pick highest fps when concatenating

* pick highest fps when concatenating

* fps either max or none

* remove resolve markers

removed resolve markers such as HEAD, etc so that the file will compile correctly.
Remove some double blank lines, etc

* update concatenate.py; add c.fps is not None

* add test for issue 416

* fix test_issue_416

* Update Gloin (#4)

* Fixed copy-paste typo

Changed documentation for the color parameter to distinguish from bg_color

* Fixed missing list

(using python 3)

* fixed module hierarchy for Trajectory

* fixed addy

* small recipe

* on_color function docstring has wrong parameter

The docstring for the on_color method has a parameter of bg_color but
the function uses color as the parameter.

* Update README.rst

Changed Code Block to use Python Syntax Highlighting

* fix deprecation message

currently, the docstring is nonsense. 

```
The function ``concatenate_videoclips`` is deprecated and is kept temporarily for backwards compatibility.
Please use the new name, ``concatenate_videoclips``, instead.
```

* ImageSequenceClip: Check for fps and durations rather than fps and duration

* Add a test case.

* Add another test

* ensures int arguments to np.reshape; closes #383

* fix issue #401

*  fix issue #335

* Update maintainer section in README

* make concatenate_videoclips Python 3 compatible..  fix issue #313

* Increment release version

* CompositeVideoClip doesn't accept an argument of transparent

* move PY3 variable to compat.py

* fix movie => moviepy typo

* fix issue #341

* Fixed typo #375

#375 fixed

* fix issue #357, which makes real problem more obvious (media file does not exist

* Revert "small recipe (mirroring a video)"

* Fixed indentation

* .gitignore ignore Mac-specific files, Jetbrains settings dir

* README.rst make mention of Gitter, add PyPI and Gitter badge

* README.rst wording, formatting

* README.rst structure link targets, add co-maintainers (with @username)

* README.rst move maintainers, contributing sections; change docs x-reference name

* README.rst fix grammar

* fix issue 145.  raise Exception when concatenate method != chain or compose

* make PEP8 compatible

* fix PR #413 . (issue #357)

* create test for issue #145

* add tests/media to .gitignore

* fix Issue #385 ,  no DirectoryClip class (#434)

* fix issue #385 , no DirectoryClip class

* replace DirectoryClip with ImageSequenceClip

* fix issue 417, unicode has no attribute 'shape' error.

* add test for issue 417

* add test for issue 417

* Fixed resize documentation issue #319 (#346)

* Handle bytes when listing fonts in VideoClip.py (#306)

Handle bytes when listing fonts in VideoClip.py

* add test for PR306

* add test for PR306 (#440)

* create test file for pull requests (#433)

* Test issue 407 (video has a valid fps after concatenate function) (#443)

* Move PR test to test_PR.py file (#444)

* move PR test from test_issues.py to test_PR.py

* add code to download python_logo.png

* remove duplicate test_issue_417 function

* add testing with travis-ci (#447)

added testing via travis-ci

* put DEVNULL into compat.py (#432)

* add travis-ci badge to readme file

* pick highest fps when concatenating (#416)

* readers.py cast chunksize from float to int

* choose highest fps of clips when concatenating

* pick highest fps when concatenating

* pick highest fps when concatenating

* fps either max or none

* remove resolve markers

removed resolve markers such as HEAD, etc so that the file will compile correctly.
Remove some double blank lines, etc

* update concatenate.py; add c.fps is not None

* add test for issue 416

* fix test_issue_416

* Update VideoFileClip.py

* Added test

* Added return for PEP 8 compliance

* Change
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants