Page 1 of 1

episode rename problem

Posted: 22 Aug 2015, 11:27
by kim
if you have 2 files named i.e :
mr.robinson.101.mp4
mr.robot.S01E02.mp4

then the mr.robinson.101.mp4 file will be renamed mr.robot.S01E01.mp4
the problem is something to do with the episode number?

if you take file name mr.robinson.S01E03.mp4 into the mix then all is ok
mr.robinson.101.mp4
mr.robinson.S01E03.mp4
mr.robot.S01E02.mp4


need fix or if problem at my end, then help pls


EDIT:
a workaround is to put the files into a folder like this:
mr.robinson\mr.robinson.101.mp4
mr.robot\mr.robot.S01E02.mp4

Re: episode rename problem

Posted: 22 Aug 2015, 23:45
by rednoah
That might happen in certain circumstances if you process files in the same batch. It should be fine if you have them in separate folders, or just by processing them in two separate batches.

Re: episode rename problem

Posted: 23 Aug 2015, 00:11
by kim
so cant fix the "problem" :( ?

is there a way to get a CLI script to only scrape/lookup 1 file at a time then ?

Re: episode rename problem

Posted: 23 Aug 2015, 09:15
by rednoah
You're using the CLI then? The amc script seems to differentiate them just fine here:

Code: Select all

Input: /Users/reinhard/Development/test/AMC-TEST/mr.robinson.101.mp4
Input: /Users/reinhard/Development/test/AMC-TEST/mr.robot.S01E02.mp4
mr.robinson.101.mp4 [series: Robinson, movie: Mr. Robinson (1976)]
Exclude Movie: Mr. Robinson (1976)
Group: [tvs:robinson, mov:null, anime:null] => [mr.robinson.101.mp4]
Group: [tvs:mr robot] => [mr.robot.S01E02.mp4]
Rename episodes using [TheTVDB]
Auto-detected query: [Robinson, mr robinson]
Fetching episode data for [Robinson]
Fetching episode data for [Mr. Robinson]
Fetching episode data for [The Robinsons]
Fetching episode data for [Robinson Report]
Fetching episode data for [Robinson Crusoe]
[DUPLICATE] Rename [/Users/reinhard/Development/test/AMC-TEST/mr.robinson.101.mp4] to [/Users/reinhard/Development/test/OUTPUT/TV Shows/Mr. Robinson/Season 01/Mr. Robinson - S01E01 - Pilot.mp4]
Processed 1 files
Rename episodes using [TheTVDB]
Auto-detected query: [mr robot]
Fetching episode data for [Mr. Robot]
[DUPLICATE] Rename [/Users/reinhard/Development/test/AMC-TEST/mr.robot.S01E02.mp4] to [/Users/reinhard/Development/test/OUTPUT/TV Shows/Mr. Robot/Season 01/Mr. Robot - S01E02 - eps1.1_ones-and-zer0es.mpeg.mp4]
Processed 1 files

Re: episode rename problem

Posted: 23 Aug 2015, 13:28
by kim
im not using amc but a custom script

Code: Select all

def override = _args.conflict == 'override'

include('lib/htpc')

def tvDir    = 'D:/_DoWnLoaD/Done/TV' as File
def movieDir = 'D:/_DoWnLoaD/Done/Movies' as File

def tvFormat   = '''D:/_DoWnLoaD/TV/{n.sortName().replace(':', ' - ').trim()}/{n.replaceTrailingBrackets().trim().space('.')}{'.'+s00e00}{'.'+t.space('.').replaceAll(/[!?.]+$/).replacePart('(Part.$1)')}{'.'+vf.match(/(?i)720p/).lower}{'.'+fn.match(/._.x264/).replaceAll(/._.x264/, 'HDTV')}{'.'+fn.match(/(?i)HDTV/).upper()}{'.'+video.codecID.match(/DX50|DIVX|DIV3|XVID/).replaceAll(/DX50/, 'DivX5').replaceAll(/DIVX/, 'DivX4').replaceAll(/DIV3/, 'DivX3').replaceAll(/XVID/, 'XViD')}{'.'+vc.match(/(?i)x264|AVC/).replaceAll(/(?i)x264/, 'x264').replaceAll(/(?i)AVC/, 'x264')}{'.'+ac.match(/MP3/)}{'.'+ac.match(/AAC/)+'.'+af.match(/6ch/)}{'.'+ac.match(/AAC/)+''-af.match(/2ch/)}{'.'+ac.match(/AC3|DTS/)+''-af.match(/6ch/)}{'-'+group}{'.'+lang}'''

def movieFormat   = '''/Movies/{(((info.spokenLanguages[0]==~/da/)|(info.spokenLanguages[1]==~/da/))?(info.originalName):(info.Name)).replaceFirst(/^(?i)(The|A|An)\\s(.+)/, /$2, $1/).replace(': ', ' - ').upperInitial().replaceTrailingBrackets().trim()}{' [' + fn.matchAll(/UNCUT|UNRATED|EXTENDED|Special.*Edition|Final.Cut|Super.Sized.*Rated.*Version|director.*cut|Ultimate.*Edition|THE*.*CUT/)*.lower()*.upperInitial()*.lowerTrail().unique().join(', ').replaceAll(/[._]/, ' ') + ']'}{' ('+y+')'}/{(((info.spokenLanguages[0]==~/da/)|(info.spokenLanguages[1]==~/da/))?(info.originalName):(info.Name)).upperInitial().replaceAll(/ - /, '.').replaceAll(/[',]/, '').space('.').replaceTrailingBrackets().trim()}{'.'+fn.matchAll(/UNCUT|UNRATED|EXTENDED|Special.*Edition|Final.Cut|Super.Sized.*Rated.*Version|director.*cut|Ultimate.*Edition|THE*.*CUT/)*.upperInitial()*.lowerTrail().unique().join('.').replaceAll(/[_]/, '.').upper()}{'.'+fn.match(/(?i)Repack|Proper|RERIP/).upper()}{'.'+y}{'.'+fn.match(/\\bR5\\b/)}{'.'+fn.match(/(?i)3D/)}{'.'+fn.match(/HSBS/)}{'.'+video.displayAspectRatioString.match(/4:3|5:4|1.3|1.4/).replaceAll(/4:3|5:4|1.3|1.4/, 'FS')}{'.'+fn.match(/\\bDK\\b/)}{'.'+fn.match(/\\bDC\\b/)}{'.'+fn.match(/\\bSTV\\b/)}{'.'+fn.match(/m720p|720p|m1080p|1080p/)}{'.'+vf.match(/576p|480p|360p/).replaceAll(/576p/, '480p')}{'.'+fn.match(/HDTVRip/)}{'.'+source}{'.'+video.codecID.match(/DX50|DIVX|DIV3|XVID/).replaceAll(/DX50/, 'DivX5').replaceAll(/DIVX/, 'DivX4').replaceAll(/DIV3/, 'DivX3').replaceAll(/XVID/, 'XViD')}{'.'+vc.match(/(?i)x264|AVC/).replaceAll(/(?i)x264/, 'x264').replaceAll(/(?i)AVC/, 'x264')}{'.'+ac.match(/MP3/)}{'.'+ac.match(/AAC/)+'.'+af.match(/6ch/)}{'.'+ac.match(/AAC/)-af.match(/2ch/)}{'.'+ac.match(/AC3|DTS/)+'.'+af.match(/1ch|2ch|4ch/)}{'.'+ac.match(/AC3|DTS/)-af.match(/6ch/)}{fn.match(/(?:(?:\\-\\w+$)|(?:\\-\\w+[\\.\\_]\\w+[\\-]\\w+$)|(?:\\-\\w+(?=\\.cd[0-9]|\\-trailer|\\.part[0-9]|\\.dan|\\.eng))|(?:\\-\\w+[\\-\\.\\_]\\w+$)|(?:\\-\\w+[\\.]+\\w+(?=\\.cd[0-9])))/).replaceAll(/[\\_]$/, '')}{'.cd'+pi}{('.'+lang).replaceAll(/(?i).ind/, '')}'''

	[movieDir as File].eachMediaFolder{ rename(folder:it, db:'TheMovieDB', format:movieFormat, strict:false) }


def incomplete(f) { f.name =~ /[.]incomplete|[.]chunk|[.]par$|[.]dat$|[.]url$/ }

tvDir.getFolders{ !it.hasFile{ incomplete(it) } && it.hasFile{ it.isVideo() } }.each{ dir ->

	def files = dir.listFiles{ it.isVideo() }

	[tvDir as File].eachMediaFolder{ rename(folder:it, db:'TheTVDB', format:tvFormat, strict:false) }
	}

movieDir.getFolders{ !it.hasFile{ incomplete(it) } && it.hasFile{ it.isVideo() } }.each{ dir ->
	println "Processing $dir"
	def files = dir.listFiles{ it.isVideo() }

	// fetch only missing artwork by default
	if (!override && dir.hasFile{it.name == 'movie.nfo'} && dir.hasFile{it.name == 'poster.jpg'} && dir.hasFile{it.name == 'fanart.jpg'}) {
		println "Skipping $dir"
		return
	}
	
	def videos = dir.listFiles{ it.isVideo() }
	def query = _args.query
	def options = []
	
	if (query) {
		// manual search
		options = TheMovieDB.searchMovie(query, _args.locale)
		// sort by relevance
		options = options.sortBySimilarity(query, { it.name })
	} else {
		// auto-detection
		options = MediaDetection.detectMovie(videos[0], TheMovieDB, _args.locale, true)
	}
	
	if (options.isEmpty()) {
		println "Movie not found: $query"
		return
	}
	
	// auto-select movie
	def movie = options[0]
	
	// maybe require user input
	if (options.size() != 1 && !_args.nonStrict && !java.awt.GraphicsEnvironment.headless) {
		movie = javax.swing.JOptionPane.showInputDialog(null, 'Please select Movie:', dir.path, 3, null, options.toArray(), movie)
		if (movie == null) return null
	}
	
	println "$dir => $movie"
	try {
		fetchMovieArtworkAndNfo(dir, movie, dir.getFiles{ it.isVideo() }.sort{ it.length() }.reverse().findResult{ it }, true, override, _args.locale ?: Locale.ENGLISH)
	} catch(e) {
		println "${e.class.simpleName}: ${e.message}"
	}

	rename(file:files, db:'TheMovieDB', format:movieFormat)
}
btw: if you have a way to make my script better pls feel free :) ?