INTERACT FORUM

More => Old Versions => Media Center 11 (Development Ended) => Topic started by: EpF on April 14, 2005, 02:06:19 am

Title: Database Expressions are Cool!
Post by: EpF on April 14, 2005, 02:06:19 am
Yeah, I know, most people know that already!  Just wanted to say thanks for this feature, cause I'm just starting to get to understand it now... 

I used the following expression to really streamline my [Image File] column for view schemes, and it stops it from doing wild and crazy things when the columns are resized after tagging - and it's great!! All I get is a yes or no, instead of a big long file path... ;D

FormatBoolean(IsEmpty([Image File]), No, Yes)

By the way J River, the IsEmpty function is not documented on this page:
http://www.jrmediacenter.com/DevZone/DBExpressions.htm

Thanks for all the work; looking forward to whatever you come up with next...!   ;)

Listening to 'Hardcore' by DJ Shadow, from 'In-Fluxuations (Disc 2)' (1995)
Title: Re: Database Expressions are Cool!
Post by: risingdamp on April 14, 2005, 02:54:07 am
That's a great example of how to use expressions and it's given me an idea to improve MC further. 

Most people will not be sufficiently skilled to be able to come up with that expression. It would be good to include this as a standard field that can be added to a view scheme i.e.

Field name= 'Image file?'

in addition to...

Field name = 'Image file path'

No doubt there will be similar other uses.
Title: Re: Database Expressions are Cool!
Post by: EpF on April 14, 2005, 03:18:24 am
Yes, and as examples come along, I'd love to see them.  In fact, though I think I know what the likelihood is (!), it'd be cool to have a (sticky?) thread which simply catalogued examples of expressions as people come up with them, with a short explanation of what they do.

It's probably not possible to have it as a sticky, but if the function keeps getting expanded it'll be very powerful, and would be worth some kind of knowledge base...

Anyway, thanks for the positive reply!
 :)

Listening to 'The Passion Of Lovers' by Bauhaus, from 'Mask' (1981)
Title: Re: Database Expressions are Cool!
Post by: modelmaker on April 14, 2005, 05:00:42 am
Imjustagamer set up a gmail account for us users for just things: http://yabb.jriver.com/interact/index.php?board=3;action=display;threadid=22788

AlexB has posted stuff there and I and others have downloaded from there with no problems (as recently as a couple of days ago).

This is where the old 9.0.180.exe file has been archived.
Title: Re: Database Expressions are Cool!
Post by: EpF on April 14, 2005, 05:20:46 am
Thanks - I just mailed my little idea there!  I saw that so far no-one has sent any expressions, so; to anyone reading this thread - if you have successfully created any db expressions that you have found useful, even if they're very specific to your workflow/library, please e-mail them to

mcfiles@gmail.com (opens yr mail program)

Don't forget to add a description of what it does...

Fair play, imjustagamer!   ;)
Title: Re: Database Expressions are Cool!
Post by: hit_ny on April 15, 2005, 02:19:24 am
i would suggest just bookmarking this thread and adding to it as new ones come along. I figure people will notice it as it gets bumped to the top of the pile.

..just like this smartlists (http://yabb.jriver.com/interact/index.php?board=3;action=display;threadid=9765) one
Title: Re: Database Expressions are Cool!
Post by: EpF on April 15, 2005, 02:02:35 pm
Done!

Listening to 'Kelper' by Nobukazu Takemura, from 'Scope' (1999)
Title: Re: Database Expressions are Cool!
Post by: cascius on April 15, 2005, 02:40:29 pm
Guys, would it make it easier (than using gmail) that i add an upload mod to forums I already have up? I've got 1.5gig of storage and a 40gig bandwidth... Which should be plenty. :D

I haven't had a chance to play with those expressions and I'm VERY curious to see what can be done. I'll have to look into it next week.

- Cas
Title: Re: Database Expressions are Cool!
Post by: dcwebman on April 19, 2005, 12:50:52 pm
FormatBoolean(IsEmpty([Image File]), No, Yes)

I like this, but for the covers I don't have instead of leaving them blank I have a generic image called nocover.jpg so that something is displayed in Playing Now. I thought I saw elsewhere that an OR could be done so how come the following will not work?

FormatBoolean(IsEmpty([Image File]) or IsEqual([Image File], d:\mp3\coverart\nocover.jpg, 1), No, Yes)

On the ones that have been assigned nocover.jpg, it still shows a Yes.

Jeff

Got it!
If(If(IsEqual(mid([Image File], 1, -1), :\mp3\coverart\nocover.jpg, 1), 1, If(IsEmpty([Image File]), 1, ) ), No, Yes)
Title: Re: Database Expressions are Cool!
Post by: EpF on April 23, 2005, 08:24:23 am
Another simple idea I had was this:

*NOTE* - read update in my next post for much simpler version of this

If(IsEqual([album type],Single artist /(complete/)),[artist],If(IsEqual([album type],Single artist /(incomplete/)),[artist],If(IsEqual([album type],Multiple artists /(complete/)),[album],If(IsEqual([album type],Multiple artists /(incomplete/)),[album],[artist])

What it does is create a column in a view scheme which gives you an artist if the track(s) are on a single-artist album, and gives you an album if the track(s) are on a compilation.  It can really cut down the number of entries in a column, depending on the number of compilations you have.  In my case by almost 1000!

If you invert the [artist]/[album] fields, it will do the opposite.  I find them a great replacement for standard Artist and Album columns...
Title: Re: Database Expressions are Cool!
Post by: hit_ny on July 26, 2005, 10:42:05 am
I dont understand the above, if i wanted to find all albums an artist was on a simple view scheme can do that already.

Can you give step by step instructions how to try out this "simple" expression of yours.
Title: Re: Database Expressions are Cool!
Post by: EpF on August 03, 2005, 06:53:05 pm
Sorry it took so long to get back on this, but my main computer is in hospital  :(, and it's been a PITA getting stuff sorted out on this one.

*NOTE* - see update at end of this post for much simpler version!

Anyway, first off, here's an image:

(http://www.alluvialplains.com/Images/MC/artistalbum.jpg)

You can see a compilation title and an artist title highlighted, and in the third column you get the artists on the compilation and the albums by the artist in the previous column.

I know you can set up view schemes with Album Type to filter your compilations out etc, but I find it helpful because I use a lot of View Schemes with 7 or 8 View Items, so trimming them down is always good.  It also trims the number of entries in the second column by around half for me (from 2100 artists to 1050 artist/album entries), which is great when I'm going through the whole collection...

Step by step instructions:

1; In Edit View Scheme, Add new View Item>Advanced Expression
2; Name it Artist/Album and paste the following into the Expression field:
Code: [Select]
If(IsEmpty([artist]), none,If(IsEqual([album type],Single artist /(complete/)),[artist],If(IsEqual([album type],Single artist /(incomplete/)),[artist],If(IsEqual([album type],Multiple artists /(complete/)),[album],If(IsEqual([album type],Multiple artists /(incomplete/)),[album],[artist])
note; if you copy and paste from this page you'll probably get line-breaks, which is no good for the Expression Evaluator, so paste it into Notepad and get rid of any line-breaks
3; Hit OK
4; Repeat steps 1 to 3, but paste the following instead:
Code: [Select]
If(IsEmpty([album]), none, If(IsEqual([album type],Multiple artists /(complete/)),[artist],  If(IsEqual([album type],Multiple artists /(incomplete/)),[artist],  If(IsEqual([album type],Single artist /(complete/)),[album],  If(IsEqual([album type],Single artist /(incomplete/)),[album],[artist])

Hope someone else finds it useful.

Update 13/04/06:
I have found a vastly less text-intensive version of these expressions:

Artist/Album
If(IsEmpty([artist]), none, If(IsEqual(Mid([album type]), S), [artist], [album])

Album/Artist
If(IsEmpty([album]), none, If(IsEqual(Mid([album type]), M), [artist], [album])

I dunno if anyone found them useful, but here are 2 more that are helpful with the 2 above:

AR/AL Rating
f(IsEmpty([artist rating]), !,  If(IsEmpty([album rating]), !,  If(IsEqual(Mid([album type]), S), [artist rating], [album rating])
You have to create the Artist Rating and Album Rating fields for this to work

Initial - returns first letter of album or artist (after 'the' or 'a')
If(IsEmpty([artist]), none, If(IsEqual(Mid([album type]), S), If(IsEqual(Mid([Artist],0,4),The ), Mid([artist],4), If(IsEqual(Mid([Artist],0,2),A ), Mid([artist],2), Mid([artist]))), If(IsEqual(Mid([Album],0,4),The ),    Mid([Album],4), If(IsEqual(Mid([Album],0,2),A ), Mid([Album],2), Mid([Album])))))   
Title: Re: Database Expressions are Cool!
Post by: marko on July 10, 2006, 03:12:04 am
I'll ramble on a bit first, there'll be an expression at the end ;) :)

Recently, I've been working with MC to try and get some much needed order into my photo files. I've still got a long, long way to go, but so far, progress is promising, so I keep on going. Images are a pain. They're not linear like audio files are, and I've come to the conclusion that filenames are really pretty irrelevant, as we mostly identify our pictures by looking at them, not their filenames. (I've set the filenames for MC to use in a different way, but more on that later)

It's a tough business extracting tips out of others that are already well up the road with MC and their images, so, when I stumble onto something that I think might be generally useful, I'll give it a mention.

Tagging is obviously the key to quickly finding the photos you want, but you need to work out a common-ish workflow to be able to make use of the tags when you've finished. There's the obligatory [people], [places], [events] tags, which are a good place to start, and if you check out Doof's captionator plugin, you will like it, and subsequently, you will also have a [caption] tag. Not all pictures will have all tags though. After following a tip, I created a new field called [subject], and set myself the rule that very image must at least have a subject tag. I think this is a good foundation upon which to build a useable image library.

Now, when playing an image slideshow using MC, we have some on screen text labels to accompany each image, and this is customisable. What to put in there though? As I mentioned before, not every image has every tag, so, sure, if there's a [caption] tag present, you'd want to see that, but if there's no [caption], it doesn't look pretty. What I did was to prioritise what I'd like to see...

If there's no caption, is there an event?
If there's no event, is there a place?
if there's no place, well, I know there's a subject, so i suppose we'd be as well seeing that, as nothing.
How?
go "tools>options>playback>image playback settings" and where it says "Caption" paste the following expression:

if(isempty([caption]),if(isempty([events]),if(isempty([places]),[subject],[places]),[events]),[caption])

sorted. I've also got:

 ~ formatdate([date,0],dd MMMM yyyy)

tagged on the end of that, but I think that may change. I'm not entirely thrilled with how that looks.
You should be able to see what it's doing and if you need to, change the library fields to suit your needs. Try to avoid list type fields, such as people, as they look horrible on screen, displaying as Rod;Jane;Freddy for example.

enjoy :)

-marko.
Title: Re: Database Expressions are Cool!
Post by: benn600 on July 10, 2006, 08:53:42 am
Is there a way to make an expression which would compare all songs with the same name & artist and then find songs of those which are 8 seconds apart or closer and then removes the greater length song?  This would remove duplicates which are very similar, as opposed to some versions of a duplicate which are live or something like that.
FormatBoolean(IsEmpty([Image File]), No, Yes)
SizeDifference<8  ?
Title: Re: Database Expressions are Cool!
Post by: hit_ny on July 10, 2006, 09:27:07 am
No, as expressions can't compare fields between files..

..but rather only within them.