GetResponseStream() public method

public GetResponseStream ( ) : Stream
return Stream
Ejemplo n.º 1
0
        public Playlist LoadPlaylistFor(string station)
        {
            lock (this) {
                if (station != Station)
                {
                    return(null);
                }

                Playlist      pl             = new Playlist();
                Stream        stream         = null;
                LastfmRequest radio_playlist = new LastfmRequest("radio.getPlaylist", RequestType.AuthenticatedRead, ResponseFormat.Raw);
                try {
                    radio_playlist.Send();
                    stream = radio_playlist.GetResponseStream();
                    pl.Load(stream);
                    Log.Debug(String.Format("Adding {0} Tracks to Last.fm Station {1}", pl.TrackCount, station), null);
                } catch (System.Net.WebException e) {
                    Log.Warning("Error Loading Last.fm Station", e.Message, false);
                    return(null);
                } catch (Exception e) {
                    string body = null;
                    try {
                        using (StreamReader strm = new StreamReader(stream)) {
                            body = strm.ReadToEnd();
                        }
                    } catch {}
                    Log.Warning(
                        "Error loading station",
                        String.Format("Exception:\n{0}\n\nResponse:\n{1}", e.ToString(), body ?? "Unable to get response"), false
                        );
                    return(null);
                }

                return(pl);
            }
        }
Ejemplo n.º 2
0
        public Playlist LoadPlaylistFor (string station)
        {
            lock (this) {
                if (station != Station)
                    return null;

                Playlist pl = new Playlist ();
                Stream stream = null;
                LastfmRequest radio_playlist = new LastfmRequest ("radio.getPlaylist", RequestType.AuthenticatedRead, ResponseFormat.Raw);
                try {
                    radio_playlist.Send ();
                    stream = radio_playlist.GetResponseStream ();
                    pl.Load (stream);
                    Log.Debug (String.Format ("Adding {0} Tracks to Last.fm Station {1}", pl.TrackCount, station), null);
                } catch (System.Net.WebException e) {
                    Log.Warning ("Error Loading Last.fm Station", e.Message, false);
                    return null;
                } catch (Exception e) {
                    string body = null;
                    try {
                        using (StreamReader strm = new StreamReader (stream)) {
                            body = strm.ReadToEnd ();
                        }
                    } catch {}
                    Log.Warning (
                        "Error loading station",
                        String.Format ("Exception:\n{0}\n\nResponse:\n{1}", e.ToString (), body ?? "Unable to get response"), false
                    );
                    return null;
                }

                return pl;
            }
        }