如何从在线stream媒体电台获取stream媒体url

我被要求为某个电台制作非官方的在线stream媒体android应用程序。
我有一定的MP3或任何streamAndroid的stream媒体的经验。
但是我不知道在mediaPlayer.setDataSource(url)提供的stream url

有没有什么办法可以从官方stream媒体页面获取streamurl 这个广播stream ?

Solutions Collecting From Web of "如何从在线stream媒体电台获取stream媒体url"

没那么难,

如果你看一下页面源代码,你会看到它用来通过shoutcaststream式传输audio。

这是streamurl

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

它返回一个像这样的JSON:

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

我相信这是你需要的url: http : //mp3hdfm32.hala.jo : 8132

这是站的网站

Shahar的回答真的很有帮助,但是我发现自己做这件事很麻烦,于是我制作了一个漂亮的Python程序:

 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.") 

基本上Shahar的解决scheme是自动化的。

编辑ZygD的python3.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") 

当你到一个streamurl时,你会得到一个文件。 将该文件馈送给parsing器以将其内容提取出来。 该文件是(通常)纯文本,并包含要播放的url。