Created
June 7, 2015 13:21
-
-
Save azihassan/0f3191fcd8b99db04d4b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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