Skip to content

Instantly share code, notes, and snippets.

@onorbumbum
onorbumbum / convert_radio-browser-to-raycast-internet-radio.py
Created December 6, 2024 20:25
This script: Takes JSON files from an input directory and combines them into a single master output file Transforms each station's data to match your desired output format Handles both single objects and lists of objects in the input JSON files Includes error handling for file operations Processes the following transformations: Converts tags to …
import json
import os
from pathlib import Path
def transform_station(station):
"""Transform a single station record to the desired output format."""
# Extract tags and convert to list
genres = station.get('tags', '').split(',')
# Clean up empty strings and strip whitespace
genres = [g.strip() for g in genres if g.strip()]