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

Added Python3 support #53

Merged
merged 3 commits into from
Aug 10, 2015
Merged

Added Python3 support #53

merged 3 commits into from
Aug 10, 2015

Conversation

Skylion007
Copy link
Contributor

I added Python3 support while trying to maintain Python2 support as well. The only major changes to the code base consist of adding "." to relative imports as Python3 required, modifying the decode since Python3 no longer has that feature (since everything switched to Python3) and changing a single exception's syntax. If there is anything else I need to do to add Python 3 support let me know.

@tokland
Copy link
Owner

tokland commented Aug 10, 2015

I thought the API was only python2, but no: googleapis/google-api-python-client#3.

@tokland
Copy link
Owner

tokland commented Aug 10, 2015

I couldn't make it work for Python 2.7, can you check it?

$ PYTHONPATH=. python2 bin/youtube-upload --title "Title" --playlist "Test playlist" test.mp4  
Traceback (most recent call last):
  File "bin/youtube-upload", line 9, in <module>
    from youtube_upload import main    
  File "/home/arnau/src/youtube-upload/youtube_upload/main.py", line 26, in <module>
    from . import auth
  File "/home/arnau/src/youtube-upload/youtube_upload/auth/__init__.py", line 10, in <module>
    from youtube_upload.auth import console
  File "/home/arnau/src/youtube-upload/youtube_upload/auth/console.py", line 2, in <module>
    from builtins import input
ImportError: No module named builtins

With Python 3.4.3, I get:

$ PYTHONPATH=. python bin/youtube-upload --title "Title" --playlist "Test playlist" test.mp4  
Using client secrets: /usr/share/youtube_upload/client_secrets.json
Using credentials file: /home/arnau/.youtube-upload-credentials.json
Traceback (most recent call last):
  File "bin/youtube-upload", line 10, in <module>
    main.run()
  File "/home/arnau/src/youtube-upload/youtube_upload/main.py", line 214, in run
    sys.exit(lib.catch_exceptions(EXIT_CODES, main, sys.argv[1:]))
  File "/home/arnau/src/youtube-upload/youtube_upload/lib.py", line 42, in catch_exceptions
    fun(*args, **kwargs)
  File "/home/arnau/src/youtube-upload/youtube_upload/main.py", line 211, in main
    run_main(parser, options, args)
  File "/home/arnau/src/youtube-upload/youtube_upload/main.py", line 160, in run_main
    video_id = upload_youtube_video(youtube, options, video_path, len(args), index)
  File "/home/arnau/src/youtube-upload/youtube_upload/main.py", line 95, in upload_youtube_video
    title = u(options.title)
  File "/home/arnau/src/youtube-upload/youtube_upload/lib.py", line 24, in to_utf8
    return bytes.decode(s)
TypeError: descriptor 'decode' requires a 'bytes' object but received a 'str'

@Skylion007
Copy link
Contributor Author

Interesting, it should work for Python2. I will commit a much simpler workaround. As for Python 3.4.3, I suppose that is a Unix error (with the whole Unicode vs bytes distinction in Python3). I have been testing it on Windows, so that was why Python3 failed on Linux. This should work though. If not, let me know and I'll try to fix it.

@tokland tokland merged commit 1a24d1a into tokland:master Aug 10, 2015
@tokland
Copy link
Owner

tokland commented Aug 10, 2015

It works, thx! Maybe some auxiliar funcions can be written instead of inline coding, but ok, there is always time to do that :)

@Skylion007
Copy link
Contributor Author

Might want to update the readme now that Python 3 is supported.

On Mon, Aug 10, 2015 at 1:30 PM, Arnau Sanchez [email protected]
wrote:

It works, thx! I would have written some auxiliar funcions instead of
inline coding, but ok, there is always time to do that :)


Reply to this email directly or view it on GitHub
#53 (comment)
.

@tokland
Copy link
Owner

tokland commented Aug 10, 2015

indeed: 68d643c

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.

2 participants