Browse Source

Merge branch 'Skylion007-master'

Arnau Sanchez 9 years ago
parent
commit
40589244e0
5 changed files with 70 additions and 6 deletions
  1. 59 0
      .gitignore
  2. 1 1
      bin/youtube-upload
  3. 1 1
      bin/youtube-upload.bat
  4. 1 1
      setup.py
  5. 8 3
      youtube_upload/lib.py

+ 59 - 0
.gitignore

@@ -0,0 +1,59 @@
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+env/
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+*.egg-info/
+.installed.cfg
+*.egg
+
+# PyInstaller
+#  Usually these files are written by a python script from a template
+#  before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*,cover
+.hypothesis/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/

+ 1 - 1
bin/youtube-upload

@@ -4,7 +4,7 @@ if __name__ == '__main__':
     
     #Allows you to a relative import from the parent folder
     import os.path, sys
-    sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))    
+    sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))    
     
     from youtube_upload import main    
     main.run()

+ 1 - 1
bin/youtube-upload.bat

@@ -1 +1 @@
-python %~dp0\youtube-upload %*
+python %~dp0youtube-upload %*

+ 1 - 1
setup.py

@@ -8,7 +8,7 @@ setup_kwargs = {
     "description": "Upload videos to Youtube",
     "author": "Arnau Sanchez",
     "author_email": "tokland@gmail.com",
-    "url": "http://code.google.com/p/youtube-upload/",
+    "url": "https://github.com/tokland/youtube-upload",
     "packages": ["youtube_upload/", "youtube_upload/auth"],
     "data_files": [("share/youtube_upload", ['client_secrets.json'])],
     "scripts": ["bin/youtube-upload"],

+ 8 - 3
youtube_upload/lib.py

@@ -29,11 +29,16 @@ def debug(obj, fd=sys.stderr):
     """Write obj to standard error."""
     try:
         unicode
+        should_encode = not isinstance(obj, unicode)
     except NameError:
-        unicode = bytes
+        should_encode = False #Doing so is harmless in Python 3
     string = str(obj.encode(get_encoding(fd), "backslashreplace")
-                 if not isinstance(obj, unicode) else obj)
-    fd.write(string + "\n")
+                 if should_encode else obj)
+    #Python 3 handling workaround
+    if sys.version_info >= (3, 0) and isinstance(string, bytes):
+        fd.buffer.write(string + "\n") #We write the encoding directly
+    else:
+        fd.write(string + "\n")
 
 def catch_exceptions(exit_codes, fun, *args, **kwargs):
     """