Black formatting

This commit is contained in:
Ben Arc 2021-04-12 17:20:50 +01:00
parent 492d710bb8
commit 49827a64da
4 changed files with 35 additions and 9 deletions

View file

@ -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

View file

@ -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},
)

View file

@ -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)

View file

@ -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():