From 49827a64da8363bdfd3ce2931edbbf777038bd69 Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Mon, 12 Apr 2021 17:20:50 +0100 Subject: [PATCH] Black formatting --- lnbits/extensions/livestream/__init__.py | 4 +++- lnbits/extensions/livestream/lnurl.py | 12 +++++++++--- lnbits/extensions/livestream/views.py | 10 ++++++++-- lnbits/extensions/livestream/views_api.py | 18 +++++++++++++++--- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/lnbits/extensions/livestream/__init__.py b/lnbits/extensions/livestream/__init__.py index 6f5527f1..d8f61fe0 100644 --- a/lnbits/extensions/livestream/__init__.py +++ b/lnbits/extensions/livestream/__init__.py @@ -4,7 +4,9 @@ from lnbits.db import Database db = Database("ext_livestream") -livestream_ext: Blueprint = Blueprint("livestream", __name__, static_folder="static", template_folder="templates") +livestream_ext: Blueprint = Blueprint( + "livestream", __name__, static_folder="static", template_folder="templates" +) from .views_api import * # noqa diff --git a/lnbits/extensions/livestream/lnurl.py b/lnbits/extensions/livestream/lnurl.py index ed987f8a..d1c59fb1 100644 --- a/lnbits/extensions/livestream/lnurl.py +++ b/lnbits/extensions/livestream/lnurl.py @@ -20,7 +20,9 @@ async def lnurl_response(ls_id): return jsonify({"status": "ERROR", "reason": "This livestream is offline."}) resp = LnurlPayResponse( - callback=url_for("livestream.lnurl_callback", track_id=track.id, _external=True), + callback=url_for( + "livestream.lnurl_callback", track_id=track.id, _external=True + ), min_sendable=track.min_sendable, max_sendable=track.max_sendable, metadata=await track.lnurlpay_metadata(), @@ -60,7 +62,9 @@ async def lnurl_callback(track_id): comment = request.args.get("comment") if len(comment or "") > 300: return jsonify( - LnurlErrorResponse(reason=f"Got a comment with {len(comment)} characters, but can only accept 300").dict() + LnurlErrorResponse( + reason=f"Got a comment with {len(comment)} characters, but can only accept 300" + ).dict() ) ls = await get_livestream_by_track(track_id) @@ -69,7 +73,9 @@ async def lnurl_callback(track_id): wallet_id=ls.wallet, amount=int(amount_received / 1000), memo=await track.fullname(), - description_hash=hashlib.sha256((await track.lnurlpay_metadata()).encode("utf-8")).digest(), + description_hash=hashlib.sha256( + (await track.lnurlpay_metadata()).encode("utf-8") + ).digest(), extra={"tag": "livestream", "track": track.id, "comment": comment}, ) diff --git a/lnbits/extensions/livestream/views.py b/lnbits/extensions/livestream/views.py index 55acc714..8864ac2c 100644 --- a/lnbits/extensions/livestream/views.py +++ b/lnbits/extensions/livestream/views.py @@ -24,9 +24,15 @@ async def track_redirect_download(track_id): payment: Payment = await get_wallet_payment(ls.wallet, payment_hash) if not payment: - return f"Couldn't find the payment {payment_hash} or track {track.id}.", HTTPStatus.NOT_FOUND + return ( + f"Couldn't find the payment {payment_hash} or track {track.id}.", + HTTPStatus.NOT_FOUND, + ) if payment.pending: - return f"Payment {payment_hash} wasn't received yet. Please try again in a minute.", HTTPStatus.PAYMENT_REQUIRED + return ( + f"Payment {payment_hash} wasn't received yet. Please try again in a minute.", + HTTPStatus.PAYMENT_REQUIRED, + ) return redirect(track.download_url) diff --git a/lnbits/extensions/livestream/views_api.py b/lnbits/extensions/livestream/views_api.py index c601883e..1150ddb9 100644 --- a/lnbits/extensions/livestream/views_api.py +++ b/lnbits/extensions/livestream/views_api.py @@ -39,7 +39,11 @@ async def api_livestream_from_wallet(): ) except LnurlInvalidUrl: return ( - jsonify({"message": "LNURLs need to be delivered over a publically accessible `https` domain or Tor."}), + jsonify( + { + "message": "LNURLs need to be delivered over a publically accessible `https` domain or Tor." + } + ), HTTPStatus.UPGRADE_REQUIRED, ) @@ -74,8 +78,16 @@ async def api_update_fee(fee_pct): "name": {"type": "string", "empty": False, "required": True}, "download_url": {"type": "string", "empty": False, "required": False}, "price_msat": {"type": "number", "min": 0, "required": False}, - "producer_id": {"type": "number", "required": True, "excludes": "producer_name"}, - "producer_name": {"type": "string", "required": True, "excludes": "producer_id"}, + "producer_id": { + "type": "number", + "required": True, + "excludes": "producer_name", + }, + "producer_name": { + "type": "string", + "required": True, + "excludes": "producer_id", + }, } ) async def api_add_track():