Subtitle stored in different folder to movie

Any questions? Need some help?
Post Reply
CHA0SENG7NE
Posts: 50
Joined: 19 Apr 2017, 22:13

Subtitle stored in different folder to movie

Post by CHA0SENG7NE » 06 May 2020, 10:49

Hi

I have an issue with subtitles being moved into separate folder from movies.

My current script...

Code: Select all

\\192.168.0.160\Multimedia/Movies/{f =~ /(?i)3D|3\.D|3\-D/ ? '3D Movies' : vf =~ /2160p/ ? '4K Movies' : 'Movies'}/{AZ}/
{kodi.name} [{director}] [{imdbid}]
/{kodi.name} [{vf} {vc} {hdr} 
{
	def codecList =
	[
	'MP3' : 'MP3',
	'PCM' : 'PCM',
	'AAC LC' : 'AAC',
	'AAC LC SBR' : 'AAC',
	'AC 3' : 'AC3',
	'AC 3 Dep' : 'EAC3',
	'E AC 3' : 'EAC3',
	'E AC 3 JOC' : 'EAC3 Atmos',
	'DTS' : 'DTS',
	'DTS 96 24' : 'DTS 96-24',
	'DTS ES' : 'DTS-ES',
	'DTS ES XXCH' : 'DTS-ES',
	'DTS XBR' : 'DTS-HD HRA',
	'DTS ES XBR' : 'DTS-HD HRA',
	'DTS ES XXCH XBR' : 'DTS-HD HRA',
	'DTS XLL' : 'DTS-HD MA',
	'DTS ES XLL' : 'DTS-HD MA',
	'DTS ES XXCH XLL' : 'DTS-HD MA',
	'DTS XLL X' : 'DTS-X',
	'MLP FBA' : 'TrueHD',
	'MLP FBA 16 ch' : 'Dolby Atmos'
	]
	def filter = { [it.codec, it.ch, it.objects] }

	def audioStreams = []
	def audioClean = { it.replaceAll(/[\p{Pd}\p{Space}]/, ' ').replaceAll(/\p{Space}{2,}/, ' ').slash(' ') }
	def channelClean = { it.replaceAll(/Debug.+|Object\sBased\s?\/?|(\d+)?\sobjects\s\/\s|0.(?=\d.\d)|20/).replaceAll(/6.0/,'5.1').replaceAll(/8.0/,'7.1')}
	def oneStream = { it.collect{ filter(it) }*.minus(null).unique().flatten().join(' ') }
	def dString = { it.toDouble().toString() }
	def toInt = { it.toInteger() }

	audio.collect{ au ->
		def codec = audioClean(any{ au['CodecID/Hint'] }{ au['Format'] })
		def format_profile = any{ audioClean(au['Format_AdditionalFeatures'])}{}
		def String ch = any{ channelClean(au.ChannelPositionsString2).tokenize('\\/')*.toDouble().toString().sum() }
			{ channelClean(dString(au.ChannelsOriginal)) } { channelClean(dString(au.Channels)) }

		def chFilter =	(( ( (ac == 'AAC'||ac == 'MP3') && ch != '2.0') || ( (ac == 'AC3'||ac == 'EAC3'||ac == 'DTS'||ac == 'TrueHD'||ac == 'MLPFBA') && ch != '5.1' ) ) ? ch : null)

		def combined = allOf{codec}{format_profile}.join(' ')
		audioStreams << ['index' : codecList.findIndexOf {it.key == combined}, 'default' : au['default'][0].toBoolean(),
		'codec' : codecList.get(combined, 'UNKNOWN_FORMAT'), 'combined' : combined, 'ch' : ch, 
		'bitrate' : any{toInt(au.BitRate)}{toInt(au.BitRate_Maximum)}{au.FrameRate.toDouble()}{null},
		'objects' : any{'(' + au['NumberOfDynamicObjects'] + ' Objs)'}{null}, 'lang' : any{au.'LanguageString3'.upperInitial()}{null} ]
		return audioStreams
	}

	def allStreams = audioStreams.collect{ filter(it) }*.minus(null).unique()*.join(' ')
	def preferredStream = oneStream(audioStreams.findAll{ it.index == audioStreams.index.max() })
	def bestBitRate = oneStream(audioStreams.findAll{ it.bitrate == audioStreams.bitrate.max() })
	def defaultStream = oneStream(audioStreams.findAll{it.default == true})
}] 
{[source]} [{runtime}mins]

Example
The film gets put into correct folder and named properly

Code: Select all

\\192.168.0.160\Multimedia\Movies\Movies\A\Æon Flux (2005) [Karyn Kusama] [tt0402022]\Æon Flux (2005) [1080p x265 AAC 5.1] [BluRay] [93mins].mp4
The subtitle is saved into

Code: Select all

\\192.168.0.160\Multimedia\Movies\A\Æon Flux (2005).eng [Karyn Kusama] [tt0402022]\Æon Flux (2005).eng [ ] [93mins].srt
Any help working this out or understanding would be appreciated.

I can only guess that the subtitle has no video information so its named differently... that's all i have got :(

Thank you

User avatar
rednoah
The Source
Posts: 18381
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Subtitle stored in different folder to movie

Post by rednoah » 06 May 2020, 12:15

1.
I recommend sticking to one of the default formats and omitting complex custom code:

Code: Select all

{plex.derive{" [$vf, $vc, $ac]"}}
viewtopic.php?t=4116


:idea: The original author of this snippet possibly did not take subtitles into account. If you rely heavily on custom code, then it's best to write it yourself, with all your specific use cases in mind, otherwise you'll find debugging and fixing things later on excruciatingly difficult to impossible.


2.
Are your subtitle files organized and named reasonably well?

Code: Select all

Avatar.2009.mp4
Avatar.2009.eng.srt

:idea: FileBot will implicitly read MediaInfo from the primary video file when formatting a subtitle file, and so most formats do not need to take subtitles into account specifically. However, if you process orphaned subtitle files (i.e. subtitles without corresponding video file) then MediaInfo will be limited.

:idea: A completely different approach might be more appropriate, such as pre-organizing subtitles files first to be more in line (same folder, same name) with their corresponding video files. Alternatively, processing video files and subtitle files in the same batch an also help with associating them.
:idea: Please read the FAQ and How to Request Help.

CHA0SENG7NE
Posts: 50
Joined: 19 Apr 2017, 22:13

Re: Subtitle stored in different folder to movie

Post by CHA0SENG7NE » 06 May 2020, 12:30

Thanks for the information.
Ill take your advice and stick to the default format as described.
Thank you

CHA0SENG7NE
Posts: 50
Joined: 19 Apr 2017, 22:13

Re: Subtitle stored in different folder to movie

Post by CHA0SENG7NE » 06 May 2020, 12:59

I just don't understand enough to be honest!

User avatar
rednoah
The Source
Posts: 18381
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Subtitle stored in different folder to movie

Post by rednoah » 06 May 2020, 13:22

The easiest way is to just use {plex}. If you don't embed MediaInfo in the file name, then all video files and subtitle are assured to end up with the same file name. ;)
:idea: Please read the FAQ and How to Request Help.

CHA0SENG7NE
Posts: 50
Joined: 19 Apr 2017, 22:13

Re: Subtitle stored in different folder to movie

Post by CHA0SENG7NE » 07 May 2020, 19:35

Thanks Rednoah. Will using {Plex} still allow the movies to be stored into the correct folders i.e 4k 3d and movies?

User avatar
rednoah
The Source
Posts: 18381
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Subtitle stored in different folder to movie

Post by rednoah » 07 May 2020, 20:18

CHA0SENG7NE wrote:
07 May 2020, 19:35
Will using {Plex} still allow the movies to be stored into the correct folders i.e 4k 3d and movies?
{plex} organized movies correctly as per Naming and organizing your Movie files which does not specify 4K or 3D folders:
https://support.plex.tv/articles/naming ... dia-files/


If you want a folder structure like this, then you need to customize the format:

Code: Select all

Movies/...
4K Movies/...
3D Movies/...

You can use {plex.tail} to re-use most of the {plex} format. But you'll have to write your own code to generate the top level folder yourself.

e.g.

Code: Select all

{f =~ /3D/ ? '3D Movies' : hd =~ /UHD/ ? '4K Movies' : 'Movies'}/{plex.tail}
:!: Since {hd} is based on MediaInfo, this format may not work well for orphaned subtitles, as explained above. But you could identify 4K movies by checking the file path for certain markers, like what we're doing with 3D here.
:idea: Please read the FAQ and How to Request Help.

CHA0SENG7NE
Posts: 50
Joined: 19 Apr 2017, 22:13

Re: Subtitle stored in different folder to movie

Post by CHA0SENG7NE » 08 May 2020, 23:39

That makes sense and works thank you. Subtitles are being moved correctly now.
Always helpful Rednoah

CHA0SENG7NE
Posts: 50
Joined: 19 Apr 2017, 22:13

Re: Subtitle stored in different folder to movie

Post by CHA0SENG7NE » 18 May 2020, 08:50

Is it possible to ignore subtitles when naming? To not transfer from downloaded folder?

User avatar
rednoah
The Source
Posts: 18381
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Subtitle stored in different folder to movie

Post by rednoah » 18 May 2020, 09:18

You can use --def ignore to ignore input paths.

e.g.
viewtopic.php?f=4&t=11812#p50647



EDIT:

:!: I am assuming that you're using the amc script.
:idea: Please read the FAQ and How to Request Help.

CHA0SENG7NE
Posts: 50
Joined: 19 Apr 2017, 22:13

Re: Subtitle stored in different folder to movie

Post by CHA0SENG7NE » 18 May 2020, 10:19

Yes im using the AMC script.
I dont use subtitles unless its required for a foreign film.
So if I can prevent the subtitles being processed then it will stop the mess of my folders it makes.
So if i add

--def ignore=".srt|.idx|.sub"

Should fix this?

CHA0SENG7NE
Posts: 50
Joined: 19 Apr 2017, 22:13

Re: Subtitle stored in different folder to movie

Post by CHA0SENG7NE » 20 May 2020, 21:27

Hi Rednoah
I have been playing with the plex.name and tail. Also with Kodi. Trying to learn some new things. I then changed my original script from {kodi.name} to {ny}

Hey presto the orphan subs are named the same as the movie file. I added {subt} to the end too.

All working perfectly. Thank you.

Post Reply