No need to make 20 hostname guesses. You can look up the station ID value for a known callsign with this API URL (replace "KEIB" below with your desired callsign):
Code:
https://us.api.iheart.com/api/v1/catalog/searchAll?keywords=KEIB&maxRows=20&queryArtist=false&queryTrack=false&queryBundle=false&queryFeaturedStation=true&queryKeyword=false&queryStation=true&queryTalkShow=false&startIndex=0
The result is XML. Look inside the <id></id> tag for the station ID value.
You can then get the stream URLs (rtmp, icy, hls) by placing the aforementioned station ID value in
this API URL (replace "197" below with your desired station ID):
Code:
https://us.api.iheart.com/api/v2/content/liveStations/197?allMarkets=true
The result is json.
I made a batch file that can be run at the Windows command line to retrieve all stream URLs for an IHR station by callsign (requires xidel.exe from
http://www.videlibri.de/xidel.html):
Code:
@echo off
setlocal
if not "%~1" == "" goto top
echo.
echo Command line syntax:
echo ihrstreams [callsign]
echo Example:
echo ihrstreams KEIB
goto :eof
:top
set "ihr_call=%~1"
for /f "tokens=1" %%a in ('xidel -s "http://us.api.iheart.com/api/v1/catalog/searchAll?keywords=%ihr_call%&maxRows=20&queryArtist=false&queryTrack=false&queryBundle=false&queryFeaturedStation=true&queryKeyword=false&queryStation=true&queryTalkShow=false&startIndex=0" -e "//bestmatch/id"') do set "ihr_sid=%%a"
if "%ihr_sid%" == "" (
echo.
echo Error querying IHR 'searchAll' API. Check callsign.
) else (
echo.
for /f "tokens=1" %%a in ('xidel -s "http://us.api.iheart.com/api/v2/content/liveStations/%ihr_sid%?allMarkets=true" -e "($json).hits/streams/*"') do echo %%a
)
endlocal
Screenshot of the batch file working:
https://images2.imgbox.com/95/59/l7tvGD9R_o.png
If you want the batch file to return only one kind of stream (instead of all 5 kinds), just replace the asterisk inside the batch file (there is only one) with the desired stream's name in the server's json output (i.e., replace "*" with "hls_stream" or "shoutcast_stream" or "secure_rtmp_stream" or "secure_hls_stream" or "secure_shoutcast_stream").