public void grab_should_return_the_correct_download_link(string song, string singer, int count) { var graber = new BaiduMp3Graber(); var result = graber.Grab(song, singer); Assert.AreEqual(count, result.Count); }
public void Execute(CommandContext context) { var parameters = context.CommandParameter.Split('|'); if (parameters.Length == 0) throw new ArgumentNullException(); var song = string.Empty; var singer = string.Empty; switch (parameters.Length) { case 1: song = parameters[0].Trim(); break; case 2: song = parameters[0].Trim(); singer = parameters[1].Trim(); break; } var graber = new BaiduMp3Graber(); var result = graber.Grab(song, singer); if (result.Count == 0) { SendComment(context, "�ܱ�Ǹ��û���ҵ�����Ҫ�ĸ�����"); return; } string downUrl; if (result.DLinks.Count != 0 && !string.IsNullOrEmpty(result.DLinks[0].Encode)) downUrl = result.DLinks[0].TrueDownloadUrl; else downUrl = result.Links[0].TrueDownloadUrl; SendComment(context, string.Format("#PCң����# ��ʼ�������ظ�����{0}, ���ص�ַΪ��{1}", song, downUrl)); DonwloadMp3(context.DownloadPath, downUrl, song, singer); SendComment(context, "�����������..."); }