Redundant tags

All about user-defined episode / movie / file name format expressions
Post Reply
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Redundant tags

Post by devster »

I have a file with the following characteristics:

Code: Select all

General
Unique ID                                : 250976278231036526772972929662264737331 (0xBCD045E08CA3E63285C1DD35310AFE33)
Complete name                            : /cephfs/Media/dispenser/movies/The.Expendables.2010.Extended.DC.720p.BluRay.DD5.1.x264-BMF.mkv
Format                                   : Matroska
Format version                           : Version 4
File size                                : 6.57 GiB
Duration                                 : 1 h 53 min
Overall bit rate                         : 8 312 kb/s
Movie name                               : The Expendables (2010) Extended Director's Cut - 720p x264 - BMF
Encoded date                             : UTC 2017-04-11 10:33:00
Writing application                      : mkvmerge v10.0.0 ('To Drown In You') 64bit
Writing library                          : libebml v1.3.4 + libmatroska v1.4.5
Since both the file name and the "title" tag of the MKV (sourced here I think: https://github.com/filebot/filebot/blob ... 1293-L1296) match the pattern.video.tags regex the following is the result:

Code: Select all

{tags}
[Extended, Extended Directors Cut]
I solved it using:

Code: Select all

    { def last = n.tokenize(" ").last()
      def t = call{tags}
      if (t) {
      	if (t.any { it.matches(/(?i)extended$/) } &&
      	    t.any { it.matches(/(?i)extended.(Director.?s.Cut|dc)/) }) {
      		t.remove("Extended") // personal preference
      	}
      }
      specials = { allOf
                    { t }
                    ... } }
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Redundant tags

Post by rednoah »

Here's my easy solution for this interesting problem:

Code: Select all

{
	def allTags = ['Extended', 'Extended Directors Cut', 'Hello World']
	def longestTags = allTags.findAll{ a -> !allTags.any{ b -> a != b && b.startsWith(a) } }
	return longestTags
}
:idea: Please read the FAQ and How to Request Help.
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Re: Redundant tags

Post by devster »

Much simpler. I edited mine.

Code: Select all

      def _tags = call{tags}
      if (_tags) {
      	_tags.removeIf { it ==~ /(?i:imax)/ }
        _tags.removeIf{ a -> _tags.any{ b -> a != b && b.startsWith(a) } }
      }
I only work in black and sometimes very, very dark grey. (Batman)
Post Reply