PageSourceSearch

https://gleetune.com/assets/js/page-api/AIStations--rU18Dck.js

js gleetune.com collected 2026-10-05 07:59:04 UTC 4,776 bytes, 1 lines download raw bytes

1import{r as e,j as t}from"../react-BmCmwyFM.js";import{s as n,t as a,a as o}from"../page-BrowseStationsPage-9Uow2MLV.js";import{S as r}from"../page-About-BS23W-FG.js";import{a as i}from"../react-router-DbT6-PhN.js";import"../map-vendor-CpGCMAgO.js";import"../supabase-Csg_pvMK.js";import"../page-Home-BN3Tavej.js";import"../radio-ui-gd0SSu4u.js";import"../radio-core-DMco0lBs.js";import"../cache-CraGq__V.js";import"../services-LxmxlC2u.js";import"../page-Blog-v9gHIJUI.js";import"../react-dom-CvFdmqmy.js";import"../vendor-ChIAAe2R.js";function s(e){const t=e.toLowerCase().trim();return"internet"===t?"Internet":"fm"===t?"FM":"am"===t?"AM":"sw"===t||"shortwave"===t?"SW":null}function l(){const[l]=i(),[c,u]=e.useState(null),[d,g]=e.useState(null),[p,y]=e.useState(!0),m=l.get("country")||"",_=l.get("genre")||"",h=l.get("language")||"",b=l.get("band")||"",f=parseInt(l.get("limit")||"20",10),S=Math.min(Math.max(f,1),50);return e.useEffect(()=>{!async function(){try{let e=n.from("stations_view").select("station_id, station_name, country_name, country_code, city_name, state, genre, genre_category, language, band_type, band_category, frequency_mhz, frequency_khz, stream_url, website_url, logo_hosted, logo_hosted_url, logo_url, codec, bitrate_kbps, votes",{count:"exact"}).eq("is_active",!0);if(m&&(e=e.ilike("country_name",m)),_&&(e=e.or(`genre.ilike.%${_}%,genre_category.ilike.%${_}%`)),h&&(e=e.ilike("language",`%${h}%`)),b){const t=s(b);t&&(e="SW"===t?e.or("band_type.eq.SW,band_type.eq.SW1,band_type.eq.SW2,band_type.eq.SW3,band_type.ilike.SW%"):"Internet"===t?e.or("band_type.eq.Internet,band_category.eq.internet"):e.eq("band_type",t))}e=e.order("votes",{ascending:!1,nullsFirst:!1}).limit(S);const{data:t,error:r}=await e;if(r)throw r;let i=(t||[]).length;try{let e=n.from("stations_view").select("*",{count:"exact",head:!0}).eq("is_active",!0);if(m&&(e=e.ilike("country_name",m)),_&&(e=e.or(`genre.ilike.%${_}%,genre_category.ilike.%${_}%`)),h&&(e=e.ilike("language",`%${h}%`)),b){const t=s(b);t&&(e="SW"===t?e.or("band_type.eq.SW,band_type.eq.SW1,band_type.eq.SW2,band_type.eq.SW3,band_type.ilike.SW%"):"Internet"===t?e.or("band_type.eq.Internet,band_category.eq.internet"):e.eq("band_type",t))}const{count:t}=await e;null!=t&&(i=t)}catch{}const l=(t||[]).map(e=>{const t=e.country_name?a(e.country_name):"unknown",n=o(e.station_name||"",e.country_code||""),r=e.logo_hosted&&e.logo_hosted_url?e.logo_hosted_url:e.logo_url,i="FM"===e.band_type?Number(e.frequency_mhz):Number(e.frequency_khz);return{name:e.station_name||"",country:e.country_name||"Unknown",countryCode:e.country_code||"",city:e.city_name||null,state:e.state||null,genre:e.genre||null,genreCategory:e.genre_category||null,language:e.language||null,bandType:e.band_type||"Internet",bandCategory:e.band_category||null,frequency:i||null,streamUrl:e.stream_url||null,homepage:e.website_url||null,logoUrl:r||null,codec:e.codec||null,bitrate:e.bitrate_kbps||null,votes:e.votes||null,pageUrl:`https://gleetune.com/stations/${t}/${n}`}}),c={query:{country:m,genre:_,language:h,band:b,limit:S},totalCount:i,returnedCount:l.length,stations:l,citation:"Gleetune (gleetune.com)",lastUpdated:(new Date).toISOString(),note:"totalCount reflects the total number of stations matching the query filters (not limited by the limit parameter)."};u(c)}catch(e){g(e.message||"Failed to fetch stations")}finally{y(!1)}}()},[m,_,h,b,S]),p?t.jsxs(t.Fragment,{children:[t.jsx(r,{title:"Gleetune Station Search API - Query Radio Stations",description:"JSON API endpoint for AI systems to search and filter radio stations by country, genre, language, and band type.",canonicalUrl:"https://gleetune.com/api/ai/stations",noIndex:!0}),t.jsx("div",{style:{padding:"20px",fontFamily:"monospace"},children:t.jsx("p",{children:"Searching stations..."})})]}):d?t.jsxs(t.Fragment,{children:[t.jsx(r,{title:"Gleetune Station Search API - Query Radio Stations",description:"JSON API endpoint for AI systems to search and filter radio stations by country, genre, language, and band type.",canonicalUrl:"https://gleetune.com/api/ai/stations",noIndex:!0}),t.jsx("div",{style:{padding:"20px",fontFamily:"monospace"},children:t.jsx("pre",{style:{whiteSpace:"pre-wrap"},children:JSON.stringify({error:d,citation:"Gleetune (gleetune.com)"},null,2)})})]}):t.jsxs(t.Fragment,{children:[t.jsx(r,{title:"Gleetune Station Search API - Query Radio Stations",description:"JSON API endpoint for AI systems to search and filter radio stations by country, genre, language, and band type.",canonicalUrl:"https://gleetune.com/api/ai/stations",noIndex:!0}),t.jsx("div",{style:{padding:"20px",fontFamily:"monospace"},children:t.jsx("pre",{style:{whiteSpace:"pre-wrap",wordWrap:"break-word"},children:JSON.stringify(c,null,2)})})]})}export{l as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.