I have in my possession a Microsoft Powershell script which examines all the files in a folded ending in .wtv (Windows Media Center recorded TV programmes), extracts some metadata (using a DLL called "Toub.MediaCenter.Dvrms.dll") and then writes it to stdout:
[void][System.Reflection.Assembly]::LoadFile("C:\Toub.MediaCenter.Dvrms.dll")
# Get all files ending in .wtv
foreach ($file in gci "*.wtv")
{
$wtv = New-Object Toub.Mediacenter.Dvrms.Metadata.DvrmsMetadataEditor($file)
$attrlist = $wtv.GetAttributes()
# Extract the Title and Description from the recorded programme
$t = $attrlist["Title"].value
$d = $attrlist["WM/SubTitleDescription"].value
# Print them to STDOUT
"$t"
"$d"
}
At the moment, I run this from a Perl script and then parse the results. It works, but is messy and I'd like to drop the powershell part and do it entirely within Perl.
However, I have absolutely no idea how to link to a DLL so that I can call GetAttributes method on a file and then extract the values of Title and WM/SubTitleDescription.
I was pointed to using Win32::API, but I have no idea what the name of the library from which I want to import the function nor do I know the C prototype of the function.
As such, my code grinds to a halt because I'm not really sure what I should be doing with Win32::API. My (very basic) stub looks like this:
use Win32::API;
foreach my $file (glob("*.wtv"))
{
my $wtv = new Win32::API(...stuck here...);
# Complete guesswork from here on...
print $wtv->GetAttributes("Title") . "\n";
print $wtv->GetAttributes("WM/SubTitleDescription") . "\n";
}
I'm guessing it's probably obvious from the Powershell above on what I should be putting into the new Win32::API line and whether or not $wtv->GetAttributes is correct - but to be honest, I don't have a clue.
Can someone please point me in the right direction?