How to get streaming url from online streaming radio station

I was asked to make an unofficial online application for androids for a specific radio station.
I have experience streaming in android for a specific mp3 or any other stream.
But I do not know how to provide stream url in mediaPlayer.setDataSource(url) .

Is there any way to get the stream url from the official streaming page for ex. is this radio stream ?

+7
javascript android html stream
source share
4 answers

not so hard

if you look at the source of the page, you will see what it uses to stream sound through a scream.

this is the url of the stream

"StreamUrl": " http://stream.radiotime.com/listen.stream?streamIds=3244651&rti=c051HQVbfRc4FEMbKg5RRVMzRU9KUBw%2fVBZHS0dPF1VIExNzJz0CGQtRcX8OS0o0CUkYRFJDDW8LEVRxGAEOEAcQXko%2bGgwSBBZrV1pQZgQZZxkWCA4L%7e%7e%7e ",

which returns JSON as follows:

 { "Streams": [ { "StreamId": 3244651, "Reliability": 92, "Bandwidth": 64, "HasPlaylist": false, "MediaType": "MP3", "Url": "http://mp3hdfm32.hala.jo:8132", "Type": "Live" } ] } 

I believe the required URL is: http://mp3hdfm32.hala.jo:8132

this is the station website

+14
source share

The answer to Shahar was really helpful, but it was pretty tedious for me to do all this myself, so I made a great little Python program:

 import re import urllib2 import string url1 = raw_input("Please enter a URL from Tunein Radio: "); open_file = urllib2.urlopen(url1); raw_file = open_file.read(); API_key = re.findall(r"StreamUrl\":\"(.*?),",raw_file); #print API_key; #print "The API key is: " + API_key[0]; use_key = urllib2.urlopen(str(API_key[0])); key_content = use_key.read(); raw_stream_url = re.findall(r"Url\": \"(.*?)\"",key_content); bandwidth = re.findall(r"Bandwidth\":(.*?),", key_content); reliability = re.findall(r"lity\":(.*?),", key_content); isPlaylist = re.findall(r"HasPlaylist\":(.*?),",key_content); codec = re.findall(r"MediaType\": \"(.*?)\",", key_content); tipe = re.findall(r"Type\": \"(.*?)\"", key_content); total = 0 for element in raw_stream_url: total = total + 1 i = 0 print "I found " + str(total) + " streams."; for element in raw_stream_url: print "Stream #" + str(i + 1); print "Stream stats:"; print "Bandwidth: " + str(bandwidth[i]) + " kilobytes per second." print "Reliability: " + str(reliability[i]) + "%" print "HasPlaylist: " + str(isPlaylist[i]) + "." print "Stream codec: " + str(codec[i]) + "." print "This audio stream is " + tipe[i].lower() + "." print "Pure streaming URL: " + str(raw_stream_url[i]) + "."; i = i + 1 raw_input("Press enter to close TMUS.") 

This is basically a Shahar solution automated.

+4
source share

ZygD edited answer for python 3.x .:

 import re import urllib.request import string url1 = input("Please enter a URL from Tunein Radio: "); request = urllib.request.Request(url1); response = urllib.request.urlopen(request); raw_file = response.read().decode('utf-8'); API_key = re.findall(r"StreamUrl\":\"(.*?),\"",raw_file); #print API_key; #print "The API key is: " + API_key[0]; request2 = urllib.request.Request(str(API_key[0])); response2 = urllib.request.urlopen(request2); key_content = response2.read().decode('utf-8'); raw_stream_url = re.findall(r"Url\": \"(.*?)\"",key_content); bandwidth = re.findall(r"Bandwidth\":(.*?),", key_content); reliability = re.findall(r"lity\":(.*?),", key_content); isPlaylist = re.findall(r"HasPlaylist\":(.*?),",key_content); codec = re.findall(r"MediaType\": \"(.*?)\",", key_content); tipe = re.findall(r"Type\": \"(.*?)\"", key_content); total = 0 for element in raw_stream_url: total = total + 1 i = 0 print ("I found " + str(total) + " streams."); for element in raw_stream_url: print ("Stream #" + str(i + 1)); print ("Stream stats:"); print ("Bandwidth: " + str(bandwidth[i]) + " kilobytes per second."); print ("Reliability: " + str(reliability[i]) + "%"); print ("HasPlaylist: " + str(isPlaylist[i])); print ("Stream codec: " + str(codec[i])); print ("This audio stream is " + tipe[i].lower()); print ("Pure streaming URL: " + str(raw_stream_url[i])); i = i + 1 input("Press enter to close") 
+4
source share

When you go to the stream URL, you are prompted with a file. load this file into the parser to extract the contents from it. the file is (usually) plain text and contains the url to play.

+1
source share

All Articles