Black formatting
This commit is contained in:
parent
492d710bb8
commit
49827a64da
4 changed files with 35 additions and 9 deletions
|
|
@ -4,7 +4,9 @@ from lnbits.db import Database
|
||||||
|
|
||||||
db = Database("ext_livestream")
|
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
|
from .views_api import * # noqa
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,9 @@ async def lnurl_response(ls_id):
|
||||||
return jsonify({"status": "ERROR", "reason": "This livestream is offline."})
|
return jsonify({"status": "ERROR", "reason": "This livestream is offline."})
|
||||||
|
|
||||||
resp = LnurlPayResponse(
|
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,
|
min_sendable=track.min_sendable,
|
||||||
max_sendable=track.max_sendable,
|
max_sendable=track.max_sendable,
|
||||||
metadata=await track.lnurlpay_metadata(),
|
metadata=await track.lnurlpay_metadata(),
|
||||||
|
|
@ -60,7 +62,9 @@ async def lnurl_callback(track_id):
|
||||||
comment = request.args.get("comment")
|
comment = request.args.get("comment")
|
||||||
if len(comment or "") > 300:
|
if len(comment or "") > 300:
|
||||||
return jsonify(
|
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)
|
ls = await get_livestream_by_track(track_id)
|
||||||
|
|
@ -69,7 +73,9 @@ async def lnurl_callback(track_id):
|
||||||
wallet_id=ls.wallet,
|
wallet_id=ls.wallet,
|
||||||
amount=int(amount_received / 1000),
|
amount=int(amount_received / 1000),
|
||||||
memo=await track.fullname(),
|
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},
|
extra={"tag": "livestream", "track": track.id, "comment": comment},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,15 @@ async def track_redirect_download(track_id):
|
||||||
payment: Payment = await get_wallet_payment(ls.wallet, payment_hash)
|
payment: Payment = await get_wallet_payment(ls.wallet, payment_hash)
|
||||||
|
|
||||||
if not payment:
|
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:
|
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)
|
return redirect(track.download_url)
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,11 @@ async def api_livestream_from_wallet():
|
||||||
)
|
)
|
||||||
except LnurlInvalidUrl:
|
except LnurlInvalidUrl:
|
||||||
return (
|
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,
|
HTTPStatus.UPGRADE_REQUIRED,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -74,8 +78,16 @@ async def api_update_fee(fee_pct):
|
||||||
"name": {"type": "string", "empty": False, "required": True},
|
"name": {"type": "string", "empty": False, "required": True},
|
||||||
"download_url": {"type": "string", "empty": False, "required": False},
|
"download_url": {"type": "string", "empty": False, "required": False},
|
||||||
"price_msat": {"type": "number", "min": 0, "required": False},
|
"price_msat": {"type": "number", "min": 0, "required": False},
|
||||||
"producer_id": {"type": "number", "required": True, "excludes": "producer_name"},
|
"producer_id": {
|
||||||
"producer_name": {"type": "string", "required": True, "excludes": "producer_id"},
|
"type": "number",
|
||||||
|
"required": True,
|
||||||
|
"excludes": "producer_name",
|
||||||
|
},
|
||||||
|
"producer_name": {
|
||||||
|
"type": "string",
|
||||||
|
"required": True,
|
||||||
|
"excludes": "producer_id",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
async def api_add_track():
|
async def api_add_track():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue