[Solved (sort of)] Working with an XML file

All about user-defined episode / movie / file name format expressions
Post Reply
SonOfDiablo
Posts: 26
Joined: 11 Feb 2019, 10:11

[Solved (sort of)] Working with an XML file

Post by SonOfDiablo »

Hello,

I want to change my FileBot workflow a bit to have FileBot automatically organize media files in appropriate folders.
However I have my TV Shows split up into different paths (/some/path/Shows; /some/other/path/Shows;)

So I made a map in the form of a csv file:

Code: Select all

ShowName;some/path/Shows
AnotherShowName;some/other/path/Shows
...
And this does work as expected using the following format:

Code: Select all

--format "{csv('path/to/map.csv').get(n) ?: 'New'}/{n.upperInitial().space('.')}.{S00E00}.{t.upperInitial().space('.')}"
however I'm also using a filter for those shows that causes detection issues:

Code: Select all

--filter "!readLines('path/to/Filebot_Excludes.txt').contains(n)"
This file is just a list of show names:

Code: Select all

Watchmen (2017)
Watchmen: Motion Comic
Magnum, P.I.
Vekterne
 Vekterne
(As explained in this post --filter and fine-tuning)

So far everything works as expected, but, I just discovered that FileBot can also work with xml files. Which lead me to the idea of combining the filter and map files into a single xml file.

However, I don't know how exactly to work with xml files with FileBot...
Only example I was able to find was in this post and that is just a very simple example. (granted i might have missed a post here on the forum)


What I'm imagining is an xml file like this:

Code: Select all

<root>
    <map>
        <path>
            <path>some/path/Shows</path>
            <items>
                <item>ShowName1</item>
                <item>ShowName2</item>
                <item>ShowName3</item>
            </items>
        </path>
        <path>
            <path>some/other/path/Shows</path>
            <items>
                <item>AnotherShowName1</item>
                <item>AnotherShowName2</item>
                <item>AnotherShowName3</item>
            </items>
        </path>
    </map>
    <blacklist>
        <item>Watchmen (2017)</item>
        <item>Watchmen: Motion Comic</item>
        <item>Magnum, P.I.</item>
        <item>Vekterne</item>
        <item> Vekterne</item>
    </blacklist>
</root>
My current cli command for renaming looks like this:

Code: Select all

filebot -rename .\*.mkv --db TheTVDB -non-strict --filter "!readLines(path/to/Filebot_Excludes.txt').contains(n)" --log FINE --format "{csv('path/to/map.csv').get(n) ?: 'New'}/{n.upperInitial().space('.')}.{S00E00}.{t.upperInitial().space('.')}"
So finally to my actual question:
Does anyone have an idea as to how I can achieve this?
And is this at all feasible?
Last edited by SonOfDiablo on 24 Feb 2020, 21:20, edited 1 time in total.
User avatar
rednoah
The Source
Posts: 22975
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [Help Needed] Working with an XML file

Post by rednoah »

Can you do it? Yes! Should you do it? No!


:idea: I'd stick with plain text CSV files. XML is a human-readable machine format. Typing XML should never ever be done by a human, because humans make mistakes that make files not machine-readable. ;)


:idea: That being said, processing XML with Groovy very straightforward: https://groovy-lang.org/processing-xml.html
:idea: Please read the FAQ and How to Request Help.
SonOfDiablo
Posts: 26
Joined: 11 Feb 2019, 10:11

Re: [Help Needed] Working with an XML file

Post by SonOfDiablo »

I didn't plan on writing it all out myself, I had in mind to throw together a little script that would let me add items to the XML file (with as little input from me as possible).
Mostly I wanted to do this to combine it all into a single file (for the sake of keeping things tidy). Also I though the XML approach would result in less text... Though after realizing that I didn't have to provide the full path (as the Formatting done by FileBot can fill in most of it) it turns out that the CSV file is ~25% smaller (currently).

Guess I'm just gonna stick with the plain text and CSV (for now at least).

Thanks for your input! Made me realize I didn't have much to gain and much more to lose from trying to get that working :oops:
Post Reply