Page 1 of 1

[Script] Generate .plexmatch files

Posted: 09 Jul 2025, 19:42
by rednoah
This post-processing script for Episode Mode will generate .plexmatch files after episodes have been renamed and organized into season folders:

Groovy: Select all

{ source, target, metadata ->
	def plexmatch = target.dir / '.plexmatch'

	allOf{ "Title: $n" }
	     { "Year: $y" }
	     { if (s) "Season: $s"}
	     { if (tmdbid) "tmdbid: $tmdbid" }
	     { if (tvdbid) "tvdbid: $tvdbid" }
	     { if (e) "Episode: ${e.pad(2)}: $target.name" }
	     { if (special) "Episode: SP${special.pad(2)}: $target.name" }
	.findAll{ line ->
		none{ line in lines(plexmatch) }
	}.each{ line ->
		plexmatch.append(line + '\n', 'UTF-8')
	}
}

Console Output: Select all

$ ls -a
.plexmatch
Alias - S01E01 - Truth Be Told.mkv
Alias - S01E02 - So It Begins.mkv
Alias - S01E03 - Parity.mkv
...

Properties: Select all

Title: Alias
Year: 2001
Season: 1
tmdbid: 2046
tvdbid: 75930
Episode: 01: Alias - S01E01 - Truth Be Told.mkv
Episode: 02: Alias - S01E02 - So It Begins.mkv
Episode: 03: Alias - S01E03 - Parity.mkv
...