Esempio n. 1
0
        //last.fm API
        private IEnumerable <Result> processRecommendationQuery(string query)
        {
            List <Result> results        = new List <Result>(N_RECOMMEND);
            var           name           = query.Replace("!similarto", "").Trim();
            var           artist         = new Lastfm.Services.Artist(name, session);
            var           similarArtists = artist.GetSimilar(N_RECOMMEND);

            foreach (var a in similarArtists)
            {
                results.Add(new Result {
                    Artist = a.Name, URL = a.URL
                });
            }
            return(results);
        }
Esempio n. 2
0
 //last.fm API
 private IEnumerable<Result> processRecommendationQuery(string query)
 {
     List<Result> results = new List<Result>(N_RECOMMEND);
     var name = query.Replace("!similarto","").Trim();
     var artist = new Lastfm.Services.Artist(name, session);
     var similarArtists = artist.GetSimilar(N_RECOMMEND);
     foreach (var a in similarArtists)
     {
         results.Add(new Result { Artist = a.Name, URL = a.URL });
     }
     return results;
 }
Esempio n. 3
0
 public Track(Artist artist, string title, Session session)
     : base(session)
 {
     Title  = title;
     Artist = artist;
 }
Esempio n. 4
0
 public Track(string artistName, string title, Session session)
     : base(session)
 {
     Title  = title;
     Artist = new Artist(artistName, Session);
 }
Esempio n. 5
0
 /// <summary>
 /// Create an album.
 /// </summary>
 /// <param name="artist">A <see cref="Artist"/></param>
 /// <param name="title">A <see cref="string"/></param>
 /// <param name="session">A <see cref="Session"/></param>
 public Album(Artist artist, string title, Session session) : base(session)
 {
     Artist = artist;
     Title  = title;
 }
Esempio n. 6
0
 /// <summary>
 /// Createa an album object.
 /// </summary>
 /// <param name="artistName">A <see cref="string"/></param>
 /// <param name="title">A <see cref="string"/></param>
 /// <param name="session">A <see cref="Session"/></param>
 public Album(string artistName, string title, Session session) : base(session)
 {
     Artist = new Artist(artistName, Session);
     Title  = title;
 }
        public bool SetSkinProperties(YouTubeEntry youTubeEntry, string prefix, bool grab, bool download)
        {
            if (youTubeEntry == null)
            return true;
              ArtistItem artistItem = DatabaseProvider.InstanInstance.GetArtist(youTubeEntry);
              if (artistItem == null && grab)
              {
            string vidId = Youtube2MP.GetVideoId(youTubeEntry);
            artistItem = SitesCache.GetByVideoId(vidId) != null
                       ? Grabber.GetFromVideoSite(SitesCache.GetByVideoId(vidId).SIte)
                       : Grabber.GetFromVideoId(vidId);
              }
              if (artistItem == null)
              {
            string art = GetArtistName(youTubeEntry.Title.Text);
            artistItem = GetArtistsByName(art);
              }
              if ((artistItem == null || string.IsNullOrEmpty(artistItem.Bio) || string.IsNullOrEmpty(artistItem.Img_url)) && grab)
              {
            if (artistItem == null || string.IsNullOrEmpty((artistItem.Name)))
              artistItem = new ArtistItem() {Name = GetArtistName(youTubeEntry.Title.Text)};

            try
            {
              Lastfm.Services.Artist artist = new Lastfm.Services.Artist(artistItem.Name, Youtube2MP.LastFmProfile.Session);
              if (string.IsNullOrEmpty(artistItem.Img_url))
              {
            artistItem.Img_url = artist.GetImageURL(ImageSize.Huge);
              }
              if (string.IsNullOrEmpty(artistItem.Bio))
              {
            ArtistBio artistBio = artist.Bio;
            artistBio.Lang = GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage());
            string contents = Regex.Replace(HttpUtility.HtmlDecode(artistBio.getContent()), "<.*?>",
                                            string.Empty);
            if (string.IsNullOrEmpty(contents))
            {
              artistBio.Lang = string.Empty;
              contents = Regex.Replace(HttpUtility.HtmlDecode(artistBio.getContent()), "<.*?>",
                                       string.Empty);
            }
            artistItem.Bio = contents;
              }
              if (string.IsNullOrEmpty(artistItem.Tags))
              {
            int i = 0;
            string tags = "";
            TopTag[] topTags = artist.GetTopTags();
            foreach (TopTag tag in topTags)
            {
              tags += tag.Item.Name + "|";
              if (i < 5)
              {
                if (!string.IsNullOrEmpty(artistItem.Id))
                  SaveTag(artistItem, tag.Item.Name);
              }
              i++;
            }
            artistItem.Tags = tags;
              }
              DatabaseProvider.InstanInstance.AddArtist(artistItem);
            }
            catch (Exception exception)
            {
              Log.Debug(exception.Message);
            }
              }
              if (artistItem != null)
              {
            if (download && !File.Exists(artistItem.LocalImage))
            {
              Youtube2MP.DownloadFile(artistItem.Img_url, artistItem.LocalImage);
            }
            SetSkinProperties(artistItem, prefix);
              }
              return false;
        }
Esempio n. 8
0
        public bool SetSkinProperties(YouTubeEntry youTubeEntry, string prefix, bool grab, bool download)
        {
            if (youTubeEntry == null)
            {
                return(true);
            }
            ArtistItem artistItem = DatabaseProvider.InstanInstance.GetArtist(youTubeEntry);

            if (artistItem == null && grab)
            {
                string vidId = Youtube2MP.GetVideoId(youTubeEntry);
                artistItem = SitesCache.GetByVideoId(vidId) != null
                       ? Grabber.GetFromVideoSite(SitesCache.GetByVideoId(vidId).SIte)
                       : Grabber.GetFromVideoId(vidId);
            }
            if (artistItem == null)
            {
                string art = GetArtistName(youTubeEntry.Title.Text);
                artistItem = GetArtistsByName(art);
            }
            if ((artistItem == null || string.IsNullOrEmpty(artistItem.Bio) || string.IsNullOrEmpty(artistItem.Img_url)) && grab)
            {
                if (artistItem == null || string.IsNullOrEmpty((artistItem.Name)))
                {
                    artistItem = new ArtistItem()
                    {
                        Name = GetArtistName(youTubeEntry.Title.Text)
                    }
                }
                ;

                try
                {
                    Lastfm.Services.Artist artist = new Lastfm.Services.Artist(artistItem.Name, Youtube2MP.LastFmProfile.Session);
                    if (string.IsNullOrEmpty(artistItem.Img_url))
                    {
                        artistItem.Img_url = artist.GetImageURL(ImageSize.Huge);
                    }
                    if (string.IsNullOrEmpty(artistItem.Bio))
                    {
                        ArtistBio artistBio = artist.Bio;
                        artistBio.Lang = GUILocalizeStrings.GetCultureName(GUILocalizeStrings.CurrentLanguage());
                        string contents = Regex.Replace(HttpUtility.HtmlDecode(artistBio.getContent()), "<.*?>",
                                                        string.Empty);
                        if (string.IsNullOrEmpty(contents))
                        {
                            artistBio.Lang = string.Empty;
                            contents       = Regex.Replace(HttpUtility.HtmlDecode(artistBio.getContent()), "<.*?>",
                                                           string.Empty);
                        }
                        artistItem.Bio = contents;
                    }
                    if (string.IsNullOrEmpty(artistItem.Tags))
                    {
                        int      i       = 0;
                        string   tags    = "";
                        TopTag[] topTags = artist.GetTopTags();
                        foreach (TopTag tag in topTags)
                        {
                            tags += tag.Item.Name + "|";
                            if (i < 5)
                            {
                                if (!string.IsNullOrEmpty(artistItem.Id))
                                {
                                    SaveTag(artistItem, tag.Item.Name);
                                }
                            }
                            i++;
                        }
                        artistItem.Tags = tags;
                    }
                    DatabaseProvider.InstanInstance.AddArtist(artistItem);
                }
                catch (Exception exception)
                {
                    Log.Debug(exception.Message);
                }
            }
            if (artistItem != null)
            {
                if (download && !File.Exists(artistItem.LocalImage))
                {
                    Youtube2MP.DownloadFile(artistItem.Img_url, artistItem.LocalImage);
                }
                SetSkinProperties(artistItem, prefix);
            }
            return(false);
        }