public IEnumerable <DownloadMusicItem> Scrape(string query) { const int max_records = 100; SearchManager search_manager = new SearchManager(cookieContainer, session.Session); for (int i = 0; i < 16; i++) { var search_task = search_manager.Search( SearchBuilder.Build( SearchType.Video, query, NicoNicoTarget.Keyword, NicoNicoSort.StartTime, false) .Offset(i * max_records) .Limit(max_records) .Range(NicoNicoFilter.StartTime, NicoNicoFilterOperator.Gte, this.lastDateTime) ); var videoToAudioConveter = new VideoToAudioConveter(); videoToAudioConveter.TitleConverter = TitileConverterInfo.Build("format.txt", "bands.txt", "ignore.txt"); var search_result = search_task.Result; foreach (var search in search_result.Data) { Logger.Current.WriteLine(string.Format("getting titile from {0}", search.ContentId)); Logger.Current.WriteLine(string.Format("title:{0} description:{1}", search.Title, search.Description)); string title = videoToAudioConveter.GetMusicTitle(search.Title, search.Description); yield return(new DownloadMusicItem(search.ContentId, title)); } } using (StreamWriter sw = new StreamWriter(config_file_name)) { sw.WriteLine(DateTime.Now.ToString(date_format)); } }
public async static Task <BatchDownloadModel> LoginAsync(string email, string pass) { NicoNicoDownload nico = new NicoNicoDownload(); nico.TitleConverter = TitileConverterInfo.Build("format.txt", "bands.txt", "ignore.txt"); await nico.Login(email, pass); BatchDownloadModel _model = new BatchDownloadModel(nico); return(_model); }
public static TitileConverterInfo Build(string file_path, string known_band_file_path = null, string ignore_token_file_path = null) { TitileConverterInfo info = new TitileConverterInfo(); using (StreamReader sr = new StreamReader(file_path, Encoding.Default)) { info.OutputParttern = sr.ReadLine(); List <string> input_list = new List <string>(); while (!sr.EndOfStream) { input_list.Add(sr.ReadLine()); } info.InputPattern = input_list.ToArray(); } if (known_band_file_path != null) { using (StreamReader sr = new StreamReader(known_band_file_path, Encoding.Default)) { List <string> known_band = new List <string>(); while (!sr.EndOfStream) { known_band.Add(sr.ReadLine()); } info.KnownBandList = known_band.ToArray(); } } if (ignore_token_file_path != null) { using (StreamReader sr = new StreamReader(ignore_token_file_path, Encoding.Default)) { List <string> ignore_tokens = new List <string>(); while (!sr.EndOfStream) { ignore_tokens.Add(sr.ReadLine()); } info.IgnoreTokenList = ignore_tokens.ToArray(); } } return(info); }