import requests, json, urllib3
urllib3.disable_warnings()

URL = "https://mtr.ciapongi.szablix.pl/mtr/api/map/stations-and-routes?dimension=0"

def main():
    print("=== GŁĘBOKI RENTGEN TYPÓW POJAZDÓW W MTR ===")
    try:
        r = requests.get(URL, verify=False, timeout=10)
        routes = r.json().get('data', {}).get('routes', [])
        
        seen_types = set()
        
        for route in routes:
            # Tworzymy unikalny klucz dla typu
            t_key = f"{route.get('type', 'Brak')}_{route.get('jmeType', 'Brak')}"
            
            if t_key not in seen_types:
                seen_types.add(t_key)
                
                print(f"\n--- ZNALEZIONO NOWY TYP: {t_key} ---")
                
                # Tworzymy kopię żeby ukryć ogromne listy stacji i zrzucić sam szkielet
                r_copy = dict(route)
                if 'stations' in r_copy:
                    r_copy['stations'] = f"[Ukryto {len(r_copy['stations'])} stacji]"
                if 'durations' in r_copy:
                    r_copy['durations'] = "[Ukryto czasy przejazdów]"
                
                print(json.dumps(r_copy, indent=2, ensure_ascii=False))
                print("-" * 50)
                
    except Exception as e:
        print(f"Błąd pobierania danych: {e}")

if __name__ == "__main__":
    main()
