Example #1
0
        public SimpleAlbum(Client client, string id)
        {
            client.Depth = 4;
            id           = client.GetID(id);

            if (!client.Query(Rdf.MBQ_GetAlbumById, id) || !client.Select(Rdf.MBS_SelectAlbum, 1))
            {
                throw new ApplicationException("Could not fetch album with ID: " + id);
            }

            this.id       = client.GetID(client.GetResultData(Rdf.MBE_AlbumGetAlbumId));
            asin          = client.GetResultData(Rdf.MBE_AlbumGetAmazonAsin);
            cover_art_url = client.GetResultData(Rdf.MBE_AlbumGetAmazonCoverartURL);
            string artist_name = client.GetResultData(Rdf.MBE_AlbumGetArtistName);

            Console.WriteLine(artist_name);
            title = client.GetResultData(Rdf.MBE_AlbumGetAlbumName);

            int track_count = client.GetResultInt(Rdf.MBE_AlbumGetNumTracks, 1);

            if (track_count <= 0)
            {
                throw new ApplicationException("Invalid track count from album query");
            }

            tracks = new SimpleTrack[track_count];

            for (int i = 1; i <= tracks.Length; i++)
            {
                client.Select(Rdf.MBS_SelectTrack, i);

                tracks[i - 1]        = new SimpleTrack(i, 0);
                tracks[i - 1].Artist = client.GetResultData(Rdf.MBE_TrackGetArtistName);
                tracks[i - 1].Title  = client.GetResultData(Rdf.MBE_TrackGetTrackName);

                int length = client.GetResultInt(Rdf.MBE_TrackGetTrackDuration);
                tracks[i - 1].Length = length / 1000;

                client.Select(Rdf.MBS_Back);
            }

            if (client.GetResultInt(Rdf.MBE_AlbumGetNumReleaseDates) > 0)
            {
                client.Select(Rdf.MBS_SelectReleaseDate, 1);
                release_date = Utilities.StringToDateTime(
                    client.GetResultData(Rdf.MBE_ReleaseGetDate));
                client.Select(Rdf.MBS_Back);
            }

            client.Select(Rdf.MBS_Back);
        }
Example #2
0
        public SimpleDisc(string device, Client client)
        {
            this.client   = client;
            client.Device = device;

            ReadCDToc();

            tracks = new SimpleTrack[lengths.Length];

            for (int i = 0; i < lengths.Length; i++)
            {
                tracks[i] = new SimpleTrack(i + 1, lengths[i]);
            }
        }
        public SimpleAlbum(Client client, string id)
        {
            client.Depth = 4;
            id = client.GetID(id);

            if(!client.Query(Rdf.MBQ_GetAlbumById, id) || !client.Select(Rdf.MBS_SelectAlbum, 1)) {
                throw new ApplicationException("Could not fetch album with ID: " + id);
            }

            this.id = client.GetID(client.GetResultData(Rdf.MBE_AlbumGetAlbumId));
            asin = client.GetResultData(Rdf.MBE_AlbumGetAmazonAsin);
            cover_art_url = client.GetResultData(Rdf.MBE_AlbumGetAmazonCoverartURL);
            string artist_name = client.GetResultData(Rdf.MBE_AlbumGetArtistName);
            Console.WriteLine(artist_name);
            title = client.GetResultData(Rdf.MBE_AlbumGetAlbumName);

            int track_count = client.GetResultInt(Rdf.MBE_AlbumGetNumTracks, 1);

            if(track_count <= 0) {
                throw new ApplicationException("Invalid track count from album query");
            }

            tracks = new SimpleTrack[track_count];

            for(int i = 1; i <= tracks.Length; i++) {
                client.Select(Rdf.MBS_SelectTrack, i);

                tracks[i - 1] = new SimpleTrack(i, 0);
                tracks[i - 1].Artist = client.GetResultData(Rdf.MBE_TrackGetArtistName);
                tracks[i - 1].Title = client.GetResultData(Rdf.MBE_TrackGetTrackName);

                int length = client.GetResultInt(Rdf.MBE_TrackGetTrackDuration);
                tracks[i - 1].Length = length / 1000;

                client.Select(Rdf.MBS_Back);
            }

            if(client.GetResultInt(Rdf.MBE_AlbumGetNumReleaseDates) > 0) {
                client.Select(Rdf.MBS_SelectReleaseDate, 1);
                release_date = Utilities.StringToDateTime(
                    client.GetResultData(Rdf.MBE_ReleaseGetDate));
                client.Select(Rdf.MBS_Back);
            }

            client.Select(Rdf.MBS_Back);
        }
Example #4
0
        public void QueryCDMetadata()
        {
            if (!client.Query(Rdf.MBQ_GetCDInfo))
            {
                throw new ApplicationException("Could not query CD");
            }

            int disc_count = client.GetResultInt(Rdf.MBE_GetNumAlbums);

            if (disc_count <= 0)
            {
                throw new ApplicationException("No Discs Found");
            }

            // handle more than 1 disc? not sure how this works? for multi-disc sets?
            // if that's the case, we only care about the first one I guess... I hope

            if (!client.Select(Rdf.MBS_SelectAlbum, 1))
            {
                throw new ApplicationException("Could not select disc");
            }

            amazon_asin   = client.GetResultData(Rdf.MBE_AlbumGetAmazonAsin, 1);
            cover_art_url = client.GetResultData(Rdf.MBE_AlbumGetAmazonCoverartURL, 1);
            artist_name   = client.GetResultData(Rdf.MBE_AlbumGetArtistName, 1);
            album_name    = client.GetResultData(Rdf.MBE_AlbumGetAlbumName, 1);

            int track_count = client.GetResultInt(Rdf.MBE_AlbumGetNumTracks, 1);

            if (track_count <= 0)
            {
                throw new ApplicationException("Invalid track count from album query");
            }

            tracks = new SimpleTrack[track_count];

            for (int i = 1; i <= tracks.Length; i++)
            {
                client.Select(Rdf.MBS_SelectTrack, i);

                tracks[i - 1]        = new SimpleTrack(i, lengths[i - 1]);
                tracks[i - 1].Artist = client.GetResultData(Rdf.MBE_TrackGetArtistName);
                tracks[i - 1].Title  = client.GetResultData(Rdf.MBE_TrackGetTrackName);

                int new_length = client.GetResultInt(Rdf.MBE_TrackGetTrackDuration);
                if (new_length > 0)
                {
                    tracks[i - 1].Length = new_length / 1000;
                }

                client.Select(Rdf.MBS_Back);
            }

            int num_releases = client.GetResultInt(Rdf.MBE_AlbumGetNumReleaseDates);

            if (num_releases > 0)
            {
                client.Select(Rdf.MBS_SelectReleaseDate, 1);

                string raw_date = client.GetResultData(Rdf.MBE_ReleaseGetDate);
                if (raw_date != null && raw_date != String.Empty)
                {
                    string [] parts = raw_date.Split('-');
                    if (parts.Length == 3)
                    {
                        int year  = Convert.ToInt32(parts[0]);
                        int month = Convert.ToInt32(parts[1]);
                        int day   = Convert.ToInt32(parts[2]);

                        release_date = new DateTime(year, month, day);
                    }
                }

                client.Select(Rdf.MBS_Back);
            }

            client.Select(Rdf.MBS_Back);
        }