4

Hello I am trying to parse Shoutcast radio's metadata in iOS.

After trying many submitted solutions, I end up with a piece of code that is still giving me error

Response String: ICY 404 Resource Not Found icy-notice1:
SHOUTcast Distributed Network Audio Server/Linux v1.9.8
icy-notice2:The resource requested was not found

the code im trying to parse metadata

NSURL *url = [NSURL URLWithString:@"http://relay.181.fm:8052/7.html"];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:15.0];

   [request addValue:@"1" forHTTPHeaderField:@"icy-metadata"];
   [request addValue:@"Winamp 5/3" forHTTPHeaderField:@"User-Agent"];
   [request addValue:@"audio/mpeg" forHTTPHeaderField:@"Content-Type"];

[request setHTTPMethod:@"GET"];

NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];

NSString* responseString = [[NSString alloc] initWithData:data encoding: NSUTF8StringEncoding];

NSLog(@"Response String: %@", responseString);

any ideas about problem, thanks for helping

bugrasitemkar
  • 431
  • 1
  • 7
  • 26

3 Answers3

4

Not all SHOUTcast servers allow access to 7.html. There are two other ways to get that data.

The XML data for SHOUTcast is generally available, but requires the server's password. You can request it using /admin.cgi?mode=viewxml&page=4.

You can also read the metadata right out of the stream. This is more cumbersome, but entirely possible, and not too difficult. See this answer for details: https://stackoverflow.com/a/4914538/362536

Community
  • 1
  • 1
Brad
  • 159,648
  • 54
  • 349
  • 530
0

I found a solution for those who can't/doesn't want to read metadata from stream. Its the easiest solution I have seen.

http://www.fvalente.org/blog/2012/03/15/shoutcast-metadata-the-easy-way/

Brad says in the post above

Not all SHOUTcast servers allow access to 7.html.

so it is better to check if the server you want to get metadata has /7.html page

bugrasitemkar
  • 431
  • 1
  • 7
  • 26
  • For what it's worth, I've had problems with 7.html not being served as UTF-8, leading to crap characters when I parse it. played.html doesn't give me that problem. – Brandon Roberson May 26 '14 at 03:30
0

the current song is also displayed on the page /played.html but it works in a web browser along with /7.html. But when i tried in fiddler2 on a windows machine i got the ICY 404 resource not found error

marcusdev
  • 19
  • 1