INDEX
2024-01-21 17:56 - RSS Repeaters I want to make a tool to take a folder and host an rss feed of it Since I already have that in bash, it should have a config to allow multiple feeds Was doing it 1 port per feed but can have one big python website for many at once FastAPI or flask? Probably Flask since I know fastapi at this point # Simple compose script with python and volume mount docker compose run python bash Firstly need to setup environment - can install pip globally in docker But also why not put in a venv pip install -r requirements.txt # Install from list of python requirements pip freeze > requirements.txt # Export requirements flask --app main run -p 1234 # Weirdly the order of this matters network_mode: "host" # Set this in docker-compose to use host network # Weirdly sets hostname to same as my host too (might be due to image choice) Anyway exposed 1234 and website seems to run fine. Just need arbitrary endpoints # From the documentation from markupsafe import escape @app.route('/user/<username>') def show_user_profile(username): # show the user profile for that user return f'User {escape(username)}' Seems to work. Now just need to make a list of folders to copy Why not write in yaml - using pyyaml - can do basic parsing just reads as dict/json for key, value in d.items(): # Always useful
2024-01-22 15:35 So before I wrote a basic website to scan yaml and read it - gonna clean that up Plan is have /serve and /track - serve is local and track is remote It's not going to be an rss tracker - more a generator for awkward sites that don't use rss Can generate rss feeds for youtube playlists and just link back to original videos Essentially replacing the "using a website" bit of everything - just link to the source Trying to figure out how to structure this yaml - don't necessarily need an ID for each item Just do "- ITEM" to add a list item - but you need a list label # Using template from redhat site - name: Check URL hosts: all gather_facts: True tasks: - uri: url: "{{ urlpath }}" method: GET register: result until: result.status == 200 retries: 30 delay: 20 delegate_to: localhost - debug: msg: "{{ result.status }} - {{ result.msg }}" # This way the ID is not "uri" - you just have 2 tasks indexed by 0 and 1 Need to figure out how to set up expected yaml structures in python Might have to use typing for this - strictyaml or schema which is best? Features I want to use in strictyaml are "in alpha" so looking at schema now https://www.andrewvillazon.com/validate-yaml-python-schema/ https://github.com/keleshev/schema Can do things like ["directory": os.path.exists] to see if a file given exists # Current version (untested) schema = Schema({ "local": { "defaults": [{ Optional("category", default=""): str, Optional("enabled", default=False): bool, Optional("itemtype", default="mp3"): Or("mp3","mp4") }], "feeds": [{ "directory": os.path.exists, "title": str, Optional("category", default=""): str, Optional("enabled", default=False): bool, Optional("itemtype", default="mp3"): Or("mp3","mp4") }]} "track": { "defaults": [{ Optional("category", default=""): str, Optional("quality", default="mid"): Or("low","mid","high"), Optional("selfgenerate", default=False): bool }], "feeds": [{ "source": str, "title": str, "id": str, Optional("category", default=""): str, Optional("quality", default="mid"): Or("low","mid","high"), Optional("selfgenerate", default=False): bool }]}} Gets ugly when you try to figure out how to host a file server inside this I'll figure it out a bit later. For now, got proper yaml reading and a plan for structure For now it's just going to be an rss relay and generator - no actual hosting Okay so in the time I've been working I've added a few things Made it scan a folder for relevant files and save all this as an rss feed Add a basic http server to run script (running in background) so feed link as valid Added formatting checking to config file - with defaults applied