This week's tip shows how to get a little more leverage from Media Center's
Links feature. Links are those click-able words to the right of your view tabs:
Links are also available by right-clicking one or more media files and selecting Links.
Links operate on the selected media, and when clicked, open an internal or external browser to the site specified in the Link's definition. The link is defined using the Media Center expression language, which of course has access to a media file's metadata, and this metadata can help guide the query for more advanced linking.
Let's take a look at a simple link - the stock AMG link:
The Search URL defines the rule used to construct a URL that should open a browser page at the correct location for the selected media. The Link for AMG uses the rule:
http:////www.allmusic.com//search//artist//Hexify([Search])
This is a basic AllMusic search URL, with a couple of expression language modifications:
- forward slashes must be escaped by doubling them (because they are special in expressions)
- part of the URL's path is constructed dynamically based on the expression Hexify([Search])
[Search] is a special, internal Media Center field whose value is generated dynamically for Links. It is filled with the appropriate field value needed for a particular Media Type query (e.g. Artist for Audio, Name for Video). And Hexify() ensures that stuff is safe to embed as part of a URL.
Alternatively, you might want to search using a different criteria, such as by Album name:
http:////www.allmusic.com//search//albums//Hexify([album])
For many Links, the defaults work acceptably. But there are some cases where simple artist or album searching will never produce reliable results (classical music, for example). I decided to handle such cases by helping Media Center a bit. I created a custom field, called
AMG URL, and whenever necessary, I simply fill it with the correct AMG album URL:
By modifying the Search URL for AMG, this URL can now be used instead of the stock AMG search rule, but the stock rule is used as a fallback:
if(!isempty([AMG URL]), [AMG URL], http:////www.allmusic.com//search//artist//Hexify([Search]))
For those of you using MC19, the new FirstNotEmpty() function makes the expression trivially simple:
FirstNotEmpty([AMG URL], http:////www.allmusic.com//search//artist//Hexify([Search]))
Incidentally, the AMG URL is
used for other purposes.
The Search URL expressions can be much richer, and use other fields such as Genre or Media Type, to dynamically construct a URL for your personal needs. You might, for example, want one multi-tasking Link which for audio goes to Allmusic for all but classical music, and goes to the IMSLP whenever the genre is classical and there is a value in the composer field, or for video goes to IMDB for movies and TheTVdb for TV shows. Or limit your Google Images searches to only cover art that is 500x500. Remember to configure the Edit Search... area in the Link:
The link is shown only when there are files in the view that match the search criteria defined here. This allows a link to be hidden when it isn't relevant.
Use your imagination and see what you can come up with, and share your results here.
Have a good week!
[
Go read last week's Tip ]