Example #1
0
        //Send a partner auth request to Pandora.  This will get us our sync time, partner ID, and partner auth token, which we need for any further requests.
        public bool doPartnerAuth()
        {
            bool responseOK = false;
            PandoraPartnerAuthRequest authRequest = new PandoraPartnerAuthRequest();
            PandoraResponse           authResponse;

            authRequest.Protocol             = ProtocolTLS;
            authRequest.needEncryption       = false;
            authRequest.expectedResponseType = typeof(PandoraPartnerAuthResult);
            authRequest.username             = ClientConfig.ParterUser;
            authRequest.password             = ClientConfig.PartnerPassword;
            authRequest.deviceModel          = ClientConfig.DeviceModel;
            authRequest.version                    = ClientConfig.Version;
            authRequest.includeUrls                = false;
            authRequest.returnDeviceType           = false;
            authRequest.returnUpdatePromptVersions = false;
            authResponse = PConnector.doPost(authRequest);
            responseOK   = validateResponse(authResponse);
            if (responseOK)
            {
                PandoraPartnerAuthResult authResult = authResponse.result;
                this.PartnerID        = authResult.partnerId;
                this.PartnerAuthToken = authResult.partnerAuthToken;
                this.SyncTime         = parseSyncTime(authResult.syncTime);
            }
            return(responseOK);
        }
Example #2
0
        //Adds a search result to the station list. Returns the new station.
        public PStation doAddStation(ISearchResult search)
        {
            bool responseOK = false;
            PandoraStationAddRequest addRequest = new PandoraStationAddRequest();
            PandoraResponse          addResponse;

            addRequest.Protocol             = ProtocolTLS;
            addRequest.expectedResponseType = typeof(PandoraStationAddResult);
            addRequest.UserID        = this.UserID;
            addRequest.PartnerID     = this.PartnerID;
            addRequest.userAuthToken = this.UserAuthToken;
            addRequest.syncTime      = computeSyncTime();
            addRequest.musicType     = (search.getType().Equals("Artist")?"artist":"song");
            addRequest.musicToken    = search.musicToken;
            addResponse = PConnector.doPost(addRequest);
            responseOK  = validateResponse(addResponse);
            if (responseOK)
            {
                PandoraStationAddResult addResult = addResponse.result;
                return(addResult.station);
            }
            else
            {
                throw new PandoraResponseExecption();
            }
        }
Example #3
0
        //The following methods require a valid user ID and auth token.
        //Returns a list of stations currently available to the authed user.
        public List <PStation> doGetStationList()
        {
            bool responseOK = false;
            PandoraStationListRequest stationRequest = new PandoraStationListRequest();
            PandoraResponse           stationResponse;

            stationRequest.Protocol             = ProtocolNoTLS;
            stationRequest.expectedResponseType = typeof(PandoraStationListResult);
            stationRequest.UserID        = this.UserID;
            stationRequest.PartnerID     = this.PartnerID;
            stationRequest.userAuthToken = this.UserAuthToken;
            stationRequest.syncTime      = computeSyncTime();
            stationResponse = PConnector.doPost(stationRequest);
            responseOK      = validateResponse(stationResponse);
            if (responseOK)
            {
                PandoraStationListResult stationResult = stationResponse.result;
                this.StationList = stationResult.stations;
            }
            return(this.StationList);
        }
Example #4
0
        //Returns a list of song objects representing a station's playlist.
        public List <PSong> doGetStationPlaylist(PStation station)
        {
            bool responseOK = false;
            PandoraGetPlaylistRequest playlistRequest = new PandoraGetPlaylistRequest();
            PandoraResponse           playlistResponse;

            playlistRequest.Protocol             = ProtocolTLS;
            playlistRequest.expectedResponseType = typeof(PandoraGetPlaylistResult);
            playlistRequest.UserID        = this.UserID;
            playlistRequest.PartnerID     = this.PartnerID;
            playlistRequest.userAuthToken = this.UserAuthToken;
            playlistRequest.syncTime      = computeSyncTime();
            playlistRequest.stationToken  = station.stationToken;
            playlistResponse = PConnector.doPost(playlistRequest);
            responseOK       = validateResponse(playlistResponse);
            if (responseOK)
            {
                PandoraGetPlaylistResult playlistResult = playlistResponse.result;
                return(playlistResult.items);
            }
            return(new List <PSong>());
        }
Example #5
0
        //Methods for controlling station list.
        //Returns a list of search results.  Pandora returns three different types - artist, song, and genre.  This method aggregates these and returns the full list.
        public List <ISearchResult> doSearchStations(string searchString)
        {
            bool responseOK = false;
            PandoraSearchStationRequest stationRequest = new PandoraSearchStationRequest();
            PandoraResponse             stationResponse;

            stationRequest.Protocol             = ProtocolNoTLS;
            stationRequest.expectedResponseType = typeof(PandoraSearchStationResult);
            stationRequest.UserID        = this.UserID;
            stationRequest.PartnerID     = this.PartnerID;
            stationRequest.userAuthToken = this.UserAuthToken;
            stationRequest.syncTime      = computeSyncTime();
            stationRequest.searchText    = searchString;
            stationResponse = PConnector.doPost(stationRequest);
            responseOK      = validateResponse(stationResponse);
            if (responseOK)
            {
                PandoraSearchStationResult stationResult = stationResponse.result;
                this.SearchResults = stationResult.AggregateResults;
            }
            return(this.SearchResults);
        }
Example #6
0
        //Send a user auth request to Pandora.  This will get our user auth token and user ID.  Will fail if partner auth not successful.
        public bool doUserAuth()
        {
            bool responseOK = false;
            PandoraUserAuthRequest authRequest = new PandoraUserAuthRequest();
            PandoraResponse        authResponse;

            authRequest.Protocol             = ProtocolTLS;
            authRequest.expectedResponseType = typeof(PandoraUserAuthResult);
            authRequest.username             = ClientConfig.Username;
            authRequest.password             = ClientConfig.UserPass;
            authRequest.PartnerID            = this.PartnerID;
            authRequest.partnerAuthToken     = this.PartnerAuthToken;
            authRequest.syncTime             = computeSyncTime();
            authResponse = PConnector.doPost(authRequest);
            responseOK   = validateResponse(authResponse);
            if (responseOK)
            {
                PandoraUserAuthResult authResult = authResponse.result;
                this.UserID        = authResult.userId;
                this.UserAuthToken = authResult.userAuthToken;
            }
            return(responseOK);
        }