Skip to content

Instantly share code, notes, and snippets.

@azihassan
Created June 7, 2015 13:21
Show Gist options
  • Save azihassan/0f3191fcd8b99db04d4b to your computer and use it in GitHub Desktop.
Save azihassan/0f3191fcd8b99db04d4b to your computer and use it in GitHub Desktop.
loadDetailsButton.click ~= &loadDetailsButton;
//...
void loadDetailsCallback(Control sender, EventArgs ea)
{
if(!urlBox.text)
{
msgBox("No URL was provided.", "Error", MsgBoxButtons.OK, MsgBoxIcon.INFORMATION);
urlBox.focus();
return;
}
this.qualityBox.items.add("0 - video/unknown - N/A - N/A");
qualityBox.invoke(delegate Object(Object[]) {
loadDetails();
return null;
});
}
void loadDetails()
{
try
{
loadDetailsButton.enabled = false;
auto parser = new Youtube(urlBox.text);
VideoInfo vid = parser.process();
titleBox.text = vid.title;
foreach(q; vid.qualities)
{
qualityBox.beginUpdate();
writeln(q.itag.to!string, ", ", q.type, ", ", q.quality, ", ", q.link);
qualityBox.addRow(q.itag.to!string, q.type, q.quality, q.link);
qualityBox.endUpdate();
}
}
catch(Exception e)
{
msgBox("Failed to parse the info : " ~ e.msg, "Error", MsgBoxButtons.OK, MsgBoxIcon.ERROR);
}
finally
{
loadDetailsButton.enabled = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment