Page 1 of 1

Using CSVs for lists to insert into format?

Posted: 23 Jul 2016, 15:43
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?

Re: Using CSVs for lists to insert into format?

Posted: 23 Jul 2016, 16:14
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)}

Re: Using CSVs for lists to insert into format?

Posted: 23 Jul 2016, 17:07
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!

Re: Using CSVs for lists to insert into format?

Posted: 25 Jul 2016, 09:41
by rednoah
Alright, I'll add this as a String method with the next build:

Code: Select all

{fn.stripReleaseInfo()}