Skip to content

Commit

Permalink
Add support for user-defined sort -order [input, quality, time]
Browse files Browse the repository at this point in the history
  • Loading branch information
rednoah committed Aug 13, 2020
1 parent b8377a5 commit dad94fe
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions duplicates.groovy
@@ -1,8 +1,15 @@
#!/usr/bin/env filebot -script


delete = 'DELETE'.equalsIgnoreCase _args.action
binary = 'BINARY'.equalsIgnoreCase _args.mode
delete = 'DELETE'.equalsIgnoreCase(_args.action)
binary = 'BINARY'.equalsIgnoreCase(_args.mode)

// Binary Duplicates: Keep Input Argument Order
// Logical Duplicates: Order by Video Quality
order = 'INPUT' .equalsIgnoreCase(_args.order) ? 'INPUT'
: 'QUALITY'.equalsIgnoreCase(_args.order) ? 'QUALITY'
: 'TIME' .equalsIgnoreCase(_args.order) ? 'TIME'
: binary ? 'INPUT' : 'QUALITY'


// sanity checks
Expand Down Expand Up @@ -46,13 +53,14 @@ def group(files) {


def order(files) {
// Binary Duplicates: Keep Input Argument Order
if (binary) {
return files
switch(order) {
case 'INPUT':
return files
case 'QUALITY':
return files.toSorted(VideoQuality.DESCENDING_ORDER)
case 'TIME':
return files.toSorted{ -it.lastModified() }
}

// Logical Duplicates: Order by Video Quality
return files.toSorted(VideoQuality.DESCENDING_ORDER)
}


Expand Down

0 comments on commit dad94fe

Please sign in to comment.