# TCMediaInfo plugin for Total Commander 0.7.4

## Plugin description

TCMediaInfo - is content/lister plugin that allow to retreive info about many video and audio formats. Plugin use MediaInfo library, and support all formats that MediaInfo library have support for. Full list of formats you can find here.

## Prerequisites

This plugin has been tested on:

- Total Commander 8.01 under Windows XP Professional SP3 (x86)
- Total Commander 8.01 x64 under Windows 7 (x64)

## Installation

Just open wdx_tcmediainfo_xxx.zip in Total Commander, this will install the plugin automatically.

## Usage

Since MediaInfo library can retreive a LOT information from file, plugin is fully customizable and allow to wrap any MediaInfo library's field. By default some most useful fields already configured and you can instantly start use plugun.

Please refer Total Commander documentation on how to configure columns.

## Configuration

If you need additional information that not configured by default, you have to edit TCMediaInfo.xml file, where all plugin settings are set. Refer allprops.txt file for full list of library properties. If you update library MediaInfo.dll to new version, run saveprops.bat for creating newer version of this file.

In configurtion file you can see four main xml nodes.

### Settings node:

    <options>
        <Formats>AVI,DIVX,MPEG,...</Formats>
        <MultiSeparator> / </MultiSeparator>
        <BasePath>base.db</BasePath>
        <MemoryBase>False</MemoryBase>
        <UseBase>True</UseBase>
        <SqlitePath>Sqlite3.dll</SqlitePath>
        <Sqlite64Path>Sqlite3_x64.dll</Sqlite64Path>
        <MediaInfoPath>MediaInfo.dll</MediaInfoPath>
        <MediaInfo64Path>MediaInfo_x64.dll</MediaInfo64Path>
        <MissedField><empty></MissedField>
        <DebugMode>0</DebugMode>
    </options>

Formats - here you set a list of all extensions supported by plugin, separated by comma.

MultiSeparator - here you set string, that will separate multiple results (for example list of sound languages).

BaseFile - path to database file. Environment variables are allowed.

UseBase - set to True if you want to use database. Base was implemented due slow work of the MediaInfo for speedup following data retrieving.

MemoryBase - if this true, database will be created in memory only and reset when TC restarted.

SqlitePath - path to Sqlite3.dll. By default plugin searching the library in it's folder. Environment variables are allowed.

Sqlite64Path - path to Sqlite3_x64.dll for x64 plugin version. By default plugin searching the library in it's folder. Environment variables are allowed.

MediaInfoPath - path to MediaInfo.dll. By default plugin searching the library in it's folder. Environment variables are allowed.

MediaInfo64Path path to MediaInfo_x64.dll for x64 plugin version. By default plugin searching the library in it's folder. Environment variables are allowed.

MissedField - this text will appear in fields, that have not data in database (for new sources).

DebugMode - if this larger then zero, the debug and error messages are writing in the debug.log file. Debug output have 3 levels (can be combined): 1 - critical errors, 2 - warnings, 4 - details.

### Sources node:

    <sources>
      <source name="SourceName" field="MediaLibraryField" context="MediaLibraryFieldContext" stream="StreamNumber"/>
    </sources>

Here you define the "sources" - info that will be retrieved from library and (optionally) saved to database. Each <source> node can have attributes:

SourceName - name of source. It can be only latin alphanumeric plus underscore. Defined name will become a database field name, and as variable in the scripts.

MediaLibraryField - the MediaLibrary field name (for full list refer to allprops.txt)

MediaLibraryFieldContext (optional) - since many library fields with the same name return different info for different kinds of objects (container, video, audio etc), and some work only in certain context, you can to set it. Context can be one of General, Video, Audio, Text, Chapters, Image, Menu. If this attribute omitted, will be retreived General context (usually container or just common properties).

StreamNumber (optional) - number of stream, for which info will be retreived. If instead number will be "*" - info about all available streams of this kind will be collected (they will be separated with string, defined in MultiSeparator parameter).

### Columns node:

    <columns>
      <column name="ColumnName" coltype="ColumnOutputType">SourceName</column>
      <column name="ColumnName" type="template">SourceName1, SourceName2</column>
      <column name="ColumnName" type="list" list="ListName">SourceName</column>
      <column name="ColumnName" type="script">{script content here}</column>
      <column name="ColumnName" type="script">
      <![CDATA[
          {script content here}
      ]]>
      </column>
    </columns>

Here you define the columns, as they are will be appeared in Total Commander.

Each <column> node can have attributes:

ColumnName - name (usually english, in order it can be translated with standard Total Commander language file) of column, as this will be appeared in Total Commander.

type="<single|template|list|script>" - defining, how to treat the node text.

This can be:

single - the node text is name of source itself.
template - source names in this text will be replaced by their values.
list - value of source will be searched in list and replaced by some value, if found (refer to "lists" section)
script - the script (refer to scripting section).

If attribute omitted, text will treated as "single".

Text of node can be wrapped to CDATA section. It's recommend for scripts, in order to not convert special symbols, it also useful for multiline scripts.

<column> node also can contain <unit> subnodes. They are handling the same as columns and can have the same attributes. Don't use any "type" attribute in <column> node if you use units.

ColumnOutputType (optional) - type of column's output value, it's need mostly for date/time format: ft_string, ft_numeric_32, ft_numeric_32, ft_datetime. Default is ft_string.

Also, you can place <separator/> node between columns, this will appear as separator in Total Commander's menu.

### Lists node:

    <lists>
      <list name="ListName">
        <line name="SearchText">ReplaceText</line>
      </list>
      <list name="ListName" type="ini" file="{path to file, environment variables allowed}" section="{load from}"/>
    </lists>

In this node you can define lists of terms that need to be replaced.

ListName - name of list. It can be only non-latin alphanumeric plus underscore. Defined name can be used in columns of "list" type, or called by that name from script.

SearchText - search text

ReplaceText - search text will be replaced by that text

type="ini" - list can be loaded from external ini-file. The name of file should be in "file" attribute (environment variables allowed). Also you should set in "section" attribute name of ini-file section. Ini can be ANSI or UTF-8 encoded.

## Scripting

Scripting is allow you to visualize information in any kind.

In scripts you can use all names, defined for "sources", and special variable "Output" that will be displayed. All input variables and "Output" variable are have Variant type. This mean in many cases you can use it's value without additional conversions. Note, that when variant is string, it's actually UTF-8 stream.

It's no need to declare variables, labels and functions. PASCALC creates variables dynamically on first assignment. Variable type depends on the last value assigned, type checking is not carried out.

Expressions syntax: Arithmetic operators: +, -, *, /, ^ (power), SHL, SHL Bitwise operators: BITOR,BITAND,BITXOR,BITNOT Logical operators: >, <, >=, <=, =, <>, AND, OR, NOT, constants TRUE and FALSE. Operators precedence standard, you can use parentheses.

Statements supported:

- BEGIN ... END
- IF ... THEN ... ELSE
- CASE
- FOR ... TO/DOWNTO ... DO
- WHILE ... DO
- REPEAT ... UNTIL
- CONTINUE
- BREAK
- GOTO
- EXIT

Also supported procedures and functions.

## String functions

StrUpper(string)
StrLower(string)
StrMid(string, start, count)
StrLeft(string, count)
StrRight(string, count)
StrTrim(string)
StrLen(string)
StrPos(string, start, count)
StrReplace(string, oldpattern, newpattern, replaceall, casesense)

## Special functions

For simplify handling plugin data some special functions was implemented.

GetListValue(List; Default)

This function for working with lists. Parameters:

List - name of list
ID - text that will be searched
Default - default value that will be used in case text not found

Return value - string.

TimingFormat(TimingFmt; Timing)

This function for counting and format timing values from the value in milliseconds.

TimingFmt - timing format, can be constructed from any text with following substitutes:

%h - hour, ex. 1 hour → 1
%hh - hour with one leading zero, ex. 1 hour → 01
%hhh - hour with two leading zeros, ex. 1 hour → 001
%m - мminutes, ex. 5 min → 5
%mm -minutes with leading zero, ex. 5 min → 05
%s - seconds, ex. 5 sec → 5
%ss - seconds with leading zero, ex. 5 sec → 05
%z - thouthand's fractions of second (= milliseconds), ex. 25 ms → 25
%fff - thouthand's fractions of second (= milliseconds), with leading zeros, ex. 25 ms → 025
%ff - fractions of milliseconds rounded to hundreds, with leading zeros, ex. 125 ms → 13
%f - fractions of milliseconds rounded to ten's, ex. 125 ms → 1

Timing - timing in milliseconds

Return value - string.

Example: TimingFormat('%hh:%mm%:%ss.%fff', 183353) → "00:03:03.353"

## Translation

For translation of fields you can use standard TC's mechanism. Look to TCMediaInfo.lng file, it's content is obvious.

## Version history

    Version 0.7.4 (2013-07-26)
    + translation
    + ability (actually hack) to fix wrong codepage conversion for field retrieved from ID3-tags

    Version 0.7.3 (2013-07-24)
    + custom view modes
    - fixed multi-window support

    Version 0.7.2 (2013-07-17)
    ? trying to fix locking on some opened files
    + color and font settings for WLX
    + few string functions in scripting
    + WLX now aware of MediaLibrary paths that set in config
    + added horizontal scrollbar in WLX
    - fixed format checking under x64 WDX

    Version 0.7.1 (2012-07-09)
    + integrated WLX plugin
    + added FLV and 3GP to standard list of supported extensions
    - fixed bitrate divider
    - fixed displaying wrong information sometimes

    Version 0.7.0 (2012-06-27)
    * Documentation in html.
    * Changed scripting engine (some minor script modifications required) to be able make x64 build.
    * Updated MediaInfo to version 0.7.58.0.
    * Instead message boxes plugin write it's errors and debug info in log file
    + Added special scripting function TimingFormat
    + Added option, that set text which will be diplayed for fields without info in database (for fields that was added after the file info was added into base)
    + Adding sources not require base recreation anymore

    Version 0.6.2 (2011-02-06)
    - Fixed appearing unneeded message on empty database
    + Readded ANSI-version
    - Version info was not visible under Windows 7
    + Now possible to set custom database path

    Version 0.6.1 (2010-09-14)
    - Almost fixed shared DB access
    + Option to have in-memory (session) only database

    Version 0.6 (2010-08-22)
    * Plugin fully rewritten
    * Pascal Script as scripting engine
    * XML for store definitions and options
    + Column value can be constructed from multiple sources
    + Database for speedup loading (Sqlite3)
    - Fixed non-working latest releases of library

    Version 0.51 (unreleased)
    + Substitutions lists support
    + Now plugin not use detect string, it checks extension list that set in config
    + Added default config, so working one will not rewritten by installer

    Version 0.50 (2009-09-07)
      First release.

## Credits

Christian Ghisler - for infinitely powerful tool.

MediaInfo team - for infinitely powerful tool.

Alexey Boyko - for simple and convenient PasCalc interpreter.

## License

Copyright (c) 2009-2012 Dmitry Yudin

Plugin website

This plugin is freeware.

Allowed inclusion of this plugin in any Total Commander packs, personal or publc, in case of this information file presence.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.