commit 1c5b52eab0556bdb9839d8862e37245e21f252e4 Author: Jonas Heinrich Date: Sat Nov 9 09:59:47 2024 +0100 Initial commit diff --git a/eintopf-sync.py b/eintopf-sync.py new file mode 100644 index 0000000..8d18d46 --- /dev/null +++ b/eintopf-sync.py @@ -0,0 +1,30 @@ +import requests +import json + +url = "https://radar.squat.net/api/1.2/search/events.json?fields=title,offline,date_time,body&facets[group][]=436012" +response = requests.get(url) + +if response.status_code == 200: + data = response.json() + events = data["result"] + + radar_events = [] + + for event in events: + + event = events[event] + title = event["title"] + time_start = event["date_time"][0]["time_start"] + time_end = event["date_time"][0]["time_end"] + location = event["offline"][0]['title'] + description = event["body"]['value'] + + # Print the formatted output + print(f"Title: {title}") + print(f"Time Start: {time_start}") + print(f"Location: {location}") + #print(f"Description: {body}") + print('-' * 40) +else: + print(f"Failed to retrieve data. Status code: {response.status_code}") + diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..2a0d99f --- /dev/null +++ b/flake.lock @@ -0,0 +1,60 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1730883749, + "narHash": "sha256-mwrFF0vElHJP8X3pFCByJR365Q2463ATp2qGIrDUdlE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "dba414932936fde69f0606b4f1d87c5bc0003ede", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-24.05", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..e51b907 --- /dev/null +++ b/flake.nix @@ -0,0 +1,31 @@ +{ + inputs = { + nixpkgs.url = "nixpkgs/nixos-24.05"; + # Required for multi platform support + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + + start = + pkgs.writeShellScriptBin "start" '' + set -e + ${pkgs.python3}/bin/python eintopf-sync.py + ''; + in + { + devShell = pkgs.mkShell { + packages = with pkgs; with python3Packages; [ + python3 + requests + ]; + }; + + packages = { inherit start; }; + defaultPackage = start; + }); +} +