[scrobbles] Add orgparse and start of emacs webhook

This commit is contained in:
2025-06-06 17:25:04 -04:00
parent 39e2fdce27
commit 99a6e5107b
4 changed files with 48 additions and 1 deletions

15
poetry.lock generated
View File

@ -2228,6 +2228,7 @@ python-versions = "*"
groups = ["main"]
files = [
{file = "jusText-3.0.1-py2.py3-none-any.whl", hash = "sha256:e0fb882dd7285415709f4b7466aed23d6b98b7b89404c36e8a2e730facfed02b"},
{file = "justext-3.0.1-py2.py3-none-any.whl", hash = "sha256:0a5225c5cd7c5a124fec7bfa9a55110a73135e8b58ce784470af67d051ac9fd3"},
{file = "justext-3.0.1.tar.gz", hash = "sha256:b6ed2fb6c5d21618e2e34b2295c4edfc0bcece3bd549ed5c8ef5a8d20f0b3451"},
]
@ -2891,6 +2892,18 @@ rsa = ["cryptography (>=3.0.0)"]
signals = ["blinker (>=1.4.0)"]
signedtoken = ["cryptography (>=3.0.0)", "pyjwt (>=2.0.0,<3)"]
[[package]]
name = "orgparse"
version = "0.4.20250520"
description = "orgparse - Emacs org-mode parser in Python"
optional = false
python-versions = ">=3.9"
groups = ["main"]
files = [
{file = "orgparse-0.4.20250520-py3-none-any.whl", hash = "sha256:24d454432385016ae91c3518c8357a3a31fdd4cebfbb0c5926cf31247bf4c7e3"},
{file = "orgparse-0.4.20250520.tar.gz", hash = "sha256:6472fd16ddcabb523918505c865263abfa05ac80b593e668a089cda291b1a2de"},
]
[[package]]
name = "packaging"
version = "24.2"
@ -5439,4 +5452,4 @@ cffi = ["cffi (>=1.11)"]
[metadata]
lock-version = "2.1"
python-versions = ">=3.9,<3.12"
content-hash = "17358679b06dd15b7f119307013ed578ef81dbf31c592bc2ca11d13787a81215"
content-hash = "cdd7f577fe3a4c5c8cc960e0070d93b7ddbb2a7968fab63d72bb039afaa05bbe"

View File

@ -53,6 +53,7 @@ django-oauth-toolkit = "^3.0.1"
meta-yt = "^0.1.9"
berserk = "^0.13.2"
poetry-bumpversion = "^0.3.3"
orgparse = "^0.4.20250520"
[tool.poetry.group.test]
optional = true

View File

@ -36,6 +36,11 @@ urlpatterns = [
views.web_scrobbler_webhook,
name="web-scrobbler-webhook",
),
path(
"webhook/emacs/",
views.emacs_webhook,
name="emacs-webhook",
),
path(
"webhook/gps/",
views.gps_webhook,

View File

@ -453,6 +453,34 @@ def gps_webhook(request):
return Response({"scrobble_id": scrobble.id}, status=status.HTTP_200_OK)
@csrf_exempt
@api_view(["POST"])
def emacs_webhook(request):
try:
data_dict = json.loads(request.data)
except TypeError:
data_dict = request.data
logger.info(
"[emacs_webhook] called",
extra={
"post_data": data_dict,
"user_id": 1,
},
)
# TODO Fix this so we have to authenticate!
user_id = 1
if request.user.id:
user_id = request.user.id
#scrobble = gpslogger_scrobble_location(data_dict, user_id)
#if not scrobble:
# return Response({}, status=status.HTTP_200_OK)
return Response({"post_data": post_data}, status=status.HTTP_200_OK)
@csrf_exempt
@permission_classes([IsAuthenticated])