示例#1
0
 public static Query <Release> Query(ReleaseQueryParameters parameters)
 {
     if (parameters == null)
     {
         throw new ArgumentNullException("parameters");
     }
     return(new Query <Release> (EXTENSION, parameters.ToString()));
 }
示例#2
0
        public static Query <Release> QueryFromDevice(string device)
        {
            if (device == null)
            {
                throw new ArgumentNullException("device");
            }

            ReleaseQueryParameters parameters = new ReleaseQueryParameters();

            parameters.DiscId = LocalDisc.GetFromDevice(device).Id;
            return(Query(parameters));
        }
示例#3
0
        public static Query <Release> Query(Disc disc)
        {
            if (disc == null)
            {
                throw new ArgumentNullException("disc");
            }

            ReleaseQueryParameters parameters = new ReleaseQueryParameters();

            parameters.DiscId = disc.Id;
            return(Query(parameters));
        }
示例#4
0
        public static Query <Release> Query(string title)
        {
            if (title == null)
            {
                throw new ArgumentNullException("title");
            }

            ReleaseQueryParameters parameters = new ReleaseQueryParameters();

            parameters.Title = title;
            return(Query(parameters));
        }
示例#5
0
文件: Release.cs 项目: pulb/basenji
        public static Query<Release> QueryFromDevice(string device)
        {
            if (device == null) throw new ArgumentNullException ("device");

            ReleaseQueryParameters parameters = new ReleaseQueryParameters ();
            parameters.DiscId = LocalDisc.GetFromDevice (device).Id;
            return Query (parameters);
        }
示例#6
0
文件: Release.cs 项目: pulb/basenji
 public static Query<Release> Query(ReleaseQueryParameters parameters)
 {
     if (parameters == null) throw new ArgumentNullException ("parameters");
     return new Query<Release> (EXTENSION, parameters.ToString ());
 }
示例#7
0
文件: Release.cs 项目: pulb/basenji
        public static Query<Release> Query(Disc disc)
        {
            if (disc == null) throw new ArgumentNullException ("disc");

            ReleaseQueryParameters parameters = new ReleaseQueryParameters ();
            parameters.DiscId = disc.Id;
            return Query (parameters);
        }
示例#8
0
文件: Release.cs 项目: pulb/basenji
        public static Query<Release> Query(string title, string artist)
        {
            if (title == null) throw new ArgumentNullException ("title");
            if (artist == null) throw new ArgumentNullException ("artist");

            ReleaseQueryParameters parameters = new ReleaseQueryParameters ();
            parameters.Title = title;
            parameters.Artist = artist;
            return Query (parameters);
        }
示例#9
0
        public bool Lookup ()
        {

            if (Track == null || (Track.MediaAttributes & TrackMediaAttributes.Podcast) != 0) {
                return false;
            }

            string artwork_id = Track.ArtworkId;

            if (artwork_id == null) {
                return false;
            } else if (CoverArtSpec.CoverExists (artwork_id)) {
                return false;
            } else if (!InternetConnected) {
                return false;
            }

            DatabaseTrackInfo dbtrack;
            dbtrack = Track as DatabaseTrackInfo;

            Release release;

            // If we have the MBID of the album, we can do a direct MusicBrainz lookup
            if (dbtrack != null && dbtrack.AlbumMusicBrainzId != null) {

                release = Release.Get (dbtrack.AlbumMusicBrainzId);
                if (!String.IsNullOrEmpty (release.GetAsin ()) && SaveCover (String.Format (AmazonUriFormat, release.GetAsin ()))) {
                    return true;
                }

            // Otherwise we do a MusicBrainz search
            } else {
                ReleaseQueryParameters parameters = new ReleaseQueryParameters ();
                parameters.Title = Track.AlbumTitle;
                parameters.Artist = Track.AlbumArtist;
                if (dbtrack != null) {
                    parameters.TrackCount = dbtrack.TrackCount;
                }

                Query<Release> query = Release.Query (parameters);
                release = query.PerfectMatch ();

                foreach (Release r in query.Best ()) {
                    if (!String.IsNullOrEmpty (r.GetAsin ()) && SaveCover (String.Format (AmazonUriFormat, r.GetAsin ()))) {
                        return true;
                    }
                }
            }

            if (release == null) {
                return false;
            }

            // No success with ASIN, let's try with other linked URLs
            ReadOnlyCollection<UrlRelation> relations = release.GetUrlRelations ();
            foreach (UrlRelation relation in relations) {

                foreach (CoverArtSite site in CoverArtSites) {

                   Match m = site.Regex.Match (relation.Target.AbsoluteUri);
                   if (m.Success) {
                        string [] parameters = new string [m.Groups.Count];
                        for (int i = 1; i < m.Groups.Count; i++) {
                            parameters[i-1] = m.Groups[i].Value;
                        }

                        String uri = String.Format (site.ImgURI, parameters);
                        if (SaveCover (uri)) {
                             return true;
                        }
                   }
                }

                if (relation.Type == "CoverArtLink" && SaveCover (relation.Target.AbsoluteUri)) {
                   return true;
                }
            }

            return false;
        }
示例#10
0
文件: Release.cs 项目: hannuraina/tag
        public static Query<Release> Query (string title, int limit)
        {
            if (title == null) throw new ArgumentNullException ("title");

            ReleaseQueryParameters parameters = new ReleaseQueryParameters ();
            parameters.Title = title;
            return Query (parameters, limit);
        }