public static Collection <PartialMatche> Search(string strAlbum, GraceNoteLanguage language, string artist) { Uri strUrl = new Uri(string.Format(@"https://c{0}.web.cddbp.net/webapi/xml/1.0/", ClientId)); if (string.IsNullOrWhiteSpace(_userId)) { _userId = Register(); } if (string.IsNullOrWhiteSpace(_userId) == false) { string query = string.Format(@"<QUERIES> <AUTH> <CLIENT>{0}</CLIENT> <USER>{1}</USER> </AUTH> <LANG>{2}</LANG> <QUERY CMD=""ALBUM_SEARCH""> <TEXT TYPE=""ALBUM_TITLE"">{3}</TEXT>", ClientId, _userId, language, strAlbum); if (string.IsNullOrWhiteSpace(artist) == false) { query += string.Format(@"<TEXT TYPE=""ARTIST"">{0}</TEXT>", artist); } query += @" </QUERY> </QUERIES>"; XElement restResponse = XElement.Parse(Util.PostRequest(strUrl, query)); return(GraceNote.AlbumToPartialMatch(restResponse)); } return(null); }
private static string Register() { Uri strUrl = new Uri(string.Format(@"https://c{0}.web.cddbp.net/webapi/xml/1.0/", ClientId)); string query = string.Format(@"<QUERIES> <QUERY CMD=""REGISTER""> <CLIENT>{0}</CLIENT> </QUERY> </QUERIES>", ClientId); string result = Util.PostRequest(strUrl, query); if (string.IsNullOrWhiteSpace(result) == false) { XElement restResponse = XElement.Parse(result); return(GraceNote.GetClientId(restResponse)); } else { return(null); } }
protected GraceNote ReadGraceNote() { GraceNote graceNote = new GraceNote(); int i; byte[] b = new byte[4]; for (i = 0; i < 4; i++) { b[i] = ReadByte(); } graceNote.Fret = b[0]; graceNote.Dynamic = (Dynamic)Enum.ToObject(typeof(Dynamic), b[1]); graceNote.Transition = (GraceNoteTransition)Enum.ToObject(typeof(GraceNoteTransition), b[2]); graceNote.Duration = (Duration)Enum.ToObject(typeof(Duration), 3 - b[3]); return(graceNote); }
protected GraceNote ReadGraceNote() { //TODO: //grace.setDead( (flags & 0x01) != 0 ); //grace.setOnBeat( (flags & 0x02) != 0 ); GraceNote graceNote = new GraceNote(); graceNote.Fret = ReadByte(); //TODO var dynamic = (Dynamic)Enum.ToObject(typeof(Dynamic), ReadByte()); graceNote.Dynamic = Dynamic.Invalid; //TODO var transition = (GraceNoteTransition)Enum.ToObject(typeof(GraceNoteTransition), ReadByte()); graceNote.Transition = GraceNoteTransition.None; graceNote.Duration = (Duration)Enum.ToObject(typeof(Duration), (byte)(3 - ReadByte())); int flags = ReadByte(); return(graceNote); }
protected GraceNote ReadGraceNote() { GraceNote graceNote = new GraceNote(); int i; byte[] b = new byte[4]; for (i = 0; i < 4; i++) b[i] = ReadByte(); graceNote.Fret = b[0]; graceNote.Dynamic = (Dynamic)Enum.ToObject(typeof(Dynamic), b[1]); graceNote.Transition = (GraceNoteTransition)Enum.ToObject(typeof(GraceNoteTransition), b[2]); graceNote.Duration = (Duration)Enum.ToObject(typeof(Duration), 3 - b[3]); return graceNote; }
public static Hashtable Parse(string id, GraceNoteLanguage language) { Hashtable objResuls = new Hashtable(); try { //FIX 2.7.12.0 if (string.IsNullOrWhiteSpace(id) == true) { return(objResuls); } Uri strUrl = new Uri(string.Format(@"https://c{0}.web.cddbp.net/webapi/xml/1.0/", ClientId)); if (string.IsNullOrWhiteSpace(_userId)) { _userId = Register(); } if (string.IsNullOrWhiteSpace(_userId) == false) { string query = string.Format(@"<QUERIES> <AUTH> <CLIENT>{0}</CLIENT> <USER>{1}</USER> </AUTH> <LANG>{2}</LANG> <QUERY CMD=""ALBUM_FETCH""> <GN_ID>{3}</GN_ID> <OPTION> <PARAMETER>SELECT_EXTENDED</PARAMETER> <VALUE>COVER,ARTIST_IMAGE,CONTENT,ARTIST_BIOGRAPHY,REVIEW,ARTIST_OET,MOOD,TEMPO</VALUE> </OPTION> <OPTION> <PARAMETER>COVER_SIZE</PARAMETER> <VALUE>LARGE</VALUE> </OPTION> </QUERY> </QUERIES>", ClientId, _userId, language, id); XElement restResponse = XElement.Parse(Util.PostRequest(strUrl, query)); GraceNote graceNote = GraceNote.AlbumToObject(restResponse); //FIX 2.8.9.0 if (graceNote != null) { objResuls.Add("Title", graceNote.AlbumName); #region Album objResuls.Add("Album", graceNote.AlbumName); #endregion #region Artist Artist artist = ParseArtist(graceNote.ArtistName, graceNote.ArtistUrl, graceNote.ArtistImage); if (artist != null) { objResuls.Add("Artist", artist); } #endregion #region Description if (string.IsNullOrWhiteSpace(graceNote.AlbumDescription) == false) { objResuls.Add("Description", graceNote.AlbumDescription); } #endregion #region Image if (string.IsNullOrWhiteSpace(graceNote.AlbumImage) == false) { objResuls.Add("Image", graceNote.AlbumImage); } #endregion #region Tracks objResuls.Add("Tracks", graceNote.AlbumTracks); #endregion #region Types if (graceNote.AlbumTypes != null) { objResuls.Add("Types", graceNote.AlbumTypes); } #endregion } } return(objResuls); } catch (Exception ex) { Util.LogException(ex, id); return(null); } }
protected GraceNote ReadGraceNote() { //TODO: //grace.setDead( (flags & 0x01) != 0 ); //grace.setOnBeat( (flags & 0x02) != 0 ); GraceNote graceNote = new GraceNote(); graceNote.Fret = ReadByte(); //TODO var dynamic = (Dynamic)Enum.ToObject(typeof(Dynamic), ReadByte()); graceNote.Dynamic = Dynamic.Invalid; //TODO var transition = (GraceNoteTransition)Enum.ToObject(typeof(GraceNoteTransition), ReadByte()); graceNote.Transition = GraceNoteTransition.None; graceNote.Duration = (Duration)Enum.ToObject(typeof(Duration), (byte)(3 - ReadByte())); int flags = ReadByte(); return graceNote; }