예제 #1
0
        public async Task QueryPostsFromJSON(SearchList Searches)
        {
            var TaskList = new List <Task <bool> >();
            var ran      = new Random();

            foreach (var search in Searches.Queries)
            {
                if (search.Tags == string.Empty)
                {
                    continue;
                }
                var client = new HttpClient();
                client.DefaultRequestHeaders.UserAgent.ParseAdd("MFCD / 1.0 (By VelvetThePanda)");
                TaskList.Add(new QueryObject(client, search.Pages, string.Join(' ', search.Tags, search.Blacklist))
                {
                    Site = search.Site
                }.QueryPosts());
                Program.Log.Trace("Added Task to Task List.");
                await Task.Delay(ran.Next(15, 50));
            }
            Task queryTask = Task.WhenAll(TaskList).ContinueWith(_ => PostDownloadHelper.ThreadsFinished = true);
            //await Task.Delay(500);
            //Program.Log.Info("Waiting for Tasks to complete.");
            //await queryTask.ContinueWith(_ => PostDownloadHelper.ThreadsFinished = true);
        }
예제 #2
0
 private static void GenerateDirectories(SearchList config)
 {
     foreach (var search in config.Queries)
     {
         var unsanitizedFoldername = string.Join(' ', search.Tags, search.Blacklist);
         var sanitizedFoldername   = Regex.Replace(unsanitizedFoldername, "[\\/?:<>\"|]+", "", RegexOptions.IgnoreCase);
         if (sanitizedFoldername == " ")
         {
             continue;
         }
         Directory.CreateDirectory(sanitizedFoldername.TrimEnd());
     }
 }