mirror of
https://git.lecygnenoir.info/LecygneNoir/prismedia.git
synced 2025-10-03 09:29:16 +02:00
Fix bug with trailing / in peertube url. fix #6
This commit is contained in:
parent
a160b2e409
commit
2e600bc455
1 changed files with 19 additions and 12 deletions
|
@ -23,21 +23,28 @@ PEERTUBE_PRIVACY = {
|
||||||
|
|
||||||
|
|
||||||
def get_authenticated_service(secret):
|
def get_authenticated_service(secret):
|
||||||
peertube_url = str(secret.get('peertube', 'peertube_url'))
|
peertube_url = str(secret.get('peertube', 'peertube_url')).rstrip("/")
|
||||||
|
|
||||||
oauth_client = LegacyApplicationClient(
|
oauth_client = LegacyApplicationClient(
|
||||||
client_id=str(secret.get('peertube', 'client_id'))
|
client_id=str(secret.get('peertube', 'client_id'))
|
||||||
)
|
)
|
||||||
|
try:
|
||||||
oauth = OAuth2Session(client=oauth_client)
|
oauth = OAuth2Session(client=oauth_client)
|
||||||
oauth.fetch_token(
|
oauth.fetch_token(
|
||||||
token_url=peertube_url + '/api/v1/users/token',
|
token_url=str(peertube_url + '/api/v1/users/token'),
|
||||||
# lower as peertube does not store uppecase for pseudo
|
# lower as peertube does not store uppercase for pseudo
|
||||||
username=str(secret.get('peertube', 'username').lower()),
|
username=str(secret.get('peertube', 'username').lower()),
|
||||||
password=str(secret.get('peertube', 'password')),
|
password=str(secret.get('peertube', 'password')),
|
||||||
client_id=str(secret.get('peertube', 'client_id')),
|
client_id=str(secret.get('peertube', 'client_id')),
|
||||||
client_secret=str(secret.get('peertube', 'client_secret'))
|
client_secret=str(secret.get('peertube', 'client_secret'))
|
||||||
)
|
)
|
||||||
|
except Exception as e:
|
||||||
|
if hasattr(e, 'message'):
|
||||||
|
logging.error("Peertube: Error: " + str(e.message))
|
||||||
|
exit(1)
|
||||||
|
else:
|
||||||
|
logging.error("Peertube: Error: " + str(e))
|
||||||
|
exit(1)
|
||||||
return oauth
|
return oauth
|
||||||
|
|
||||||
|
|
||||||
|
@ -52,7 +59,7 @@ def upload_video(oauth, secret, options):
|
||||||
return (basename(path), open(abspath(path), 'rb'),
|
return (basename(path), open(abspath(path), 'rb'),
|
||||||
mimetypes.types_map[splitext(path)[1]])
|
mimetypes.types_map[splitext(path)[1]])
|
||||||
|
|
||||||
url = secret.get('peertube', 'peertube_url')
|
url = str(secret.get('peertube', 'peertube_url')).rstrip('/')
|
||||||
|
|
||||||
# We need to transform fields into tuple to deal with tags as
|
# We need to transform fields into tuple to deal with tags as
|
||||||
# MultipartEncoder does not support list refer
|
# MultipartEncoder does not support list refer
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue