This project has moved and is read-only. For the latest updates, please go here.

export class

Mar 19, 2013 at 12:56 AM
I'd like to try my hand at doing some export templates as I'm faimliar with html/css/js, but not entirely sure where the template vars are coming from.

Can you point me towards the file/class that handles the exporting of movies / tv shows? and how the export menu is built? (I looked in the html_templates folder, but it's not a 1:1 name match.

Mar 19, 2013 at 1:34 AM
Hi Zxurian,

The template file itself is placed in the 'html_templates' folder (obviously!), and can have any filename but must have a '.txt' extension.

The important part that enables it to be picked up by Media Companion is:
<title>[Menu Title goes here]</title>
<<MC HTML Page>>
<</MC HTML Page>>
The [Menu Title goes here] bit is what will appear in the MC menu.
The 'MC HTML Page' tag is for movie templates and 'MC TV HTML' Page is for TV Shows.

More information is at Exporting Media Info, but unfortunately, I haven't finished what I started!

If you have any more questions about it, please don't hesitate to ask!

Mar 19, 2013 at 1:39 AM
Oh, and the file is MediaInfoExport.vb for all the functions for this.

There are a couple of tags undocumented in INFO_HTMLoutputTags.txt that you may be interested in, that may not be immediately obvious by looking at the source file - let me know, and I'll dig out the info I've written down somewhere... probably in an email to someone else!
Mar 21, 2013 at 8:58 PM

what's the <<footer>> template code for?
Mar 21, 2013 at 9:04 PM
Edited Mar 21, 2013 at 9:05 PM
and this might have to be an option added, but is there a way to limit the movies processed while testing the output? Like only loop through 10 or so while testing a template.
Mar 21, 2013 at 9:08 PM
Best bet, and I figure the dev's are doing this too, is to have a separate install of MC, and a Dummy folder with a couple of movies in it.

Personally, I just create a text file and rename it to a movie with .mkv or .mp4 as the suffix. Scrape it with the separate install of MC and that's your test files.

HueyHQ will have to answer the "Footer" question.
Mar 21, 2013 at 9:11 PM
vbat99 wrote:
Best bet, and I figure the dev's are doing this too, is to have a separate install of MC, and a Dummy folder with a couple of movies in it.
yea, that's what I was just thinking of doing. Copy my install, then just remove all except a few from the list and leave it at that.
Mar 21, 2013 at 9:18 PM
Yes, there is a limit option I implemented only a few weeks ago. I'll have to find out what it is and get back to you.
I'll also post here the details of the email I sent with the new features. (Yes, I suck at documentation!)
Mar 21, 2013 at 9:22 PM
Edited Mar 21, 2013 at 9:23 PM
Limit parameter:
<<media_item[:xx]>> where xx is an integer.

<<format[:container][:source][:resolution]>>, where

container is the file extension, and the case of the C controls whether output is upper or lowercase.
source is the source field on the main movie page from the collection specified in Preferences->Advanced
resolution is the standard vertical res as XBMC does it, eg. 480,576,540,720,1080 (you have to specify the 'p' as in 1080p)

<<filename[:root][:path][:file][:ext]>>, which I think is self-explanatory.

<<nfo:[createdate][:dateformat][:separator]>>, where

createdate is the date field inserted when the NFO is first created
dateformat is a standard date format eg. yyyyMMddHHmmss (ref:
separator can be one of space|colon|slash|dash if an underscore is present in date format.

(hint: you can get 30-Jan-2012 08:49 with <<nfo:createdate:dd_MMM_yyyy:dash>><<nfo:createdate:HH_ss:colon>>, no non-alphanumeric characters allowed in tag which is why we need to specify the separator)

The format and filename tag parameters are all optional, and can be arranged in any order for desired display in the output.
Mar 21, 2013 at 9:26 PM
Oh, and <<footer>> doesn't do anything.
Is there something you could use it for? It would basically be handled like the header is currently.
Mar 21, 2013 at 9:39 PM
HueyHQ wrote:
Oh, and <<footer>> doesn't do anything.
Is there something you could use it for? It would basically be handled like the header is currently.
Not at the moment, just saw the empty tags so thought I would ask what it's for.
And this is an OCD request, can the initial <title></title> tags be changed to something else so as not to be confused with the actual <title> tags in html header? <menutitle></menutitle> maybe?
Mar 21, 2013 at 9:45 PM
That would be a great idea, but I would be worried about backwards-compatibility (as I always do!).
I could add it as an addition to <title>?
Mar 21, 2013 at 10:40 PM
yea, in addition to for backwards compatibility makes sense.
Mar 21, 2013 at 10:41 PM
It will be done! (Next time I fire up the project!)
Mar 21, 2013 at 10:42 PM
something like this in in Movie Card 2up.txt

<<nfo:title:47>>, is that pulling the title tag from the .nfo file, and truncating it to the first 47 characters?
Mar 21, 2013 at 10:44 PM
Yes, I believe so.
Mar 21, 2013 at 10:47 PM
Edited Mar 21, 2013 at 10:47 PM
would you prefer that method, or the method of usign the tags defined within info_htmloutputtags.txt ?
ie. <<title>> or <<nfo:title>> ?
Mar 21, 2013 at 10:55 PM
The predefined tags certainly has less overhead if you don't need to use the NFO-only parameters and options.

Using any of the following:
"fullplot", "director", "stars", "writer", "moviegenre", "releasedate", "format", "filename", "nfo"
requires the NFO file to be loaded (altho' I just noticed "filename" doesn't need to load it).

I guess if you use any of those tags, it won't matter which way you go because it would have loaded the NFO anyway. It is still fairly quick tho', I think.
Mar 21, 2013 at 11:07 PM
oooh, just found something that could definitely use help.

It looks like MC is loading the templates at startup and that's it, so if I make changes to a template it doesn't see them until I quit and restart MC.

Can MC be changed so that it doesn't load the templates at startup, but instead just runs through them once to get the menu entries, and then if you choose an export option, at that time it loads the template, processes it, then dumps it from memory again?
Mar 21, 2013 at 11:20 PM
Um, probably not.

I can see where you're coming from, but it would be a lot of work for very little gain. Tho', admittedly, I created the templates before I consolidated the code to load at start-up.
Raise a feature request, but I doubt it will be implemented for some time - probably when I start creating templates again and get pist off at it, which may not be too far away! Maybe.
Mar 21, 2013 at 11:51 PM
OK, I added the <menutitle></menutitle> as requested.
Mar 22, 2013 at 4:12 PM
HueyHQ wrote:
OK, I added the <menutitle></menutitle> as requested.

on another note, I'm experiencing some inconsistincies with the <<nfo>> tag
<<nfo:mpaa:30>> should read the mpaa rating, and truncate to 30 characters, however the output is Rated R for crude and which is only 21 characters (24 if you include the trailing psuedo elipses as part of the character count).

How does the char_limit translate into number of characters?
Mar 22, 2013 at 9:31 PM
Hmm, the code is as follows:
    If tokenInstr.Length > 2 Then
        Dim intCharLimit = CInt(tokenInstr(2))
        If strNFOprop.Length > intCharLimit Then
            strNFOprop = strNFOprop.Substring(0, strNFOprop.LastIndexOf(" ", intCharLimit - 3)) & "<font class=dim>...</font>"
        End If
    End If
so, working backwards, starting at the limit specified (minus 3 for the ellipses characters), it should truncate at the last space it finds.
In your case, it will start at character position 27, and working towards the beginning of the string, it will find the space after "crude and". The next word must be a long one?!

So it is an actual limit, but not a truncate-at. I did it this way so that it didn't get truncated mid-word.
Mar 25, 2013 at 5:16 AM
ahhh, that explains the discrepancy. Thank you for clarifying.
Mar 25, 2013 at 6:04 AM
can I request that the template be modified to start with <!DOCTYPE html> instead of just <html> to be html5 compatible?

I have to manually change it to that after the export is finished in order to have my javascript properly function.
Mar 25, 2013 at 6:29 AM
and while I'm at it, can I request another html template tag of <<titlewithoutarticles>> or something similar that outputs the name of the movie minus the articles?
so the Following three Movies
Absolute Power
The Adjustment Bureau
Batman Returns
The Book of Eli
would all output the following if <<titlewithoutarticles>> was used
Absolute Power
Adjustment Bureau
Batman Returns
Book of Eli
Mar 27, 2013 at 12:40 AM
Have added !DOCTYPE to <html> tag.

The <title> tag has now been upgraded to <<title[:none|append]>>

For reloading the templates, I think I will add a menu item to reload templates. When I get around to it!