Example #1
0
        /// <summary>
        /// Given the username and password, attempts to log into the Pandora music service.
        /// </summary>
        /// <returns>If login is successful, returns a PandoraUser object. If invalid username or password
        /// null is returned.</returns>
        public PandoraUser UserLogin(PandoraSession session, string username, string password, WebProxy proxy)
        {
            try {
                PandoraUser user = (PandoraUser)ExecuteRequest(new UserLoginRequest(session, username, password), proxy);
                session.User  = user;
                user.Password = password;
                return(user);
            }
            catch (PandoraException e) {
                if (e.ErrorCode == ErrorCodeEnum.AUTH_INVALID_USERNAME_PASSWORD)
                {
                    return(null);
                }

                throw;
            }
        }
Example #2
0
        // estimate the length of each song based on file size
        public void GetSongLength(PandoraUser user, PandoraSong song, WebProxy proxy)
        {
            if (!IsValid(song, proxy))
            {
                throw new PandoraException("Attempting to get song length for an expired song.");
            }

            WebRequest request = WebRequest.Create(song.AudioURL);

            if (proxy != null)
            {
                request.Proxy = proxy;
            }
            request.Method = "HEAD";

            using (WebResponse response = request.GetResponse()) {
                long bytes   = response.ContentLength;
                int  seconds = (int)((bytes * 8) / (int.Parse(song.AudioInfo.Bitrate) * 1000));
                song.Length = new TimeSpan(0, 0, seconds);
            }
        }
Example #3
0
 public void GetSongLength(PandoraUser user, PandoraSong song)
 {
     GetSongLength(user, song, null);
 }
 internal SkipHistory(PandoraUser user)
     : this()
 {
     _user = user;
 }