Exemple #1
0
        private void link_ButtonPressed(QButton Button)
        {
            switch (this.View)
            {
            case AlbumDetailView.AlbumInfo:
            case AlbumDetailView.Lyrics:
                if (albumURL.Length > 0)
                {
                    Net.BrowseTo(albumURL);
                }
                else
                {
                    Net.BrowseTo(LastFM.GetLastFMAlbumURL(CurrentTrack));
                }
                break;

            case AlbumDetailView.ArtistInfo:
                if (artistURL.Length > 0)
                {
                    Net.BrowseTo(artistURL);
                }
                else
                {
                    Net.BrowseTo(LastFM.GetLastFMArtistURL(CurrentTrack));
                }
                break;
            }
        }
Exemple #2
0
 private void initUpdateAlbum()
 {
     LastFM.UpdateAlbumInfo(CurrentTrack, updateAlbum);
 }
Exemple #3
0
 private void initUpdateArtist()
 {
     LastFM.UpdateArtistInfo(CurrentTrack, updateArtist);
 }
Exemple #4
0
        public static ImageItem ImageFromLastFM(string Artist, string Album)
        {
            string key = Artist + Album;

            if (items.ContainsKey(key))
            {
                return(items[key]);
            }

            if (Artist.Length == 0 || Album.Length == 0)
            {
                addToItems(key, null);
                return(null);
            }

            try
            {
                string url = LastFM.GetAlbumImageURL(Artist, Album);

                if (url.Length > 0)
                {
                    System.Net.HttpWebRequest  httpRequest  = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url);
                    System.Net.HttpWebResponse httpResponse = (System.Net.HttpWebResponse)httpRequest.GetResponse();

                    httpRequest.ServicePoint.Expect100Continue = false;

                    Stream imageStream = httpResponse.GetResponseStream();

                    ImageItem ii = new ImageItem();
                    ii.filePath = key;

                    List <byte[]> bytes  = new List <byte[]>();
                    int           length = 0;
                    int           numRead;
                    byte[]        bb = new byte[100000];

                    while ((numRead = imageStream.Read(bb, 0, 100000)) > 0)
                    {
                        if (numRead < 100000)
                        {
                            byte[] bbbb = new byte[numRead];
                            Array.Copy(bb, bbbb, numRead);
                            bb = bbbb;
                        }
                        bytes.Add(bb);
                        length += numRead;
                        bb      = new byte[100000];
                    }

                    byte[] bbb    = new byte[length];
                    int    cursor = 0;
                    foreach (byte[] b in bytes)
                    {
                        Array.Copy(b, 0, bbb, cursor, Math.Min(length, b.Length));
                        length -= b.Length;
                        cursor += b.Length;
                    }

                    ii.imageData.Data = bbb;
                    ii.Src            = Source.Download;

                    httpResponse.Close();
                    imageStream.Close();

                    ii.it = typeFromExtension(url);

                    addToItems(key, ii);
                    return(ii);
                }
                else
                {
                    addToItems(key, null);
                    return(null);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());

                if (StringUtil.HasParentheticalChars(Album))
                {
                    return(ImageFromLastFM(Artist, StringUtil.RemoveParentheticalChars(Album)));
                }
            }
            addToItems(key, null);
            return(null);
        }