mirror of
https://git.lecygnenoir.info/LecygneNoir/prismedia.git
synced 2025-10-03 09:29:16 +02:00
Patch playlist to be comaptible with beta16 (using name AND display name)
This commit is contained in:
parent
2565071e40
commit
d3a42c4be1
2 changed files with 15 additions and 14 deletions
|
@ -64,7 +64,8 @@ def get_playlist_by_name(user_info, options):
|
||||||
def create_playlist(oauth, url, options):
|
def create_playlist(oauth, url, options):
|
||||||
template = ('Peertube: Playlist %s does not exist, creating it.')
|
template = ('Peertube: Playlist %s does not exist, creating it.')
|
||||||
logging.info(template % (str(options.get('--playlist'))))
|
logging.info(template % (str(options.get('--playlist'))))
|
||||||
data = '{"displayName":"' + str(options.get('--playlist')) +'", \
|
data = '{"name":"' + utils.cleanString(str(options.get('--playlist'))) +'", \
|
||||||
|
"displayName":"' + str(options.get('--playlist')) +'", \
|
||||||
"description":null}'
|
"description":null}'
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
|
@ -101,7 +102,7 @@ def upload_video(oauth, secret, options):
|
||||||
mimetypes.types_map[splitext(path)[1]])
|
mimetypes.types_map[splitext(path)[1]])
|
||||||
|
|
||||||
path = options.get('--file')
|
path = options.get('--file')
|
||||||
url = secret.get('peertube', 'peertube_url')
|
url = str(secret.get('peertube', 'peertube_url')).rstrip('/')
|
||||||
user_info = get_userinfo()
|
user_info = get_userinfo()
|
||||||
|
|
||||||
# We need to transform fields into tuple to deal with tags as
|
# We need to transform fields into tuple to deal with tags as
|
||||||
|
@ -128,7 +129,7 @@ def upload_video(oauth, secret, options):
|
||||||
exit(1)
|
exit(1)
|
||||||
# If Mastodon compatibility is enabled, clean tags from special characters
|
# If Mastodon compatibility is enabled, clean tags from special characters
|
||||||
if options.get('--mt'):
|
if options.get('--mt'):
|
||||||
strtag = utils.mastodonTag(strtag)
|
strtag = utils.cleanString(strtag)
|
||||||
fields.append(("tags", strtag))
|
fields.append(("tags", strtag))
|
||||||
|
|
||||||
if options.get('--category'):
|
if options.get('--category'):
|
||||||
|
|
18
lib/utils.py
18
lib/utils.py
|
@ -193,15 +193,15 @@ def parseNFO(options):
|
||||||
def upcaseFirstLetter(s):
|
def upcaseFirstLetter(s):
|
||||||
return s[0].upper() + s[1:]
|
return s[0].upper() + s[1:]
|
||||||
|
|
||||||
def mastodonTag(tag):
|
def cleanString(toclean):
|
||||||
tags = tag.split(' ')
|
toclean = toclean.split(' ')
|
||||||
mtag = ''
|
cleaned = ''
|
||||||
for s in tags:
|
for s in toclean:
|
||||||
if s == '':
|
if s == '':
|
||||||
continue
|
continue
|
||||||
strtag = unicodedata.normalize('NFKD', unicode (s, 'utf-8')).encode('ASCII', 'ignore')
|
strtoclean = unicodedata.normalize('NFKD', unicode (s, 'utf-8')).encode('ASCII', 'ignore')
|
||||||
strtag = ''.join(e for e in strtag if e.isalnum())
|
strtoclean = ''.join(e for e in strtoclean if e.isalnum())
|
||||||
strtag = upcaseFirstLetter(strtag)
|
strtoclean = upcaseFirstLetter(strtoclean)
|
||||||
mtag = mtag + strtag
|
cleaned = cleaned + strtoclean
|
||||||
|
|
||||||
return mtag
|
return cleaned
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue