Using CSVs for lists to insert into format?

Support for Windows users
Post Reply
DavidRTurner
Power User
Posts: 85
Joined: 01 Feb 2014, 16:59

Using CSVs for lists to insert into format?

Post by DavidRTurner »

I've recently added a preset format to strip all the junk from filenames that aren't recognized by the database yet - shows that premiered last night, for example, where nobody has yet added an entry for them.

I currently use a ReplaceAll to eliminate all the crap, but it's going to be tedious to keep the code updated this way as I keep finding new snippets to remove from the filename.
I'd like to pull in a CSV list, where I can simply add new terms to the end of the CSV file quickly.

I need some code to replace each item in the filename that is found in the CSV list with a blank; something the functions like:

Code: Select all

.replaceAll(csv('B:/CrapList.csv').getall(items),"")
Example:
Irelands.Greatest.Robberies.S01E01.WEB.x264-spamTV.mkv

CSV contains:
.WEB
.x264
-spamTV

Result:
Irelands.Greatest.Robberies.S01E01.mkv

Any thoughts?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Using CSVs for lists to insert into format?

Post by rednoah »

Read all lines, join with | to build a regex that matches any of the lines:

Code: Select all

{fn.replaceAll(readLines('/path/to/file.txt').join('|'), '')}

EDIT:

:idea: Please share your "crap list" once in a while:
viewtopic.php?f=3&t=359


:ugeek: Just for fun. Hooking into FileBot internals, because FileBot probably already knows everything you might wanna get rid of:

Code: Select all

{net.filebot.media.MediaDetection.stripReleaseInfo(fn, false)}
:idea: Please read the FAQ and How to Request Help.
DavidRTurner
Power User
Posts: 85
Joined: 01 Feb 2014, 16:59

Re: Using CSVs for lists to insert into format?

Post by DavidRTurner »

rednoah wrote:Read all lines, join with | to build a regex that matches any of the lines:

Code: Select all

{fn.replaceAll(readLines('/path/to/file.txt').join('|'), '')}
This is, of course, the elegant solution I was looking for... didn't have the "readLines" - thanks!
EDIT:
:idea: Please share your "crap list" once in a while:
viewtopic.php?f=3&t=359
I've seen that thread. My "crap list" contains just about everything that isn't name/title/season/episode - i.e. release groups & other 'legitimate' crap... if it's not yet in the dbase for proper formatting, I just want to strip everything that's extraneous.
Below, seems to work best based on my trial just now!
:ugeek: Just for fun. Hooking into FileBot internals, because FileBot probably already knows everything you might wanna get rid of:

Code: Select all

{net.filebot.media.MediaDetection.stripReleaseInfo(fn, false)}
This appears to actually do exactly what I want :D so I will try this for a while.

Thanks much, as always!
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Using CSVs for lists to insert into format?

Post by rednoah »

Alright, I'll add this as a String method with the next build:

Code: Select all

{fn.stripReleaseInfo()}
:idea: Please read the FAQ and How to Request Help.
Post Reply