Multi-line Strings
Multi-line Strings
Multi-line strings are defined by one or more lines of text.
Format
For multi-line strings both FileTokens and NfoTokens are available for use in NfoForge. Also, multi-line tokens must use two sets of brackets, e.g., {{ movie_title }}
.
Tip
Whitespace inside the tokens is not required (is ignored), but by convention, your tokens should have a space before the text inside the token. e.g., {{ movie_title }}
instead of {{movie_title}}
.
Usage
This part of NfoForge's formatter utilizes Jinja.
What is Jinja?
Jinja is a fast, expressive, extensible templating engine. Special placeholders in the template allow writing code similar to Python syntax. The template is then passed data to render the final document.
Example of a token string:
Info
Title : {{ movie_title }} {{ release_year_parentheses }}
Format Profile : {{ format_profile }}
Resolution : {{ resolution }}
Average Bitrate : {{ mi_video_bit_rate }}
{% if releasers_name %}
Encoder : {{ releasers_name }}
{% endif %}
{% if screen_shots %}
{{ screen_shots }}
{% endif %}
{% if release_notes %}
Release Notes:
{{ release_notes }}
{% endif %}
{% if media_info_short %}
MediaInfo
{{ media_info_short }}
{% endif %}
{{ shared_with_bbcode }}
When filled:
Info
Title : Big Buck Bunny (2008)
Format Profile : High@L4.2
Resolution : 1080p
Average Bitrate : 3994 kbps
Encoder : anon
#### DUMMY SCREENSHOTS ####
(Real screenshots will be generated on the process page in the appropriate format for the tracker)
Screen1 Screen2
Screen3 Screen4
#### DUMMY SCREENSHOTS ####
MediaInfo
General
Complete name : Big.Buck.Bunny.2008.BluRay.1080p.MP2.2.0.x264.mp4
File size : 339 MiB
Duration : 10 min 34 s
Overall bit rate : 4 476 kb/s
Frame rate : 30.000 FPS
Video
ID : 1
Format : AVC
Format profile : High@L4.2
Duration : 10 min 34 s
Bit rate : 4 000 kb/s
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate : 30.000 FPS
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Audio #1
ID : 2
Commercial name : MPEG Audio
Codec ID : mp4a-6B
Bit rate : 160 kb/s
Channel(s) : 2 channels
Sampling rate : 48.0 kHz
Audio #2
ID : 3
Commercial name : Dolby Digital
Codec ID : ac-3
Bit rate : 320 kb/s
Channel(s) : 6 channels
ChannelLayout_Original : L R C LFE Ls Rs
Sampling rate : 48.0 kHz
Shared with [url=https://github.com/jesterr0/NfoForge]NfoForge v0.8.2[/url]
Additional Information
You can use if statements, loops, etc. A quick look at Jinja's documentation can help you understand these features if you aren't familiar.
Conditional Example:
Suppose you have filled in a movie, but you're unsure if there will be an edition. You can add this in an if statement and only display Edition if it's available or detected.
Info
Title : {{ movie_title }} {{ release_year_parentheses }}
{% if edition %}
Edition : {{ edition }}
{% else %}
Edition : None
{% endif %}
Info
Detects if there is an edition detected and fills it with a clean formatted output. If there is not any editions detected it outputs 'None' as the edition.
Output:
Jinja Filters
While I can't go over all of what jinja supports (it would take forever and they have very clean documentation), I figured I could go over a quick useful example called the replace filter. This works identically to Pythons built in string function replace.
Example:
Output:
Let's say you want to swap /
for '
.
In:
Out:
You can also chain multiple filters together.
In:
Out:
Sandbox
In NfoForge, open Settings → Templates to build templates and use the sandbox feature. Once you have created a new template, you can click the icon to preview your filled template.
Open a file to test out the sandbox (this brings up the search widget to parse the file's details).
Tip
As long as you stay in the settings window, the file is cached and won't have to be reloaded for each change to your template when modifying or testing things out.
You will see the filled template. Here, you can deselect the preview button to make changes to the template and test things out as many times as you'd like.