예제 #1
0
        /// <summary>
        ///     The Master resource represents a set of similar Releases. Masters (also known as “master releases”) have a “main
        ///     Release” which is often the chronologically earliest.
        /// </summary>
        /// <param name="id">The Master ID</param>
        /// <param name="key">User Key</param>
        /// <param name="secretKey">User Secret Key</param>
        /// <returns></returns>
        public static MasterRelease MasterRelease(string id, string key = "", string secretKey = "")
        {
            var ret = new MasterRelease();

            if (key == "")
            {
                key = Settings.Discogs.Key;
            }

            if (secretKey == "")
            {
                secretKey = Settings.Discogs.SecretKey;
            }

            var le = new LogEntry("Sites.Discogs", "Search", "MasterRelease");

            le.Parameters.Add(new Para("id", id));
            le.Parameters.Add(new Para("key", key));
            le.Parameters.Add(new Para("secretKey", secretKey));
            Logging.NewLogEntry(le);

            try
            {
                ret.Data =
                    Json.Deserialize <MasterReleaseResult>(
                        Http.Request("https://api.discogs.com/masters/" + id + "?key=" + key + "&secret=" + secretKey)) ??
                    new MasterReleaseResult();
            }
            catch (Exception ex)
            {
                Exceptions.NewException(ex);
            }

            return(new MasterRelease(ret.Data));
        }
예제 #2
0
 public void Insert(MasterRelease master)
 {
     this.cmdMaster["id"]             = master.Id;
     this.cmdMaster["main_release"]   = master.MainRelease;
     this.cmdMaster["title"]          = master.Title ?? "";
     this.cmdMaster["joined_artists"] = master.Aggregate.JoinedArtistsFixed;
     this.cmdMaster["year"]           = master.Year;
     this.cmdMaster["notes"]          = master.Notes ?? "";
     this.cmdMaster.Execute();
     this.InsertReleaseArtists(master, 0, master.Id);
     if (master.Genres != null)
     {
         this.InsertReleaseGenres(master, 0, master.Id);
     }
     if (master.Images != null)
     {
         this.InsertReleaseImages(master, 0, master.Id);
     }
     if (master.Styles != null)
     {
         this.InsertReleaseStyles(master, 0, master.Id);
     }
     if (master.Tracklist != null)
     {
         this.InsertReleaseTracks(master, 0, master.Id);
     }
 }