Here's some info from the writer of ARENAME.. friendly guy ;-) I think I might stick with my script for now. I've changed it to dump mminfo once to a temp file and then grep it so that error message is under control. I'm enjoying the ability to easily pre-process on the tags and make filename and path decisions around:
- genre = "Speech" or "Audiobook"
- genre = "Soundtrack" or "Sound Track" or "Soundtracks"
- TPE2 = "Various Artists" (compilation - exposed if you use mminfo -d 1)
keith Hunniford wrote:
> Hey, This thing is great!
Hey there. Glad you like it. Also good to know, that the user base isn't
just me and the guy who packages it for debian.
May I ask where you got it from? Debian/Ubuntu? From github? Which
version are you running? If you're running off of github, make sure
you're using the `arename3' branch. I've started to work on `master'
again a week ago. So it has improved, but it's still fairly experimental
here and there.
> I have a question that I'm sure can be solved by hooks, but I don't
> get it.
Sure, there are different ways to do this. The `pre_template' and
`pre_expand_template' come to mind.
> Basically I would love to be able to specify effectively:
>
> if genre = "Soundtrack"
> compilation = true
> end
>
> so effectively, soundtracks would have the compilation_template applied
> to them.
The `pre_template' hook is run before the template-type for the current
file is chosen. If you'd put anything into the `compilation' tag at that
point, the compilation-type template would be chosen.
Here's some code for that:
sub soundtrack_is_compilation {
my ($n, $dat, $ext) = @_;
return if ($dat->{genre} !~ m/^Soundtrack$/i);
if (!defined $dat->{compilation} || $dat->{compilation} eq '') {
$dat->{compilation} = 'force_compilation';
}
}
register_hook('pre_template', \&soundtrack_is_compilation);
The problem with that is, that it may look crappy, it your compilation
template is using the "&compilation" tag.
The `pre_expand_template' is run *just* before the template is being
expanded. And it has access to the template string, so you could just
drop in the template string you'd like before it expands the one it
chose itself.
You could do it roughly like this:
sub soundtrack_is_compilation {
my ($n, $tmpl, $dat) = @_;
return if ($dat->{genre} !~ m/^Soundtrack$/i);
$$tmpl = get_opt('comp_template');
}
register_hook('pre_expand_template', \&soundtrack_is_compilation);
I think, the latter solution is the one, I'd use.
Note, that I didn't test any of this. Use --dry-run before until it
actually works.
Regards, Frank
--
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
-- RFC 1925