private async Task ProcessImageAsync(string title)
        {
            try
            {
                // Fetch page info / Attachment info
                var page = await UpstreamContentHelper.GetPageAsync(title);
                if (page == null) return;
                // Acquire image info
                var imgs = UpstreamContentHelper.GetImagesAsync(page.Parse.Text.Content);
                if (imgs == null) return;
                var mod = new ContentModerator(AppSettings.OcpApimIdentificationKey);
                var racyFlag = false;
                var adultFlag = false;
                foreach (var img in imgs)
                {
                    try
                    {
                        // Query image
                        var result = await mod.EvaluateImageAsync(img.Value);
                        if (result.IsImageAdultClassified) adultFlag = true;
                        if (result.IsImageRacyClassified) racyFlag = true;
                    }
                    catch (Exception ex)
                    {
                        
                    }
                }

                // Decide result
                if (adultFlag || racyFlag)
                {
                    // Login in if not
                    if (AppSettings.Token == null)
                        await WikiAuth.LoginAndSaveConfigurationAsync(AppSettings.Username, AppSettings.Password);

                    // Set tag
                    await UpstreamContentHelper.AddTag(page.Parse.RevId, TagName, TagReason);
                }
            }
            catch (Exception ex)
            {
                
            }
        }
Ejemplo n.º 2
0
 public async Task TestEvaluationAsync()
 {
     var mod = new ContentModerator("YOU FORGOT TO INPUT YOUR KEY");
     var result = await mod.EvaluateImageAsync("YOU FORGOT TO SPECIFY R18 IMAGE PATH");
     Assert.AreEqual(true, result.IsImageAdultClassified);
 }