SolveMedia Audio
Please read the Terms of Use for Materials on ZennoLab
Table of contents
Added in ZennoPoster 5.9.5.1 and CapMonster 2.5.5.0.
CapMonster2 has the ability to recognize the sound variant of the SolveMedia captcha. The ZennoLab.AudioSolveMedia module will be available in the program.
Usage in ZennoPoster
To send audio captchas from ZennoPoster, you can use the snippet we have prepared. The snippet code is available below. The snippet may be updated periodically. Follow the changes.
// Main settings
// waiting timeout
var waitTime = 1000;
// attempts to load captcha
var tryLoadElement = 60;
// show recognizing progress messages
var needShowMessages = true;
// folder for saving audio files
var mainAudiofolderName = "sm_audio";
// Additional variables
var tab = instance.ActiveTab;
var timeout = false;
var file = string.Empty;
var answer = string.Empty;
var fileLoadingError = false;
var audioFolder = string.Format("{0}\\{1}\\{2}", project.Directory, mainAudiofolderName, Guid.NewGuid().ToString());
Action CheckFileDeleting= () => {
if (File.Exists(file)) File.Delete(file);
if (Directory.Exists(audioFolder))
{
// check directory is empty
if ((Directory.GetDirectories(audioFolder).Length + Directory.GetFiles(audioFolder).Length) == 0)
Directory.Delete(audioFolder);
}
};
Action CheckMediaError= () => {
if (tab.URL.Contains("api.solvemedia.com/media/media-error.gif"))
throw new Exception("Error loading media");
};
Action CheckTimeOut= () => {
if (timeout)
throw new Exception("Timeout of loading element has been exceeded");
};
Action OpenAudioForm = () => {
project.SendInfoToLog("Opening the form with audio task", needShowMessages);
for (int k = 0; k < tryLoadElement; k++)
{
var audioButton = tab.FindElementByAttribute("a", "id", "adcopy-link-audio", "text", 0);
if (!audioButton.IsVoid)
{
audioButton.Click();
break;
}
System.Threading.Thread.Sleep(waitTime);
CheckMediaError();
if (k == (tryLoadElement - 1)) timeout = true;
}
CheckTimeOut();
};
Action GetAudioFile= () => {
for (int k = 0; k < tryLoadElement; k++)
{
var audioButton = tab.FindElementByAttribute("a", "innerhtml", "Download mp3 file", "text", 0);
if (!audioButton.IsVoid)
{
project.SendInfoToLog("Downloading audio file", needShowMessages);
audioButton.Click();
break;
}
else System.Threading.Thread.Sleep(waitTime);
CheckMediaError();
if (k == (tryLoadElement - 1)) timeout = true;
}
CheckTimeOut();
};
Action Recognize= () => {
// waiting loading file
tab.WaitDownloading();
CheckMediaError();
file = audioFolder + "\\media.mp3";
for (int k = 0; k < tryLoadElement; k++)
{
if (File.Exists(file)) break;
else System.Threading.Thread.Sleep(waitTime);
if (k == (tryLoadElement - 1)) timeout = true;
}
CheckTimeOut();
// getting audio bytes
var bytes = File.ReadAllBytes(file);
if (bytes.Length < 1024) throw new Exception("Error loading file");
project.SendInfoToLog("Recognizing", needShowMessages);
string str = Convert.ToBase64String(bytes);
var rc = ZennoPoster.CaptchaRecognition("CapMonster2.dll", str, "CapMonsterModule=ZennoLab.AudioSolveMedia&ParallelMode=true");
answer = rc.Split(new [] {"-|-"}, StringSplitOptions.RemoveEmptyEntries)[0];
};
Action InputAnswer= () => {
if (!String.IsNullOrEmpty(answer) && answer != "sorry")
{
project.SendInfoToLog("Inserting answer", needShowMessages);
HtmlElement audioAnswerInput = tab.FindElementByAttribute("input:text", "id", "adcopy_response", "text", 0);
if (!audioAnswerInput.IsVoid)
{
audioAnswerInput.SetValue(answer, "None", false);
}
System.Threading.Thread.Sleep(waitTime);
}
else throw new Exception("Answer not received");
};
// Recognizing captcha
try
{
instance.DownloadsPath = audioFolder;
OpenAudioForm();
GetAudioFile();
Recognize();
InputAnswer();
return "ok";
}
finally
{
CheckFileDeleting();
}
Notes on recognition quality
We draw your attention to the need to use high-quality proxies. Both the graphical version of this captcha and the sound one, with repeated use, begin to be strongly distorted, which makes it difficult to recognize, both for a person and for our system. In this regard, the percentage specified in the module is relative. So, with a "fresh" IP-address, the percentage is often higher than the declared one, and after several hundred recognized captchas it starts to decrease for natural reasons. Also, the number of words spoken in the audio recording affects.
Note
Before loading the page on which Solve Media is located and using the snippet, you need to turn off the plugins, otherwise the link to download the audio file will not appear.
You should pay attention to the main parameters of the snippet execution, which you can change to suit your needs: the waiting time for the element to load, the number of attempts to load the element on the page, the folder for temporary storage of audio files, which will be created in the directory with your project:
// waiting timeout
var waitTime = 1000;
// attempts to load web element
var tryLoadElement = 60;
// folder for saving audio files
var mainAudiofolderName = "sm_audio";
The function of sending captcha to the service looks like this:
ZennoPoster.CaptchaRecognition("CapMonster2.dll", base64StringAudioBytes, "CapMonsterModule=ZennoLab.AudioSolveMedia");
Â