## [SCRIPT] uFiler | Automate your media center

Running FileBot from the console, Groovy / FileBot scripting, shell scripts, etc
xflak
Power User
Posts: 53
Joined: 25 Feb 2015, 01:51

### [SCRIPT] uFiler | Automate your media center

uFiler

So I wrote a windows CLI script using Filebot and called it uFiler, you can find all the info on it, including source code and download links at ufiler.wordpress.com

Here are a few highlights of what it can do that the amc script doesn't:
• Includes an exe version of uFiler (i.e. uFiler.exe in addition to uFiler.bat) which runs invisibly\silently
• Has a force run mode\argument
• When updating Plex libraries, scans\refreshes only the folders that have changes, so updates take seconds instead of 30 min or longer (depending on your library size)
• Conflicts set to "auto" by default (i.e. duplicates overwritten only if resolution detected to be superior) but if a "TV" labeled torrent name contains "proper" or "repack" the conflict setting changes to "override". This means that corrected "repack" and "proper" TV downloads will automatically replace their buggy versions even when Filebot can't detect the new file is better.
• simple move\copy operations to variable locations depending on the label used (i.e. support customizing the location on the fly using labels
• starting teamviewer
• a couple other minor things
etc.
For the most part, all uFiler's other functions can also be done by the amc script.

Big thanks to rednoah, without his help I would have had a near impossible time improving my script. Originally I wrote it using therenamer instead of FileBot and called it theRenamerHelper, but FileBot is infinitely superior than theRenamer, I wish I had found and used it in the first place!

Below I've pasted just the high level description of uFiler. It's very easy to configure so check it out.

uFiler

FUNCTIONS:
• When torrents labelled “TV” or “Movie” are queued, uFiler can optionally send notifications to Kodi/XBMC machine(s) with the download name
• When a “TV” or “Movie” torrent is completed uFiler will:
- Automatically rename and move/copy new videos to your organized media library location
- Clean your TV/Movie downloads folder of useless nfo, txt, uTorrent dat files, sample videos and empty folders (not done for copy operations to avoid seeding disruption)
- Launch local installation of Kodi/XBMC (optional)
- Update one or more Kodi/XBMC libraries (optional)
- Send on-screen Kodi/XBMC notifications with proper names for each video automatically added to library (optional)
- Update Plex libraries instantly by only scanning folders with new content (optional)
• All Kodi/XBMC notifications can be customized, enabled or disabled for each specific machine/host.
• Utilizing different labels, uFiler can simply move or copy “Finished” downloads to locations of your choosing and optionally send popup notifications to Kodi/XBMC machines.
• Using the labels “teamviewer” and “kill teamviewer”, uFiler can launch or force close teamviewer (if installed).
• Change the app name in the “kill ” label to customize what processes to force close (e.g. “kill kodi” will force close Kodi.exe, if running).
• Bonus Utility 1: “Get New Subs.exe” or “Get New Subs.bat” will search for and download missing subtitles for your videos that are less than two weeks old.
• Bonus Utility 2: XBMCmessenger.html can quickly and easily send custom messages/popups to any Kodi/XBMC machine.
• Bonus Utility 3: xbmcLibrary.exe or xbmcLibrary.bat can be used to just send update commands to your Kodi/XBMC library or libraries.
• Bonus Utility 4: xbmc_exporter.bat can export your Kodi/XBMC library.
Last edited by xflak on 22 Mar 2015, 20:13, edited 1 time in total.
xflak
Power User
Posts: 53
Joined: 25 Feb 2015, 01:51

### Re: [SCRIPT] uFiler | Automate your media center

Just updated the script. Previously conflicts were always set to auto, now it's auto by default but if a "TV" labeled torrent name contains "proper" or "repack" the conflict setting changes to override.

This means that corrected "repack" and "proper" TV downloads will automatically replace their buggy versions even when Filebot can't detect the new file is better.

Pretty sweet right?
rednoah
The Source
Posts: 19150
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

### Re: [SCRIPT] uFiler | Automate your media center

Yep, that's pretty smart!
xflak
Power User
Posts: 53
Joined: 25 Feb 2015, 01:51

### Re: [SCRIPT] uFiler | Automate your media center

When Plex Media Server\Scanner (PMS) adds the first episode of a season it needs to scan the entire series folder, the season subdirectory isn't enough. To work around this, when adding the first episode of a season, or any videos from Season 1, uFiler will have PMS scan the entire series folder instead of just the season folder. This should work in all situations except when the first episode of a season being added to your library is not the first episode of the season or from Season 1. In those cases the scheduled PMS library updates will do the initial scan of the season, and uFiler's updates will be done successfully in realtime from then going forward.

This is all to avoid scanning the entire series folder each time a video is added as it requires more time to do, especially for series with lots of episodes.

Basically uFiler (and of course FileBot) is awesome and keeps getting better
Eggman1414
Posts: 4
Joined: 22 Mar 2015, 00:43

### Re: [SCRIPT] uFiler | Automate your media center

I can not for the life of me get this to work.
This is what I have for Run this Program:
“F:\Documents\Ufiler\uFiler.exe” “F:\Documents\Ufiler” “%L” “%S” “%P” “%N” “%D” “%K”
Every time a download finishes, it just moves the file to: F:\Documents\Done
Am I missing something?
xflak
Power User
Posts: 53
Joined: 25 Feb 2015, 01:51

### Re: [SCRIPT] uFiler | Automate your media center

Edit settings.bat with your path(s), also be sure to give your tv torrents a "TV" label and your movie torrents a "Movie" label so your files get saved to F:\Documents\Done\TV and F:\Documents\Done\Movie

All explained here: https://ufiler.wordpress.com/installation/

Let me know if u have problems
Last edited by xflak on 22 Mar 2015, 17:47, edited 1 time in total.
rednoah
The Source
Posts: 19150
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

### Re: [SCRIPT] uFiler | Automate your media center

Keep in mind that “...” is absolutely not the same as "..." and that you can only quote arguments with the latter.
xflak
Power User
Posts: 53
Joined: 25 Feb 2015, 01:51

### Re: [SCRIPT] uFiler | Automate your media center

Quotes are not used in the settings.bat file so no need to concern yourself with that (uFiler compensates for that in the main script). And in a text/bat file I think the different style of quotes make no difference.

Don’t forget to escape special characters like brackets or pass throughs using carrots ^

Edit: it is however important to use the right straight quotation marks in the utorrent settings
Last edited by xflak on 05 Apr 2015, 04:37, edited 1 time in total.
Eggman1414
Posts: 4
Joined: 22 Mar 2015, 00:43

### Re: [SCRIPT] uFiler | Automate your media center

This is my settings.bat right now:

Code: Select all

::Update only what comes after the equal signs
::Escape any special characters [i.e. ()|] by inserting a carrot ^ in front, so for example (Movies) becomes ^(Movies^)
::Do not use quotations marks ""

::set TVFolder and MovieFolder to the locations of your TV and Movie library, respectively
set TVFolder=F:\Documents\Done\TV Shows
set MovieFolder=F:\Documents\Done\Movies

::set copyORmove to either "copy" or "move" depending on whether you want videos copied or moved. Note that move operations are only triggered when a torrent is "Finished" whereas copy operations are triggered when torrents are seeding and\or finished.
set copyORmove=copy

::set GetSubtitles to "Y" or "N"
set GetSubtitles=Y

::two letter language codes found here: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
set SubtitleLang=en

::If uFiler is installed on the same machine running Plex Media Server, it can update the Plex Library for just the affected folders (i.e. fast\partial scan). Set this is "Y" or "N", if Plex isn't installed it won't run even if set to "Y"
set updatePlexLibrary=Y

::Optionally customize TVFormat and MovieFormat expressions to change how videos are named. For most people the default values will be satisfactory. Do not change these settings unless you know what you're doing. Information on how to customize these can be found at www.filebot.net/naming.html (do not forget to escape special characters)

set TVFormat={n} - {sxe} - {t}

::Optionally override TV Series names by creating\editing a "list.csv" file in the same folder as uFiler. Each line should contain the original name then the new name separated by a semi-colon, for example "Star Trek The Next Generation;STNG" (without quotes)

set MovieFormat={n}
When I try and do a force run and nothing happens.
Eggman1414
Posts: 4
Joined: 22 Mar 2015, 00:43

### Re: [SCRIPT] uFiler | Automate your media center

xflak
Power User
Posts: 53
Joined: 25 Feb 2015, 01:51

### Re: [SCRIPT] uFiler | Automate your media center

Change your TVFormat and MovieFormat back to default for now. I think I may need to put out an update to support naming formats like yours that don't have separate folders for different series and\or movies. It may or may not work in it's current state, I have to investigate but for now just use the default naming format and verify that's working before making adjustments. Shouldn't take me too long to fix it up if there is a problem.

Do you have content saved to "F:\Documents\Done\TV" or "F:\Documents\Done\Movie"?
It won't do anything if there's nothing to process.

To test it, create an empty txt file and rename it as follows (including the extension):
"F:\Documents\Done\TV\the simpsons 101.avi"

then force it to run using
“F:\Documents\Ufiler\uFiler.exe” “F:\Documents\Ufiler” “F”

for verbose output, replace .exe with .bat in the above
Eggman1414
Posts: 4
Joined: 22 Mar 2015, 00:43

### Re: [SCRIPT] uFiler | Automate your media center

OK so maybe that's my problem. I have everything that's done, dumped to F:\Documents\Done\. There are two folders (Movies, TV Shows) along with all the downloaded folders. Ill try your method.
xflak
Power User
Posts: 53
Joined: 25 Feb 2015, 01:51

### Re: [SCRIPT] uFiler | Automate your media center

the update makes it more compatible with naming formats that don't utilize separate folders for different series and\or movies (I tested it using the formats you shared earlier so should work just fine)

The old version would have worked fine in most scenarios but plex updates may not have gone through and notifications for Movies may not have appeared properly
rednoah
The Source
Posts: 19150
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

### Re: [SCRIPT] uFiler | Automate your media center

Keep in mind that --def artwork=y won't work if the files aren't well-organized into TV/Movie Series/Movie folders.
xflak
Power User
Posts: 53
Joined: 25 Feb 2015, 01:51

### Re: [SCRIPT] uFiler | Automate your media center

FYI, just updated the configuring uTorrent instructions to include info on how to append the torrent’s label to the directory name

Also, I added a note to remind people to use straight quotation marks instead of curly ones in uTorrents run a program settings.
xflak
Power User
Posts: 53
Joined: 25 Feb 2015, 01:51

### Re: [SCRIPT] uFiler | Automate your media center

I put out an update last night (v2.7) fixing a small bug that was restricting bulk notifications to only 2 instead of unlimited (e.g. by bulk notifications I mean if u were to grab an entire season in one download labelled "TV" you will get a notification for each episode, not just the first one or two)
xflak
Power User
Posts: 53
Joined: 25 Feb 2015, 01:51

### Re: [SCRIPT] uFiler | Automate your media center

If anyone has any feature requests let me know!
xflak
Power User
Posts: 53
Joined: 25 Feb 2015, 01:51

### Re: [SCRIPT] uFiler | Automate your media center

Shameless bump...
xflak
Power User
Posts: 53
Joined: 25 Feb 2015, 01:51

### Re: [SCRIPT] uFiler | Automate your media center

I updated uFiler to v2.8; Movie and TV processes will now delete files with "sample" in the name, and also delete non-subtitle files that are less than 30MB large (in order to delete samples without sample in the title)
miggy
Posts: 6
Joined: 09 Jun 2016, 19:57

### Re: [SCRIPT] uFiler | Automate your media center

I would like to use uFiler with qbittorrent.

(I have used it with uTorrent for a year or so and have had zero problems. Thanks!!)

I have tried to run uFiler after a torrent completes from qbit as follows:

C:\uFiler_2.7\uFiler.bat "C:\uFiler_2.7" "%L" "%N" "%F"

The supported parameters are different, but I matched the ones in common. I dont really use much of the notifications, xbmc, teamviewer stuff. I just need to rename/move movies and tv series. I really thought it would work with these three parameters, but it is not. I also tried %D instead of %F to no avail. uFilerHistory shows nothing. ..as if its not even starting up.

These are the qbittorrent params:
N Torrent name
L category [ i assumed this means label]
F Content Path (same as root path for multifile torrent)
R Root Path (first torrent subdirectory path)
D Save Path
C Number of Files
Z Torrent size
T Current tracker
I Info Hass

For convenience here are the utorrent params:

You can use the following parameters:

%D - Directory where files are saved
%N - Title of torrent
%P - Previous state of torrent
%L - Label
%T - Tracker
%M - Status message string (same as status column)
%I - hex encoded info-hash
%S - State of torrent
%K - kind of torrent (single|multi)
xflak
Power User
Posts: 53
Joined: 25 Feb 2015, 01:51

### Re: [SCRIPT] uFiler | Automate your media center

miggy wrote:I would like to use uFiler with qbittorrent.

(I have used it with uTorrent for a year or so and have had zero problems. Thanks!!)

I have tried to run uFiler after a torrent completes from qbit as follows:

C:\uFiler_2.7\uFiler.bat "C:\uFiler_2.7" "%L" "%N" "%F"

The supported parameters are different, but I matched the ones in common. I dont really use much of the notifications, xbmc, teamviewer stuff. I just need to rename/move movies and tv series. I really thought it would work with these three parameters, but it is not. I also tried %D instead of %F to no avail. uFilerHistory shows nothing. ..as if its not even starting up.

These are the qbittorrent params:
N Torrent name
L category [ i assumed this means label]
F Content Path (same as root path for multifile torrent)
R Root Path (first torrent subdirectory path)
D Save Path
C Number of Files
Z Torrent size
T Current tracker
I Info Hass

For convenience here are the utorrent params:

You can use the following parameters:

%D - Directory where files are saved
%N - Title of torrent
%P - Previous state of torrent
%L - Label
%T - Tracker
%M - Status message string (same as status column)
%I - hex encoded info-hash
%S - State of torrent
%K - kind of torrent (single|multi)
You can use uFiler's force run command to work around your issue, for example when a torrent completes use the following

C:\uFiler_2.7\uFiler.bat "C:\uFiler_2.7" "F"

So for this to work, the completed folder needs to be the folder specified in the settings file + the label, for example, with the following setting

miggy
Posts: 6
Joined: 09 Jun 2016, 19:57

### Re: [SCRIPT] uFiler | Automate your media center

Yep, that works!

Thanks!

Feature Request: Update plex on another computer (same LAN). I see you can do it with just filebot, so it may not be difficult to implement.

Background: Plex normally watches folders just fine on its own. However, when it watches a networked drive, it does not work at all. A little help from uFiler would be greatly appreciated.

Thanks again.
xflak
Power User
Posts: 53
Joined: 25 Feb 2015, 01:51

### Re: [SCRIPT] uFiler | Automate your media center

miggy wrote:Yep, that works!

Thanks!

Feature Request: Update plex on another computer (same LAN). I see you can do it with just filebot, so it may not be difficult to implement.

Background: Plex normally watches folders just fine on its own. However, when it watches a networked drive, it does not work at all. A little help from uFiler would be greatly appreciated.

Thanks again.
uFiler updated to v3.0 on June 10, 2016

Added support for updating remote Plex libraries running on a different machine (previously only local Plex libraries running on the same machine were supported).

I added this specifically because of your request, let me know if it runs smoothly for you! Note you will need to use the latest settings.bat template to get it to work.

And if you absolutely love it, consider donating to me and\or rednoah (FileBot dev)! Cheers!
xflak
Power User
Posts: 53
Joined: 25 Feb 2015, 01:51

### Re: [SCRIPT] uFiler | Automate your media center

I should mention, uFiler will only scan the remote TV or Movie library that has the new entry (e.g. if adding a new movie, your TV library will not be scanned, only the movie library). This should make it faster than the stock filebot plex updater. Of course uFiler handles updating local plex libraries even faster by only scanning the folder(s) with new content
Toter402
Posts: 2
Joined: 04 Dec 2016, 08:17

### Re: [SCRIPT] uFiler | Automate your media center

I am loving uFiler so far. Loved your ModMii work, BTW, but I'm having a little trouble. Everything seems to work fine when I force run, "ufiler.exe" "*directory*\" "F", but utorrent doesn't seem to execute the exe. I am using "straight" quotation marks. I'm using the latest Beta of Utorrent 3.4.9 build (42951) in Windows 10. I'm guessing NT10 is the culprit. I'm going to try again now with compatibility settings on the uFiler.exe.

Here is my settings.bat:

Code: Select all

set uCompletedDownloads=E:\Torrents\Completed Torrents

set TVFolder=G:\Video\TV Shows
set MovieFolder=G:\Video\Movies

set copyORmove=copy

set GetSubtitles=Y

set SubtitleLang=en

set updatePlexLibrary=localhost
set PlexToken=0123456789abcdefghij
set PlexPort=32400

set TVFormat={csv^('list.csv'^).get^(n^) ?: n}\{episode.special ? 'Season 0' : 'Season '+s}\{s00e00} {t}{' ['+vf.match^(/720[pP]^|1080[pP]/^)+']'}{lang =~ 'eng' ? null : '.'+ lang}

set MovieFormat={n} {'^('+y+'^)'}{' ['+vf.match^(/720[pP]^|1080[pP]/^)+']'}/{n} {'^('+y+'^)'}{' ['+vf.match^(/720[pP]^|1080[pP]/^)+']'}{lang =~ 'eng' ? null : '.'+ lang}
Thanks again, XFlak.
And thank you also, RedNoah!