Help with my script

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
Automator
Posts: 36
Joined: 30 Jul 2015, 10:17

Help with my script

Post by Automator »

Hi there,

Since rednoah help so nicely with the big main issue I had with my script I thought I do a little update in the complete script.

The goal of my script is following:

- It has to recognize if a movie is SD / HD / UHD that was easy to fix with

Code: Select all

if (getMediaInfo(f, '{vf}') == "1080p" || getMediaInfo(f, '{vf}') == "720p"){
}else if (getMediaInfo(f, '{vf}') == "2160p"){
}else{
}
- It has to recognize if a movie has more than one audio line and what languages are that lines also done with

Code: Select all

if (getMediaInfo(f, '{media.AudioCount}').toInteger() > 1){
f (getMediaInfo(f, '{media.Audio_Language_List}').contains("Ger") || getMediaInfo(f, '{media.Audio_Language_List}').contains("GER") && getMediaInfo(f, '{media.Audio_Language_List}').contains("Eng") || getMediaInfo(f, '{media.Audio_Language_List}').contains("ENG") || language.contains("ende") ){
- It has to recognize folder structure for further operations

Code: Select all

}else if (ParentFolder.toString().contains("decision1") || ParentFolder.toString().contains("decision2")){
- It has do delete all the crap nobody wants or needs in movies jpg|jpeg|png|gif|info|xml|htm|html|log|md5|sfv|txt|rtf|url|db|dna|log|tgmd|json|data|srv|srr|nzb|par\d+|part\d+/ I just copied the part out of a script already exists called isClutter
- Then it has to search inside the movie directory for .idx .sub .srt files according to the movie and move them next to the movie file and also correct them so plex can read them correctly blablabla-ger-forced.idx has to become blablabla.ger.forced.idx and can no longer be in the sub folder should be on the same folder as the movie.mkv done with:

Code: Select all

//Get the Parent Folder
args.eachMediaFolder{
  ParentFolder = it
  println ParentFolder

//Move all the Subtitles to the Parent Folder
args.getFiles{ it.isSubtitle()}
.each{
  rename(file:it,output:ParentFolder,format:"{fn}")
}

args.getFiles{ it.isSubtitle() }
.each{
  SubFolder = new File(getMediaInfo(file:it, format:"{folder}"))
  println it.moveTo(new File(getMediaInfo(file:it, format:ParentFolder+"/{fn}.{ext}")))
}
At the end it has do call the right categorie on the plex server for an update its all depending on the descision variable from above :) with following command:

Code: Select all

new URL("http://$plexServer:32400/library/sections/$Decision1/refresh?X-Plex-Token=$mytoken").get()
Now I got the issue that my script works flawlessly (again thanks to rednoah)! But if I run it on a parent folder with contains several subfolders each on is one movie and contains again a subfolder called subs or sub with the subtitles it will move all the subtitles to the first movie directory. Example:

Decision1
Irgendein.Film.1.German.DL.AC3.Dubbed.1080p.BluRay.x264-WhatEver
Irgendein.Film.2.2016.German.DTS.DL.1080p.BluRay.x264.PROPER-WhatEver
Irgendein.Film.3.2016.German.DTS.DL.1080p.BluRay.x264-WhatEver
Irgendein.Film.4.2016.German.DL.1080p.BluRay.x264-WhatEver

It will move the subs from \mnt\NAS\Decision1\Irgendein.Film.2.2016.German.DTS.DL.1080p.BluRay.x264.PROPER-WhatEver\Subs\blaba.idx to \mnt\NAS\Decision1\Irgendein.Film.1.German.DL.AC3.Dubbed.1080p.BluRay.x264-WhatEver\

I think my scripting is wrong in that part...

@rednoah :-P I hope you are happy :-P

Thanks for any help :-)
User avatar
rednoah
The Source
Posts: 22984
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with my script

Post by rednoah »

1.
How do your various conditions affect processing? If the only thing affected is the destination paths of various files, then the most elegant solution would be to encode that logic in your custom format.


2.
The code snippet merely moves up subtitles up by one folder level, yes? I'm not sure why you have two rename() calls in your code. Here's how FileBot does that out-of-the-box without custom scripting and without any kind of online lookup.

Example Setup:

Code: Select all

$ tree .
.
└── Avatar
    ├── avatar.mp4
    └── subs
        └── avatar.eng.srt

2 directories, 2 files
Use filebot to move subtitle files up a directory level:

Code: Select all

$ filebot -rename -r . --db xattr -non-strict --action test --filter "f.subtitle" --format "{f.dir.dir}/{fn}"
Rename files using [Extended Attributes]
[TEST] from [Avatar/subs/avatar.eng.srt] to [Avatar/avatar.eng.srt]
Processed 1 files


:!: This line is especially confusing because it defeats it's own purpose. You identify files as movie/series/anime, then you match them with online data, which is slow and takes a lot of resources, to then just to throw away all that information (movie name, year, id, metadata, etc) and just use {fn} as output filename:

Code: Select all

rename(file:it,output:ParentFolder,format:"{fn}")
:idea: Please read the FAQ and How to Request Help.
Automator
Posts: 36
Joined: 30 Jul 2015, 10:17

Re: Help with my script

Post by Automator »

Thanks again for your reply.

1. Yes, depending on the video resultion, count of audio channels, language of these audio channels and the folder structure it will use another output folder. Example:

/mnt/NAS/INCOMING/decision1/Jack.Reacher.Kein.Weg.zurueck.2016.German.DL.1080p.BluRay.x264-COiNCiDENCE it will put it into /mnt/NAS/MOVIES/decision1/MULTi/HD/Jack Reacher (2016)/

because of decision1, 2 audio channels, german and english and 1080p

2. Okay, so filebot -rename -r . --db xattr -non-strict --action test --filter "f.subtitle" --format "{f.dir.dir}/{fn}" does what I wanted... I guess more or less. Because I am not sure if it would also do the - to . renaming?! and also some people do movie.idx and movie.sub without any .ger or .eng so plex also gets in troubles...

You said I could do 1. with encoding that logic in your custom format. Can you make a sample?
Automator
Posts: 36
Joined: 30 Jul 2015, 10:17

Re: Help with my script

Post by Automator »

Ahhh :-) i forgot something. I also wanted to script that the script checks for existens in decision1 if the new file is decision2 :-)

for example:
/mnt/NAS/INCOMING/decision2/Jack.Reacher.Kein.Weg.zurueck.2016.German.DL.1080p.BluRay.x264-COiNCiDENCE

the script should check if
/mnt/NAS/MOVIES/decision1/GER/HD/Jack Reacher (2016)/
/mnt/NAS/MOVIES/decision1/GER/SD/Jack Reacher (2016)/
/mnt/NAS/MOVIES/decision1/ENG/HD/Jack Reacher (2016)/
/mnt/NAS/MOVIES/decision1/ENG/SD/Jack Reacher (2016)/
/mnt/NAS/MOVIES/decision1/MULTi/HD/Jack Reacher (2016)/
/mnt/NAS/MOVIES/decision1/MULTi/SD/Jack Reacher (2016)/

exists and if id does delete all of them since now decision2 is better :-)
User avatar
rednoah
The Source
Posts: 22984
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with my script

Post by rednoah »

1.
A custom format might look like this and dynamically come up with different destination paths for different files:

Code: Select all

/mnt/NAS/MOVIES/{minutes > 120 ? 'Decision 1' : 'Decision 2'}/{audioLanguages.first()}/{hd}/{ny}
I don't know your "decision" logic, but you can have any logic you want. There's plenty of people that use some sort of logic to move different files into different drives (e.g. Movies A-L go to Drive X and Movies M-X go to Drive Y).


2.
Finding logical duplicates and deleting them is a completely separate task that you can run separately whenever necessary. You can look into the duplicates script for that, or write your own that better suits your needs:
viewtopic.php?f=4&t=5#p23171
:idea: Please read the FAQ and How to Request Help.
Automator
Posts: 36
Joined: 30 Jul 2015, 10:17

Re: Help with my script

Post by Automator »

Okay, so far so good. I tried the custom expressions --format "/mnt/NAS/{file.path.contains('mycondition') ? 'a' : 'b'}/{media.audioCount > 1 ? 'MULTi' : audioLanguages.first()}/{HD}/{ny}" seams to work so far. But I need more so I guess I should go back to scripting.

I am struggeling with the part which should search in the sub folders of the movies for subtitles and move them to the movie root?

Code: Select all

Collection
└── Avatar
    ├── avatar.mp4
    └── subs
        └── avatar-eng.srt
└── Bad Boys
    ├── badboys.mp4
    └── subs
        └── badboys-eng.srt
        └── badboys-ger.srt
        └── badboys-ger-forced.srt

so it will look like this

Code: Select all

Collection
└── Avatar
    ├── avatar.mp4
    ├── avatar.eng.srt
└── Bad Boys
    ├── badboys.mp4
    ├── badboys.eng.srt
    ├── badboys.ger.srt
    ├── badboys.ger.forced.srt
What I thought of so far:

Code: Select all

args.getFiles{ it.isSubtitle() }.each{
  println "$it"
}
this at least gives me back all the subtitles... now I need to find out how I can move them :-) and also rename them like the moviename.{subt}.{ext}?

Any idea rednoah?

Btw. you duplicate script is not working... $m gives back NULL

This is my current script which I use:

Code: Select all

// log input parameters
log.fine("Run script [${_args.script}] at [${now}]")
args.each{
  log.finer("Input Folder: $it")
  InputFolder = "$it"
}
SubFolder = null
Type = null
Section = null

def deleteRootFolder = any{ root.toBoolean() }{ false }

/*
    Finding all the Clutter files we don't need
*/

def isClutter(f) {
    // white list
    def ignore  = tryQuietly{ ignore }          ?: /extrathumbs/
    if (f.path.findMatch(ignore))
        return false
    
    // black list
    def exts    = tryQuietly{ exts }            ?: /jpg|jpeg|png|gif|info|xml|htm|html|log|md5|sfv|txt|rtf|url|db|dna|log|tgmd|json|data|srv|srr|nzb|par\d+|part\d+/
    def terms   = tryQuietly{ terms }           ?: /sample|trailer|extras|deleted.scenes|music.video|scrapbook|DS_Store/
    def minsize = tryQuietly{ minsize as Long } ?:  20 * 1024 * 1024
    def maxsize = tryQuietly{ maxsize as Long } ?: 100 * 1024 * 1024
    
    // file is either too small to have meaning, or to large to be considered clutter
    def fsize = f.length()

    // path contains blacklisted terms or extension is blacklisted
    if (f.extension ==~ "(?i)($exts)" && fsize < maxsize)
        return true

    if (f.path =~ "(?i)\\b($terms)\\b" && fsize < maxsize)
        return true

    if ((f.isVideo() || f.isAudio()) && fsize < minsize)
        return true

    return false
}

/*
    When called removing all the Clutter files
    
    with action = test nothing is gone happen for test puroposes
*/

def clean(f) {
    log.info "Delete $f"
    
    // do a dry run via --action test
    if (_args.action == 'test') {
        return false
    }
    
    return f.isDirectory() ? f.deleteDir() : f.delete()
}

// memoize media folder status for performance
def hasMediaFiles = {
    dir -> dir.isDirectory() && dir.getFiles().find {
        (it.isVideo() || it.isAudio()) && !isClutter(it)
    }
}.memoize()

// delete clutter files in orphaned media folders
args.getFiles{ isClutter(it) && !hasMediaFiles(it.dir) }.each { clean(it) }

// delete empty folders but exclude given args
args.getFolders().sort().reverse().each{
    if (it.isDirectory() && !it.hasFile{ it.isDirectory() || !isClutter(it) }) {
        if (deleteRootFolder || !args.contains(it))
            clean(it)
    }
}

/*
    Moving all the Subtitles to the movie and changing adding the correct file naming schema

args.getFiles{ it.isSubtitle() }.each{
  log.info("$it")
}*/

args.getFiles{ it.isVideo() }.each{ f->
  if (f.path.contains("CondA")){
    log.info "CondA"
    Type = "CondA"
  }else if (f.path.contains("CondB")){
    log.info "CondB"
    Type = "CondB"
  }else {
    log.info f.path
    System.exit()
  }
  if (getMediaInfo(f, '{media.AudioCount}').toInteger() > 1){
  log.info getMediaInfo(f, '{media.AudioCount}')+" Audio Lines"
    if (getMediaInfo(f, '{media.Audio_Language_List}').contains("Ger") || getMediaInfo(f, '{media.Audio_Language_List}').contains("GER") && getMediaInfo(f, '{media.Audio_Language_List}').contains("Eng") || getMediaInfo(f, '{media.Audio_Language_List}').contains("ENG") || language.contains("ende") ){
      log.info "I found german and english audio lines"
      if (getMediaInfo(f, '{vf}') == "1080p" || getMediaInfo(f, '{vf}') == "720p"){
        log.info "HD"
        args.eachMediaFolder{
          rename(file: it,output:"/mnt/NAS/MOViES/$Type/MULTi/HD/")
          Section = Type+"MULTiHD"          
        }
      }else if (getMediaInfo(f, '{vf}') == "2160p"){
    log.info "UHD"
        args.eachMediaFolder{
          rename(file: it,output:"/mnt/NAS/MOViES/$Type/MULTi/UHD/")
          Section = Type+"MULTiUHD"          
        }
      }else{
        log.info "SD"
        args.eachMediaFolder{
          rename(file: it,output:"/mnt/NAS/MOViES/$Type/MULTi/SD/")
          Section = Type+"MULTiSD"
        }
      } 
    }else{
      log.info "Huston we've got a Problem. I found: "+getMediaInfo(f, '{media.Audio_Language_List}')
    }
  }else if (getMediaInfo(f, '{media.AudioCount}').toInteger() == 1){
    log.info "Found only 1 audio line"
    if (getMediaInfo(f, '{media.Audio_Language_List}').contains("Ger") || getMediaInfo(f, '{media.Audio_Language_List}').contains("GER") || language.contains("de")){
      log.info "Only german audio line"
      if (getMediaInfo(f, '{vf}') == "1080p" || getMediaInfo(f, '{vf}') == "720p"){
        log.info "HD"
        args.eachMediaFolder{
          rename(file: it,output:"/mnt/NAS/MOViES/$Type/GER/HD/")
          Section = Type+"GERHD"
        }
      }else if (getMediaInfo(f, '{vf}') == "2160p"){
        log.info "UHD"
        args.eachMediaFolder{
          rename(file: it,output:"/mnt/NAS/MOViES/$Type/GER/UHD/")
          Section = Type+"GERUHD"          
        }        
      }else{
        log.info "SD"
        args.eachMediaFolder{
          rename(file: it,output:"/mnt/NAS/MOViES/$Type/GER/SD/")
          Section = Type+"GERSD"
        }
      } 
    }else if (getMediaInfo(f, '{media.Audio_Language_List}').contains("Eng") || getMediaInfo(f, '{media.Audio_Language_List}').contains("ENG") || language.contains("en")){
      log.info "Only english audio line"
      if (getMediaInfo(f, '{vf}') == "1080p" || getMediaInfo(f, '{vf}') == "720p"){
        log.info "HD"
        args.eachMediaFolder{
          rename(file: it,output:"/mnt/NAS/MOViES/$Type/ENG/HD/")
          Section = Type+"ENGHD"
        }
      }else if (getMediaInfo(f, '{vf}') == "2160p"){
        log.info "UHD"
        args.eachMediaFolder{
          rename(file: it,output:"/mnt/NAS/MOViES/$Type/ENG/UHD/")
          Section = Type+"ENGUHD"          
        }
      }else{
        log.info "SD"
        args.eachMediaFolder{
          rename(file: it,output:"/mnt/NAS/MOViES/$Type/ENG/SD/")
          Section = Type+"ENGSD" 
        }
      }
    } 
  }else{
    log.info "Huston we've got a Problem. Found "+getMediaInfo(f, '{media.AudioCount}').toInteger()+" Audio lines."
    System.exit(0)
  }
}
log.fine("Script finished [${_args.script}] at [${now}]")
Automator
Posts: 36
Joined: 30 Jul 2015, 10:17

Re: Help with my script

Post by Automator »

I think I just figured out the part with the subtitles... But I don't know how I can make the files to take the correct name name of the mkv .{subt}.{ext}

Code: Select all

args.getFiles{ it.isSubtitle() }.each{
  log.info "Moving $it"
  it.moveTo(new File(ParentFolder, it.name))
}
Btw. the Parent Folder is also a bit shitty right now I use it from eachMediaFolder...
User avatar
rednoah
The Source
Posts: 22984
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with my script

Post by rednoah »

1.
Automator wrote: 21 Jan 2018, 19:10 Okay, so far so good. I tried the custom expressions --format "/mnt/NAS/{file.path.contains('mycondition') ? 'a' : 'b'}/{media.audioCount > 1 ? 'MULTi' : audioLanguages.first()}/{HD}/{ny}" seams to work so far. But I need more so I guess I should go back to scripting.
No. How did you leap to that conclusion? What more to do you need?

i.e. a format {expression} can be more than one line and can be arbitrarily complex:

Code: Select all

/path/to/media/
{
	if (vf in ['720p', '1080p']) {
		return 'HD'
	} else {
		return 'SD'
	}
}
/{plex}

2.
About moving subtitle files, didn't I give you the code for exactly that already? How is it different from what you need?
viewtopic.php?f=4&t=5622#p32008
:idea: Please read the FAQ and How to Request Help.
Automator
Posts: 36
Joined: 30 Jul 2015, 10:17

Re: Help with my script

Post by Automator »

1. Okay I see. Renaming is good. But I don't need renaming only. I need to clean, move subtitles, rename, check for duplicates and update plex? I don't think I can do this all in one line...

2. Yes but you sent me the code for CLI not for scripting. Like I said in 1. CLI is nice. But it takes multiple CLI commands to accomplish what I can do with one script...

This is my subtitle moving right now.

Code: Select all

args.eachMediaFolder{
  ParentFolder = it
  log.info ParentFolder
  args.getFiles{ it.isSubtitle() }.each{
    log.info "Moving $it"
    it.moveTo(new File(ParentFolder, it.name))
  }
}
It works... But only if I do one move at the time. And it does not rename the subtitle files. It leave them like they where...
Automator
Posts: 36
Joined: 30 Jul 2015, 10:17

Re: Help with my script

Post by Automator »

Okay I got again some progress. Now I am able to move the subtitles multiple movies inside a movie folder into within the correct movie folder.

Code: Select all

args.eachMediaFolder{ dir->
  log.info "Working with: $dir"
  dir.getFiles{ it.isSubtitle() }.each{
	
    log.info "Moving $it to $dir/$it.name"
  
    it.moveTo(new File(dir, it.name)
  } 
}
But I can not give them the "name of the movie file".{subt}.{ext} inside that folder... Since moveTo does somehow not accept format...
User avatar
rednoah
The Source
Posts: 22984
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with my script

Post by rednoah »

Automator wrote: 21 Jan 2018, 21:53 I need to clean, move subtitles, rename, check for duplicates and update plex? I don't think I can do this all in one line...
All of these tasks seem to be fairly independent from each other. I'd write a simple script (maybe just a single command) for each task. That'll make your live easier during development, testing and debugging.
:idea: Please read the FAQ and How to Request Help.
Automator
Posts: 36
Joined: 30 Jul 2015, 10:17

Re: Help with my script

Post by Automator »

As far as I can tell the script now works flawless. Only issue that remains is the not working duplication script part since the fn:duplication is also not working :-( and the part about the subtitles not having the same correct filename as I would like to do it. But as far as I can tell plex no longer cares about that.

Can you help fix the remaining two steps?

Code: Select all

args.eachMediaFolder{ dir->
  log.info "Working with: $dir"
  dir.getFiles{ it.isSubtitle() }.each{
	
    log.info "Moving $it to $dir/$it.name"
  
    //it.moveTo(new File(dir, it.name))
  }  
  dir.getFiles{ it.isVideo() }.each{ f->
    if (f.path.contains("CondA")){
	  log.info "CondA"
	  Type = "CondA"
    } else if (f.path.contains("CondB")){
	  log.info "CondB"
	  Type = "CondB"
    } else {
	  log.info f.path
	  System.exit()
    }
    if (getMediaInfo(f, '{media.AudioCount}').toInteger() > 1){
      log.info getMediaInfo(f, '{media.AudioCount}')+" Audio Lines"
	  if (getMediaInfo(f, '{media.Audio_Language_List}').contains("Ger") || getMediaInfo(f, '{media.Audio_Language_List}').contains("GER") && getMediaInfo(f, '{media.Audio_Language_List}').contains("Eng") || getMediaInfo(f, '{media.Audio_Language_List}').contains("ENG") || language.contains("ende") ){
	    log.info "I found german and english audio lines"
	    if (getMediaInfo(f, '{vf}') == "1080p" || getMediaInfo(f, '{vf}') == "720p"){
		  log.info "HD"
		  rename(file: dir,output:"/mnt/NAS/MOViES/$Type/MULTi/HD/")
		  Section = Type+"MULTiHD"
	    } else if (getMediaInfo(f, '{vf}') == "2160p"){
	      log.info "UHD"
		  rename(file: dir,output:"/mnt/NAS/MOViES/$Type/MULTi/UHD/")
		  Section = Type+"MULTiUHD"          
	    } else {
		  log.info "SD"
		  rename(file: dir,output:"/mnt/NAS/MOViES/$Type/MULTi/SD/")
		  Section = Type+"MULTiSD"
	    }		
	  } else {
	    log.info "Huston we've got a Problem. I found: "+getMediaInfo(f, '{media.Audio_Language_List}')
	  }
    } else if (getMediaInfo(f, '{media.AudioCount}').toInteger() == 1){
	  log.info "Found only 1 audio line"
	  if (getMediaInfo(f, '{media.Audio_Language_List}').contains("Ger") || getMediaInfo(f, '{media.Audio_Language_List}').contains("GER") || language.contains("de")){
	    log.info "Only german audio line"
	    if (getMediaInfo(f, '{vf}') == "1080p" || getMediaInfo(f, '{vf}') == "720p"){
		  log.info "HD"
		  rename(file: dir,output:"/mnt/NAS/MOViES/$Type/GER/HD/")
		  Section = Type+"GERHD"
	    } else if (getMediaInfo(f, '{vf}') == "2160p"){
		  log.info "UHD"
		  rename(file: dir,output:"/mnt/NAS/MOViES/$Type/GER/UHD/")
		  Section = Type+"GERUHD"                  
	    } else {
		  log.info "SD"
		  rename(file: dir,output:"/mnt/NAS/MOViES/$Type/GER/SD/")
		  Section = Type+"GERSD"
	    } 
	  }else if (getMediaInfo(f, '{media.Audio_Language_List}').contains("Eng") || getMediaInfo(f, '{media.Audio_Language_List}').contains("ENG") || language.contains("en")){
	    log.info "Only english audio line"
	    if (getMediaInfo(f, '{vf}') == "1080p" || getMediaInfo(f, '{vf}') == "720p"){
		  log.info "HD"
		  rename(file: dir,output:"/mnt/NAS/MOViES/$Type/ENG/HD/")
		  Section = Type+"ENGHD"
	    } else if (getMediaInfo(f, '{vf}') == "2160p"){
		  log.info "UHD"
		  rename(file: dir,output:"/mnt/NAS/MOViES/$Type/ENG/UHD/")
		  Section = Type+"ENGUHD"          
	    } else {
		  log.info "SD"
		  rename(file: dir,output:"/mnt/NAS/MOViES/$Type/ENG/SD/")
		  Section = Type+"ENGSD" 
	    }
	  } 
    } else {
	  log.info "Huston we've got a Problem. Found "+getMediaInfo(f, '{media.AudioCount}').toInteger()+" Audio lines."
	  System.exit(0)
    }
  }
}
User avatar
rednoah
The Source
Posts: 22984
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with my script

Post by rednoah »

If the duplicates script is not working, then it's most likely because xattr isn't working or not enabled, so this script simply won't work.

You could form the script though and do your own duplicate detection logic that doesn't rely on previous stored xattr metadata.
:idea: Please read the FAQ and How to Request Help.
Automator
Posts: 36
Joined: 30 Jul 2015, 10:17

Re: Help with my script

Post by Automator »

rednoah wrote: 22 Jan 2018, 09:53 If the duplicates script is not working, then it's most likely because xattr isn't working or not enabled, so this script simply won't work.
sysinfo gives me back that:

Code: Select all

FileBot 4.7.14 (r5256)
JNA Native: 5.2.0
MediaInfo: 0.7.96
Apache Commons VFS: [zip, rar]
Chromaprint: 1.4.2
Extended Attributes: OK
Unicode Filesystem: OK
Script Bundle: 2017-11-21 (r512)
Groovy: 2.4.12
JRE: OpenJDK Runtime Environment 1.8.0_161
JVM: 64-bit OpenJDK 64-Bit Server VM
CPU/MEM: 2 Core / 880 MB Max Memory / 21 MB Used Memory
OS: Linux (amd64)
Package: PORTABLE
uname: Linux whatever.local 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Done ヾ(@⌒ー⌒@)ノ
But I guess since the NAS is mounted its not possible to read the xattr.
rednoah wrote: 22 Jan 2018, 09:53 You could form the script though and do your own duplicate detection logic that doesn't rely on previous stored xattr metadata.
I was thinking the same. Do you have a sample so I see in which direction I have to look? How about looking up the result of MovieDB in the Folder Structures? And then in the resuluts getting back the mediainfo and comparing them?
User avatar
rednoah
The Source
Posts: 22984
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with my script

Post by rednoah »

The duplicates script is designed to run on a large number of files. If you check TheMovieDB for all of then you'll get banned.

You'll have to identify movies locally (e.g. by checking the parent folder name) and then the rest of scripting will work. So essentially you just need your own groupBy code that groups all files that are the same movie.
:idea: Please read the FAQ and How to Request Help.
Automator
Posts: 36
Joined: 30 Jul 2015, 10:17

Re: Help with my script

Post by Automator »

Okay, I was able to write a little script which groupsby directory name since they are the same. And prefers the directories in the right place. So far so good.

But I don't know the syntax or code for using the lookup result. Can you help me out? If I for example have a download Big.Buck.Bunny.2008.1080p.x264-NoGRP the lookup of MovieDB will give me back "Big Buck Bunny (2008)" how can I use this lookup result "Big Buck Bunny (2008)" in my code?
Automator
Posts: 36
Joined: 30 Jul 2015, 10:17

Re: Help with my script

Post by Automator »

Okay, I was able to write a little script which groupsby directory name since they are the same. And prefers the directories in the right place. So far so good.

But I don't know the syntax or code for using the lookup result. Can you help me out? If I for example have a download Big.Buck.Bunny.2008.1080p.x264-NoGRP the lookup of MovieDB will give me back "Big Buck Bunny (2008)" how can I use this lookup result "Big Buck Bunny (2008)" in my code?
User avatar
rednoah
The Source
Posts: 22984
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with my script

Post by rednoah »

You can't use the lookup result if the lookup result hasn't been stored in xattr.

:!: Please don't abuse TheMovieDB by doing online lookup for duplicate detection repeatedly for all your files.
:idea: Please read the FAQ and How to Request Help.
Automator
Posts: 36
Joined: 30 Jul 2015, 10:17

Re: Help with my script

Post by Automator »

Okay, I already solved that one.

Don't worry its not duplication so I am not running hundreds and hundreds of requests against themoviedb. I got some movie who can not be matched I guess. They return CmdlineException: Failed to identify or process any files is there a way to debug that more closely? See what filebot sends to themoviedb as a query. Also is it possible to use the tt value out of a nfo file inside that movie folder? I looked at your CmdlineOperations.java and also at the MovieIdentificationService but it does not make click so far.
User avatar
rednoah
The Source
Posts: 22984
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with my script

Post by rednoah »

1.
This thread was somehow lost in time:
viewtopic.php?f=3&t=3913

You can set the JAVA_OPTS environment variable to pass in additional Java System Properties, and then FileBot will spam you with logs like you wouldn't believe.

e.g.

Code: Select all

export JAVA_OPTS="-Dnet.filebot.logging.debug=ALL -Dnet.filebot.web.WebRequest.log.response=true"

2.
FileBot should be using tt1234567 patterns from nearby NFO files to identify movies. At least that'll make sure it's part of the options, though may not necessarily win during ranking.
:idea: Please read the FAQ and How to Request Help.
Automator
Posts: 36
Joined: 30 Jul 2015, 10:17

Re: Help with my script

Post by Automator »

1. Perfect :-) gives me a lot more feedback. Thank you

2. Not sure if it does it since I can not see anything about matching or finding tt or nfo in the output I get even with the JAVA_OPTS you gave me turned on.

3. I am not sure if this is intentional since when i query manually it works...

filebot -script /pathtomyscript/new.groovy Resident.Evil.The.Final.Chapter.German.DL.1080p.BluRay.x264-KiNOWELT/ --action test

Code: Select all

Rank [Resident Evil The Final Chapter] => [Resident Evil: The Final Chapter (2016), Proteus (1995), Resident Evil (2002), The Resident (2011), Shrek Forever After (2010), The Final (2010), Evil (2005), Evil (2012), The Evil (1978), Evil (2003)]
Match Series Name => [] [Resident Evil The Final Chapter]
Query Series => [resident evil the final chapter]
Query Movie => [resident evil the final chapter]
Rank [Resident Evil The Final Chapter] => [Resident Evil: The Final Chapter (2016), Resident Evil (2002), Proteus (1995), Resident Evil: Afterlife (2010), The Resident (2011), Saw: The Final Chapter (2010), Angel III: The Final Chapter (1988), Lake Placid: The Final Chapter (2012), Urusei Yatsura: The Final Chapter (1988), Friday the 13th: The Final Chapter (1984), Puppet Master 5: The Final Chapter (1994)]
Rename movies using [TheMovieDB]
Auto-detect movie from context: [/whatever/Resident.Evil.The.Final.Chapter.German.DL.1080p.BluRay.x264-KiNOWELT]
CmdlineException: Failed to identify or process any files

filebot -script /pathtomyscript/new.groovy Resident.Evil.The.Final.Chapter.German.DL.1080p.BluRay.x264-KiNOWELT/ --q "Resident Evil The Final Chapter 2016" --action test

Code: Select all

Rank [Resident Evil The Final Chapter] => [Resident Evil: The Final Chapter (2016), Proteus (1995), Resident Evil (2002), The Resident (2011), Shrek Forever After (2010), The Final (2010), Evil (2005), Evil (2012), The Evil (1978), Evil (2003)]
Match Series Name => [] [Resident Evil The Final Chapter]
Query Series => [resident evil the final chapter]
Query Movie => [resident evil the final chapter]
Rank [Resident Evil The Final Chapter] => [Resident Evil: The Final Chapter (2016), Resident Evil (2002), Proteus (1995), Resident Evil: Afterlife (2010), The Resident (2011), Saw: The Final Chapter (2010), Angel III: The Final Chapter (1988), Lake Placid: The Final Chapter (2012), Urusei Yatsura: The Final Chapter (1988), Friday the 13th: The Final Chapter (1984), Puppet Master 5: The Final Chapter (1994)]
Rename movies using [TheMovieDB]
Looking up movie by query [Resident Evil The Final Chapter 2016]
[TEST] from [/whatever/Resident.Evil.The.Final.Chapter.German.DL.1080p.BluRay.x264-KiNOWELT] to [/whereeveriwanteputit/Resident Evil The Final Chapter (2016)]
Processed 1 files
Automator
Posts: 36
Joined: 30 Jul 2015, 10:17

Re: Help with my script

Post by Automator »

After some more diggin into that matter. I still think there is something crazying going on what that renaming method using folders... in my script I have to call it with rename(file: my_dir, output:"blabalbalbal") on cli if I call it on a folder it just takes a .nfo file and renames that nfo file... not the folder... not the movie :-S

here is the output when running:
filebot -rename Resident.Evil.The.Final.Chapter.German.DL.1080p.BluRay.x264-KiNOWELT/ --action test --format "/home/jd/NAS/{file.path.contains('condA') ? 'condA' : 'condB'}/{media.audioCount > 1 ? 'MULTi' : audioLanguages.first()}/{HD}/{ny}"

Code: Select all

Using persistent disk cache /usr/bin/filebot/data/cache/0
Rank [Resident Evil The Final Chapter] => [Resident Evil: The Final Chapter (2016), Proteus (1995), Resident Evil (2002), The Resident (2011), Shrek Forever After (2010), The Final (2010), Evil (2005), Evil (2012), The Evil (1978), Evil (2003)]
Rank [Resident Evil The Final Chapter] => [Resident Evil: The Final Chapter (2016), Proteus (1995), Resident Evil (2002), The Resident (2011), Shrek Forever After (2010), The Final (2010), Evil (2005), Evil (2012), The Evil (1978), Evil (2003)]
Match Series Name => [] [Resident Evil The Final Chapter]
Query Series => [resident evil the final chapter]
Match Series Name => [] [Resident Evil The Final Chapter]
Query Series => [resident evil the final chapter]
Query Movie => [resident evil the final chapter]
Query Movie => [resident evil the final chapter]
Rank [Resident Evil The Final Chapter] => [Resident Evil: The Final Chapter (2016), Resident Evil (2002), Proteus (1995), Resident Evil: Afterlife (2010), The Resident (2011), Saw: The Final Chapter (2010), Angel III: The Final Chapter (1988), Lake Placid: The Final Chapter (2012), Urusei Yatsura: The Final Chapter (1988), Friday the 13th: The Final Chapter (1984), Puppet Master 5: The Final Chapter (1994)]
Rank [Resident Evil The Final Chapter] => [Resident Evil: The Final Chapter (2016), Resident Evil (2002), Proteus (1995), Resident Evil: Afterlife (2010), The Resident (2011), Saw: The Final Chapter (2010), Angel III: The Final Chapter (1988), Lake Placid: The Final Chapter (2012), Urusei Yatsura: The Final Chapter (1988), Friday the 13th: The Final Chapter (1984), Puppet Master 5: The Final Chapter (1994)]
Rank [Resident Evil The Final Chapter] => [Resident Evil: The Final Chapter (2016), Proteus (1995), Resident Evil (2002), The Resident (2011), Shrek Forever After (2010), The Final (2010), Evil (2005), Evil (2012), The Evil (1978), Evil (2003)]
Match Series Name => [] [Resident Evil The Final Chapter]
Query Series => [resident evil the final chapter]
Query Movie => [resident evil the final chapter]
Rank [Resident Evil The Final Chapter] => [Resident Evil: The Final Chapter (2016), Resident Evil (2002), Proteus (1995), Resident Evil: Afterlife (2010), The Resident (2011), Saw: The Final Chapter (2010), Angel III: The Final Chapter (1988), Lake Placid: The Final Chapter (2012), Urusei Yatsura: The Final Chapter (1988), Friday the 13th: The Final Chapter (1984), Puppet Master 5: The Final Chapter (1994)]
Rename movies using [TheMovieDB]
Auto-detect movie from context: [/whatever/Resident.Evil.The.Final.Chapter.German.DL.1080p.BluRay.x264-KiNOWELT/kinowelt-resident-evil-the-final-chapter-1080p.mkv]
Stripping invalid characters from new path: /whatever/condB/MULTi/HD/Resident Evil: The Final Chapter (2016)
[TEST] from [/whatever/Resident.Evil.The.Final.Chapter.German.DL.1080p.BluRay.x264-KiNOWELT/kinowelt-resident-evil-the-final-chapter-1080p.nfo] to [/whatever/condB/MULTi/HD/Resident Evil The Final Chapter (2016).nfo]
Processed 1 files
Post Reply