From 3797c9a9f09a4bebf4f7878aae962df78320713e Mon Sep 17 00:00:00 2001 From: LecygneNoir Date: Sat, 9 Mar 2019 10:34:18 +0100 Subject: [PATCH 1/2] Remove mt option as it's not useful anymore --- CHANGELOG.md | 5 +++++ lib/pt_upload.py | 3 --- nfo_example.txt | 1 - prismedia_upload.py | 7 ++----- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 324f507..a507abd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## v0.6.1-1 Hotfix +This fix prepares the python3 compatibility + + - Remove mastodon tags (mt) options as it's deprecated. Compatibility between Peertube and Mastodon is complete. + ## v0.6.1 ### Fixes diff --git a/lib/pt_upload.py b/lib/pt_upload.py index d852e00..ad0a36a 100644 --- a/lib/pt_upload.py +++ b/lib/pt_upload.py @@ -135,9 +135,6 @@ def upload_video(oauth, secret, options): if len(strtag) >= 30: logging.warning("Peertube: Sorry, Peertube does not support tag with more than 30 characters, please reduce your tag size") exit(1) - # If Mastodon compatibility is enabled, clean tags from special characters - if options.get('--mt'): - strtag = utils.cleanString(strtag) fields.append(("tags", strtag)) if options.get('--category'): diff --git a/nfo_example.txt b/nfo_example.txt index 9a3890d..5fcfc51 100644 --- a/nfo_example.txt +++ b/nfo_example.txt @@ -12,7 +12,6 @@ description = Your complete video description should be wrote with a blank space at the beginning of the line :) tags = list of tags, comma separated -mt = True category = Films cca = True privacy = private diff --git a/prismedia_upload.py b/prismedia_upload.py index a300c96..ba86b86 100755 --- a/prismedia_upload.py +++ b/prismedia_upload.py @@ -6,7 +6,7 @@ prismedia_upload - tool to upload videos to Peertube and Youtube Usage: prismedia_upload.py --file= [options] - prismedia_upload.py -f --tags=STRING [--mt options] + prismedia_upload.py -f --tags=STRING [options] prismedia_upload.py -h | --help prismedia_upload.py --version @@ -18,8 +18,6 @@ Options: WARN: tags with space and special characters (!, ', ", ?, ...) are not supported by Mastodon to be published from Peertube use mastodon compatibility below - --mt Force Mastodon compatibility for tags (drop every incompatible characters inside tags) - This option requires --tags -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) @@ -94,7 +92,7 @@ except ImportError: 'see https://github.com/ahupp/python-magic\n') exit(1) -VERSION = "prismedia v0.6.1" +VERSION = "prismedia v0.6.1-1" VALID_PRIVACY_STATUSES = ('public', 'private', 'unlisted') VALID_CATEGORIES = ( @@ -187,7 +185,6 @@ if __name__ == '__main__': lambda x: not x.isdigit(), error="Tags should be a string") ), - Optional('--mt'): bool, Optional('--category'): Or(None, And( str, validateCategory, From 2f40ef1826c4c4701f9b316cf6549798c72b2b79 Mon Sep 17 00:00:00 2001 From: LecygneNoir Date: Sat, 9 Mar 2019 11:34:57 +0100 Subject: [PATCH 2/2] Simplify cleanString function to prepare python3 compatibility --- lib/utils.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/utils.py b/lib/utils.py index 772ff6b..63083b0 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -3,9 +3,10 @@ from ConfigParser import RawConfigParser, NoOptionError, NoSectionError from os.path import dirname, splitext, basename, isfile +import re from os import devnull from subprocess import check_call, CalledProcessError, STDOUT -import unicodedata +import unidecode import logging ### CATEGORIES ### @@ -195,16 +196,8 @@ def upcaseFirstLetter(s): def cleanString(toclean): - toclean = toclean.split(' ') - cleaned = '' - for s in toclean: - if s == '': - continue - strtoclean = unicodedata.normalize('NFKD', unicode (s, 'utf-8')).encode('ASCII', 'ignore') - strtoclean = ''.join(e for e in strtoclean if e.isalnum()) - if strtoclean == '': - continue - strtoclean = upcaseFirstLetter(strtoclean) - cleaned = cleaned + strtoclean + toclean = toclean.decode('utf-8') + toclean = unidecode.unidecode(toclean) + cleaned = re.sub('[^A-Za-z0-9]+', '', toclean) return cleaned