public static void registerRetriever(AlbumArtRetriever retriever) { retrievers[retriever.getName()] = retriever; if (curRetriever == null) { curRetriever = retriever; } }
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(); }
// TODO: Maybe we should support searching from more than one retriever at the same time, which // would require a few changes in this class, plus minor tweaks in UI and AlbumArtServer public static void SelectRetriever(string Name) { curRetriever = retrievers[Name]; }
public static void registerRetriever(AlbumArtRetriever retriever) { retrievers[retriever.getName()] = retriever; if (curRetriever == null) curRetriever = retriever; }