Beispiel #1
0
 private void chkRetriever_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (chkRetriever.CheckedItems.Count > 0)
     {
         AlbumArtRetrieverManager.SelectRetriever(chkRetriever.CheckedItems[0].ToString());
     }
     lblSelectedRetriever.Text = AlbumArtRetrieverManager.getSelectedRetriever().getName();
 }
        private static void Process(Object param)
        {
            HttpListenerContext context = (HttpListenerContext)param;
            Encoding            encoder = new UTF8Encoding();

            string url = context.Request.Url.AbsolutePath;

            Match url_match = Regex.Match(url, SearchUrlMatcher);

            if (!url_match.Success)
            {
                Form1.LogInfo("Unknown URL: " + url);
                return;
            }
            String AlbumName  = HttpUtility.UrlDecode(url_match.Groups["Album"].ToString());
            String ArtistName = HttpUtility.UrlDecode(url_match.Groups["Artist"].ToString());

            AlbumArtRetriever retriever = AlbumArtRetrieverManager.getSelectedRetriever();

            int    album_count = 0;
            String result_line = "";

            foreach (AlbumInfo album in retriever.retrieve(ArtistName, AlbumName))
            {
                album_count++;
                result_line += String.Format(PicRegexGenerator, album.AlbumArtURL, album.AlbumName, album.Artist);
            }
            Match  m = Regex.Match(result_line, PicRegex);
            String s = m.Groups["Artist"].Value;

            byte[] result_bytes = encoder.GetBytes(result_line);
            context.Response.OutputStream.Write(result_bytes, 0, result_bytes.Length);
            Form1.LogInfo(String.Format("Search of {0} {1} via {2} returned {3} albums.",
                                        new object[] { ArtistName, AlbumName, retriever.getName(), album_count }));

            context.Response.OutputStream.Close();
        }