From fa633ee5bbfdaab02a53f14de8b650fd24397f6e Mon Sep 17 00:00:00 2001 From: LecygneNoir Date: Sat, 11 Jan 2020 13:27:48 +0100 Subject: [PATCH 01/13] Update files, functions and code to work with python3 --- lib/pt_upload.py | 25 ++++++++++++++----------- lib/utils.py | 7 +++---- lib/yt_upload.py | 22 +++++++++++----------- prismedia_upload.py | 8 ++++---- 4 files changed, 32 insertions(+), 30 deletions(-) diff --git a/lib/pt_upload.py b/lib/pt_upload.py index 35562b9..4701844 100644 --- a/lib/pt_upload.py +++ b/lib/pt_upload.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python # coding: utf-8 import os @@ -10,7 +10,7 @@ import pytz from os.path import splitext, basename, abspath from tzlocal import get_localzone -from ConfigParser import RawConfigParser +from configparser import RawConfigParser from requests_oauthlib import OAuth2Session from oauthlib.oauth2 import LegacyApplicationClient from requests_toolbelt.multipart.encoder import MultipartEncoder @@ -57,7 +57,7 @@ def get_default_channel(user_info): def get_channel_by_name(user_info, options): for channel in user_info["videoChannels"]: - if channel['displayName'].encode('utf8') == str(options.get('--channel')): + if channel['displayName'] == options.get('--channel'): return channel['id'] @@ -67,16 +67,17 @@ def create_channel(oauth, url, options): channel_name = utils.cleanString(str(options.get('--channel'))) # Peertube allows 20 chars max for channel name channel_name = channel_name[:19] - data = '{"name":"' + channel_name +'", \ - "displayName":"' + str(options.get('--channel')) +'", \ - "description":null}' + data = '{"name":"' + channel_name + '", \ + "displayName":"' + options.get('--channel') + '", \ + "description":null, \ + "support":null}' headers = { - 'Content-Type': "application/json" + 'Content-Type': "application/json; charset=UTF-8" } try: response = oauth.post(url + "/api/v1/video-channels/", - data=data, + data=data.encode('utf-8'), headers=headers) except Exception as e: if hasattr(e, 'message'): @@ -89,8 +90,10 @@ def create_channel(oauth, url, options): jresponse = jresponse['videoChannel'] return jresponse['id'] if response.status_code == 409: - logging.error('Peertube: Error: It seems there is a conflict with an existing channel, please beware ' - 'Peertube internal name is compiled from 20 firsts characters of channel name.' + logging.error('Peertube: Error: It seems there is a conflict with an existing channel named ' + + channel_name + '.' + ' Please beware Peertube internal name is compiled from 20 firsts characters of channel name.' + ' Also note that channel name are not case sensitive (no uppercase nor accent)' ' Please check your channel name and retry.') exit(1) else: @@ -105,7 +108,7 @@ def get_default_playlist(user_info): def get_playlist_by_name(user_playlists, options): for playlist in user_playlists["data"]: - if playlist['displayName'].encode('utf8') == str(options.get('--playlist')): + if playlist['displayName'] == options.get('--playlist'): return playlist['id'] diff --git a/lib/utils.py b/lib/utils.py index 1602ab6..0a22383 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -1,7 +1,7 @@ #!/usr/bin/python # coding: utf-8 -from ConfigParser import RawConfigParser, NoOptionError, NoSectionError +from configparser import RawConfigParser, NoOptionError, NoSectionError from os.path import dirname, splitext, basename, isfile import re from os import devnull @@ -102,7 +102,7 @@ def getLanguage(language, platform): def remove_empty_kwargs(**kwargs): good_kwargs = {} if kwargs is not None: - for key, value in kwargs.iteritems(): + for key, value in kwargs.items(): if value: good_kwargs[key] = value return good_kwargs @@ -172,7 +172,7 @@ def parseNFO(options): nfo = loadNFO(options) if nfo: # We need to check all options and replace it with the nfo value if not defined (None or False) - for key, value in options.iteritems(): + for key, value in options.items(): key = key.replace("-", "") try: # get string options @@ -192,7 +192,6 @@ def upcaseFirstLetter(s): return s[0].upper() + s[1:] def cleanString(toclean): - toclean = toclean.decode('utf-8') toclean = unidecode.unidecode(toclean) cleaned = re.sub('[^A-Za-z0-9]+', '', toclean) diff --git a/lib/yt_upload.py b/lib/yt_upload.py index 8c726c3..c618a6f 100644 --- a/lib/yt_upload.py +++ b/lib/yt_upload.py @@ -1,8 +1,8 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python # coding: utf-8 # From Youtube samples : https://raw.githubusercontent.com/youtube/api-samples/master/python/upload_video.py # noqa -import httplib +import http.client import httplib2 import random import time @@ -38,13 +38,13 @@ MAX_RETRIES = 10 RETRIABLE_EXCEPTIONS = ( IOError, httplib2.HttpLib2Error, - httplib.NotConnected, - httplib.IncompleteRead, - httplib.ImproperConnectionState, - httplib.CannotSendRequest, - httplib.CannotSendHeader, - httplib.ResponseNotReady, - httplib.BadStatusLine, + http.client.NotConnected, + http.client.IncompleteRead, + http.client.ImproperConnectionState, + http.client.CannotSendRequest, + http.client.CannotSendHeader, + http.client.ResponseNotReady, + http.client.BadStatusLine, ) RETRIABLE_STATUS_CODES = [500, 502, 503, 504] @@ -146,7 +146,7 @@ def initialize_upload(youtube, options): # Call the API's videos.insert method to create and upload the video. insert_request = youtube.videos().insert( - part=','.join(body.keys()), + part=','.join(list(body.keys())), body=body, media_body=MediaFileUpload(path, chunksize=-1, resumable=True) ) @@ -168,7 +168,7 @@ def get_playlist_by_name(youtube, playlist_name): maxResults=50 ).execute() for playlist in response["items"]: - if playlist["snippet"]['title'].encode('utf8') == str(playlist_name): + if playlist["snippet"]['title'] == playlist_name: return playlist['id'] diff --git a/prismedia_upload.py b/prismedia_upload.py index ada156d..93daa9f 100755 --- a/prismedia_upload.py +++ b/prismedia_upload.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python # coding: utf-8 """ @@ -170,17 +170,17 @@ if __name__ == '__main__': schema = Schema({ '--file': And(str, validateVideo, error='file is not supported, please use mp4'), Optional('--name'): Or(None, And( - basestring, + str, lambda x: not x.isdigit(), error="The video name should be a string") ), Optional('--description'): Or(None, And( - basestring, + str, lambda x: not x.isdigit(), error="The video description should be a string") ), Optional('--tags'): Or(None, And( - basestring, + str, lambda x: not x.isdigit(), error="Tags should be a string") ), From ee92ff3a6f8d54927541546afc652bb849c438a3 Mon Sep 17 00:00:00 2001 From: LecygneNoir Date: Sat, 11 Jan 2020 14:14:34 +0100 Subject: [PATCH 02/13] Add a requirements.txt for an easier installation of dependencies --- README.md | 13 +++++-------- requirements.txt | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 requirements.txt diff --git a/README.md b/README.md index df0664b..4aa09ac 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Prismedia -A scripting way to upload videos to peertube and youtube written in python2 +A scripting way to upload videos to Peertube and Youtube written in python3. ## Dependencies -Search in your package manager, otherwise use ``pip install --upgrade`` +Search in your package manager, or with `pip` use ``pip install -r requirements.txt`` - google-auth - google-auth-oauthlib - google-auth-httplib2 @@ -49,8 +49,6 @@ If you plan an larger usage, please consider creating your own youtube_secret fi - Save this JSON as your youtube_secret.json file. ## How To -Currently in heavy development - Support only mp4 for cross compatibility between Youtube and Peertube Simply upload a video: @@ -158,13 +156,12 @@ Languages: - [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) -- [ ] Record and forget: put the video in a directory, and the script uploads it for you -- [ ] Usable on Desktop (Linux and/or Windows and/or MacOS) -- [ ] Graphical User Interface +- [x] Usable on Desktop (Linux and/or Windows and/or MacOS) ## Compatibility -If your server uses peertube before 1.0.0-beta4, use the version inside tag 1.0.0-beta3! + - If you still use python2, use the version 0.7.1 (no more updated) + - peertube before 1.0.0-beta4, use the version inside tag 1.0.0-beta3 ## Sources inspired by [peeror](https://git.rigelk.eu/rigelk/peeror) and [youtube-upload](https://github.com/tokland/youtube-upload) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..65b335e --- /dev/null +++ b/requirements.txt @@ -0,0 +1,18 @@ +configparser +docopt +future +google-api-python-client +google-auth +google-auth-httplib2 +google-auth-oauthlib +httplib2 +oauthlib +python-magic +requests +requests-oauthlib +requests-toolbelt +schema +tzlocal +Unidecode +uritemplate +urllib3 From aafa71ce6d5934a00fbc67c153f616c030f51380 Mon Sep 17 00:00:00 2001 From: LecygneNoir Date: Sat, 11 Jan 2020 14:15:24 +0100 Subject: [PATCH 03/13] Update Changelog about python3 --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3a3c5e..00c1786 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## vX.X.X + +### Breaking changes +Now work with python 3! support of python 2 is no longer available. +You should now use python 3 in order to use prismedia + +### Features +Added a requirements.txt file to make installing requirement easier. + + ## v0.7.1 ### Fixes From 4f2a69e02541eab4d62a0c62d7f5de3414809069 Mon Sep 17 00:00:00 2001 From: Zykino Date: Sat, 18 Jan 2020 14:22:24 +0100 Subject: [PATCH 04/13] 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 05/13] 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 06/13] 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 07/13] 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 08/13] 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 09/13] 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) From 2a624e1d9bfaeaf5e3c9ece0fe225f968be90d71 Mon Sep 17 00:00:00 2001 From: LecygneNoir Date: Sun, 19 Jan 2020 10:18:25 +0100 Subject: [PATCH 10/13] Uncomment upload lines commented by error --- prismedia_upload.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/prismedia_upload.py b/prismedia_upload.py index 9c6b96e..21170b5 100755 --- a/prismedia_upload.py +++ b/prismedia_upload.py @@ -239,7 +239,7 @@ if __name__ == '__main__': 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) + 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) From 1e72033846e2963a4bf14837f6e1c26dd30c71bb Mon Sep 17 00:00:00 2001 From: LecygneNoir Date: Sun, 19 Jan 2020 11:16:14 +0100 Subject: [PATCH 11/13] Update changelog, help and readme to finish the python3 feature --- CHANGELOG.md | 7 ++++--- README.md | 14 ++++++++------ prismedia_upload.py | 8 +++----- requirements.txt | 2 +- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00c1786..100b580 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,13 @@ ## vX.X.X ### Breaking changes -Now work with python 3! support of python 2 is no longer available. +Now work with python 3! Support of python 2 is no longer available. You should now use python 3 in order to use prismedia ### Features -Added a requirements.txt file to make installing requirement easier. - + - Add a requirements.txt file to make installing requirement easier. + - Add a debug option to show some infos before uploading (thanks to @zykino) + - Now uploading to Peertube before Youtube (thanks to @zykino) ## v0.7.1 diff --git a/README.md b/README.md index 122a39c..2c9accc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Prismedia -A scripting way to upload videos to Peertube and Youtube written in python3. +Scripting your way to upload videos to peertube and youtube. Works with Python 3.5+. ## Dependencies Search in your package manager, or with `pip` use ``pip install -r requirements.txt`` @@ -14,7 +14,7 @@ Search in your package manager, or with `pip` use ``pip install -r requirements. - httplib2 - oauthlib - python-magic - - python-magic-bin + - python-magic-bin (Windows only) - requests - requests-oauthlib - requests-toolbelt @@ -92,11 +92,11 @@ Use --help to get all available options: 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 Trigger some debug information like options used (default: no) -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 (!, ', ", ?, ...) + WARN: tags with punctuation (!, ', ", ?, ...) are not supported by Mastodon to be published from Peertube - use mastodon compatibility below -c, --category=STRING Category for the videos, see below. (default: Films) --cca License should be CreativeCommon Attribution (affects Youtube upload only) -p, --privacy=STRING Choose between public, unlisted or private. (default: private) @@ -112,7 +112,6 @@ Options: --publishAt=DATE Publish the video at the given DATE using local server timezone. DATE should be on the form YYYY-MM-DDThh:mm:ss eg: 2018-03-12T19:00:00 DATE should be in the future - For Peertube, requires the "atd" and "curl utilities installed on the system --thumbnail=STRING Path to a file to use as a thumbnail for the video. Supported types are jpg and jpeg. By default, prismedia search for an image based on video name followed by .jpg or .jpeg @@ -120,7 +119,7 @@ Options: If the channel is not found, spawn an error except if --channelCreate is set. --channelCreate Create the channel if not exists. (Peertube only, default do not create) Only relevant if --channel is set. - --playlist=STRING Set the playlist to use for the video. Also known as Channel for Peertube. + --playlist=STRING Set the playlist to use for the video. If the playlist is not found, spawn an error except if --playlistCreate is set. --playlistCreate Create the playlist if not exists. (default do not create) Only relevant if --playlist is set. @@ -173,3 +172,6 @@ Languages: ## Sources inspired by [peeror](https://git.rigelk.eu/rigelk/peeror) and [youtube-upload](https://github.com/tokland/youtube-upload) + +## Contributors +Thanks to: @Zykino, @meewan, @rigelk 😘 \ No newline at end of file diff --git a/prismedia_upload.py b/prismedia_upload.py index 21170b5..3a5e4f8 100755 --- a/prismedia_upload.py +++ b/prismedia_upload.py @@ -13,12 +13,11 @@ 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) + --debug Trigger some debug information like options used (default: no) -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 (!, ', ", ?, ...) + WARN: tags with punctuation (!, ', ", ?, ...) are not supported by Mastodon to be published from Peertube - use mastodon compatibility below -c, --category=STRING Category for the videos, see below. (default: Films) --cca License should be CreativeCommon Attribution (affects Youtube upload only) -p, --privacy=STRING Choose between public, unlisted or private. (default: private) @@ -34,7 +33,6 @@ Options: --publishAt=DATE Publish the video at the given DATE using local server timezone. DATE should be on the form YYYY-MM-DDThh:mm:ss eg: 2018-03-12T19:00:00 DATE should be in the future - For Peertube, requires the "atd" and "curl utilities installed on the system --thumbnail=STRING Path to a file to use as a thumbnail for the video. Supported types are jpg and jpeg. By default, prismedia search for an image based on video name followed by .jpg or .jpeg @@ -42,7 +40,7 @@ Options: If the channel is not found, spawn an error except if --channelCreate is set. --channelCreate Create the channel if not exists. (Peertube only, default do not create) Only relevant if --channel is set. - --playlist=STRING Set the playlist to use for the video. Also known as Channel for Peertube. + --playlist=STRING Set the playlist to use for the video. If the playlist is not found, spawn an error except if --playlistCreate is set. --playlistCreate Create the playlist if not exists. (default do not create) Only relevant if --playlist is set. diff --git a/requirements.txt b/requirements.txt index e645e88..6fa06a7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,7 @@ google-auth-oauthlib httplib2 oauthlib python-magic -python-magic-bin +python-magic-bin; platform_system == "Windows" requests requests-oauthlib requests-toolbelt From 99eee2363b4dddab56c3a617d89a683f08072d75 Mon Sep 17 00:00:00 2001 From: LecygneNoir Date: Sun, 19 Jan 2020 11:26:14 +0100 Subject: [PATCH 12/13] Test if using python3 at the beginning of the script, and change shebang to do not force python3, as it enforce default python3 value and thus the check failed even if python2 is used --- prismedia_upload.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/prismedia_upload.py b/prismedia_upload.py index 3a5e4f8..c72dd6e 100755 --- a/prismedia_upload.py +++ b/prismedia_upload.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python # coding: utf-8 """ @@ -63,8 +63,11 @@ Languages: Japanese, Korean, Mandarin, Portuguese, Punjabi, Russian, Spanish """ -from os.path import dirname, realpath import sys +if sys.version_info[0] < 3: + raise Exception("Python 3 or a more recent version is required.") + +from os.path import dirname, realpath import datetime import locale import logging @@ -96,9 +99,6 @@ 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 04e5c326ee2b6bad6a95dd84fc1231be08f3505a Mon Sep 17 00:00:00 2001 From: LecygneNoir Date: Sun, 19 Jan 2020 11:30:41 +0100 Subject: [PATCH 13/13] Update version to 0.8.0 --- CHANGELOG.md | 2 +- prismedia_upload.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 100b580..3b4d2a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## vX.X.X +## v0.8.0 ### Breaking changes Now work with python 3! Support of python 2 is no longer available. diff --git a/prismedia_upload.py b/prismedia_upload.py index c72dd6e..02b9bb8 100755 --- a/prismedia_upload.py +++ b/prismedia_upload.py @@ -99,7 +99,7 @@ except ImportError: 'see https://github.com/ahupp/python-magic\n') exit(1) -VERSION = "prismedia v0.7.1" +VERSION = "prismedia v0.8.0" VALID_PRIVACY_STATUSES = ('public', 'private', 'unlisted') VALID_CATEGORIES = (