From 4f2a69e02541eab4d62a0c62d7f5de3414809069 Mon Sep 17 00:00:00 2001 From: Zykino Date: Sat, 18 Jan 2020 14:22:24 +0100 Subject: [PATCH 1/6] Add the binaries for the lib needed on Windows --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 65b335e..e645e88 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,7 @@ google-auth-oauthlib httplib2 oauthlib python-magic +python-magic-bin requests requests-oauthlib requests-toolbelt From aa7aeed688c7b96f4374e5bfe82e4b29946fcd1a Mon Sep 17 00:00:00 2001 From: Zykino Date: Sat, 18 Jan 2020 14:51:45 +0100 Subject: [PATCH 2/6] Force the use of at least Python 3 --- prismedia_upload.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/prismedia_upload.py b/prismedia_upload.py index 93daa9f..4d9ec53 100755 --- a/prismedia_upload.py +++ b/prismedia_upload.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # coding: utf-8 """ @@ -97,6 +97,9 @@ except ImportError: 'see https://github.com/ahupp/python-magic\n') exit(1) +if sys.version_info[0] < 3: + raise Exception("Python 3 or a more recent version is required.") + VERSION = "prismedia v0.7.1" VALID_PRIVACY_STATUSES = ('public', 'private', 'unlisted') From 8c997478987e411cfac1678a42b81c1ece2ea41d Mon Sep 17 00:00:00 2001 From: Zykino Date: Sat, 18 Jan 2020 14:53:32 +0100 Subject: [PATCH 3/6] Remove the CLI input decoding --- lib/utils.py | 14 -------------- prismedia_upload.py | 1 - 2 files changed, 15 deletions(-) diff --git a/lib/utils.py b/lib/utils.py index 0a22383..94acfcd 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -196,17 +196,3 @@ def cleanString(toclean): cleaned = re.sub('[^A-Za-z0-9]+', '', toclean) return cleaned - -def decodeArgumentStrings(options, encoding): - # Python crash when decoding from UTF-8 to UTF-8, so we prevent this - if "utf-8" == encoding.lower(): - return; - - if options["--name"] is not None: - options["--name"] = options["--name"].decode(encoding) - - if options["--description"] is not None: - options["--description"] = options["--description"].decode(encoding) - - if options["--tags"] is not None: - options["--tags"] = options["--tags"].decode(encoding) diff --git a/prismedia_upload.py b/prismedia_upload.py index 4d9ec53..5c7c99f 100755 --- a/prismedia_upload.py +++ b/prismedia_upload.py @@ -223,7 +223,6 @@ if __name__ == '__main__': '--version': bool }) - utils.decodeArgumentStrings(options, locale.getpreferredencoding()) options = utils.parseNFO(options) if not options.get('--thumbnail'): From e94b48278aaff8588d2394e045dcf47468f4d660 Mon Sep 17 00:00:00 2001 From: Zykino Date: Sat, 18 Jan 2020 15:12:50 +0100 Subject: [PATCH 4/6] Force the NFO parsing to read as UTF-8 --- lib/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/utils.py b/lib/utils.py index 94acfcd..fca5f51 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -132,7 +132,7 @@ def loadNFO(options): logging.info("Using " + options.get('--nfo') + " as NFO, loading...") if isfile(options.get('--nfo')): nfo = RawConfigParser() - nfo.read(options.get('--nfo')) + nfo.read(options.get('--nfo'), encoding='utf-8') return nfo else: logging.error("Given NFO file does not exist, please check your path.") @@ -147,7 +147,7 @@ def loadNFO(options): try: logging.info("Using " + nfo_file + " as NFO, loading...") nfo = RawConfigParser() - nfo.read(nfo_file) + nfo.read(nfo_file, encoding='utf-8') return nfo except Exception as e: logging.error("Problem with NFO file: " + str(e)) @@ -160,7 +160,7 @@ def loadNFO(options): try: logging.info("Using " + nfo_file + " as NFO, loading...") nfo = RawConfigParser() - nfo.read(nfo_file) + nfo.read(nfo_file, encoding='utf-8') return nfo except Exception as e: logging.error("Problem with nfo file: " + str(e)) From 591ed0ab80a47768fc82d63d8d6cef123a683bdf Mon Sep 17 00:00:00 2001 From: Zykino Date: Sat, 18 Jan 2020 15:16:39 +0100 Subject: [PATCH 5/6] Fix some the README: sync the dependency list with requirements.txt --- README.md | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 4aa09ac..122a39c 100644 --- a/README.md +++ b/README.md @@ -4,17 +4,25 @@ A scripting way to upload videos to Peertube and Youtube written in python3. ## Dependencies Search in your package manager, or with `pip` use ``pip install -r requirements.txt`` + - configparser + - docopt + - future + - google-api-python-client - google-auth - - google-auth-oauthlib - google-auth-httplib2 - - google-api-python-client - - docopt - - schema + - google-auth-oauthlib + - httplib2 + - oauthlib - python-magic - python-magic-bin + - requests + - requests-oauthlib - requests-toolbelt + - schema - tzlocal - - unidecode + - Unidecode + - uritemplate + - urllib3 ## Configuration @@ -39,14 +47,14 @@ Prismedia will try to use this file at each launch, and re-ask for authenticatio The default youtube_secret.json should allow you to upload some videos. If you plan an larger usage, please consider creating your own youtube_secret file: -- Go to the [Google console](https://console.developers.google.com/). -- Create project. -- Side menu: APIs & auth -> APIs -- Top menu: Enabled API(s): Enable all Youtube APIs. -- Side menu: APIs & auth -> Credentials. -- Create a Client ID: Add credentials -> OAuth 2.0 Client ID -> Other -> Name: prismedia1 -> Create -> OK -- Download JSON: Under the section "OAuth 2.0 client IDs". Save the file to your local system. -- Save this JSON as your youtube_secret.json file. + - Go to the [Google console](https://console.developers.google.com/). + - Create project. + - Side menu: APIs & auth -> APIs + - Top menu: Enabled API(s): Enable all Youtube APIs. + - Side menu: APIs & auth -> Credentials. + - Create a Client ID: Add credentials -> OAuth 2.0 Client ID -> Other -> Name: prismedia1 -> Create -> OK + - Download JSON: Under the section "OAuth 2.0 client IDs". Save the file to your local system. + - Save this JSON as your youtube_secret.json file. ## How To Support only mp4 for cross compatibility between Youtube and Peertube @@ -153,7 +161,7 @@ Languages: - [x] add videos to playlist - [x] create playlist - [x] schedule your video with publishAt - - [x] combine channel and playlist (Peertube only as channel is Peertube feature). See [issue 40](https://git.lecygnenoir.info/LecygneNoir/prismedia/issues/40 for detailed usage. + - [x] combine channel and playlist (Peertube only as channel is Peertube feature). See [issue 40](https://git.lecygnenoir.info/LecygneNoir/prismedia/issues/40) for detailed usage. - [x] Use a config file (NFO) file to retrieve videos arguments - [x] Allow to choose peertube or youtube upload (to resume failed upload for example) - [x] Usable on Desktop (Linux and/or Windows and/or MacOS) From 77bcda7a79524c1d2b6f0dc1c0ebdf775fb0c968 Mon Sep 17 00:00:00 2001 From: Zykino Date: Sat, 18 Jan 2020 15:51:42 +0100 Subject: [PATCH 6/6] Add a debug option. Upload to Peertube before Youtube. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An upload to Peertube may be slower or have a slower encoding on the server. Also why not give a preference to the open source host. As it won’t slow Youtube only uploads. --- prismedia_upload.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/prismedia_upload.py b/prismedia_upload.py index 5c7c99f..9c6b96e 100755 --- a/prismedia_upload.py +++ b/prismedia_upload.py @@ -13,6 +13,7 @@ Usage: Options: -f, --file=STRING Path to the video file to upload in mp4 --name=NAME Name of the video to upload. (default to video filename) + --debug Show some debug informations like the option actually used (default: no debug info) -d, --description=STRING Description of the video. (default: default description) -t, --tags=STRING Tags for the video. comma separated. WARN: tags with space and special characters (!, ', ", ?, ...) @@ -110,7 +111,7 @@ VALID_CATEGORIES = ( "how to", "education", "activism", "science & technology", "science", "technology", "animals" ) -VALID_PLATFORM = ('youtube', 'peertube') +VALID_PLATFORM = ('youtube', 'peertube', 'none') VALID_LANGUAGES = ('arabic', 'english', 'french', 'german', 'hindi', 'italian', 'japanese', 'korean', 'mandarin', @@ -209,6 +210,7 @@ if __name__ == '__main__': validatePublish, error="DATE should be the form YYYY-MM-DDThh:mm:ss and has to be in the future") ), + Optional('--debug'): bool, Optional('--cca'): bool, Optional('--disable-comments'): bool, Optional('--nsfw'): bool, @@ -233,7 +235,11 @@ if __name__ == '__main__': except SchemaError as e: exit(e) - if options.get('--platform') is None or "youtube" in options.get('--platform'): - yt_upload.run(options) - if options.get('--platform') is None or "peertube" in options.get('--platform'): - pt_upload.run(options) + if options.get('--debug'): + print(sys.version) + print(options) + + #if options.get('--platform') is None or "peertube" in options.get('--platform'): + # pt_upload.run(options) + #if options.get('--platform') is None or "youtube" in options.get('--platform'): + # yt_upload.run(options)