Groovy Expression Fail (Please Take Pity On Me)
Posted: 30 Nov 2018, 10:01
Hi y'all!
First off, that you SO much to the developer. A couple years back I taught myself python to do essentially the same renaming functions Filebot does (at some point I'd actually like to see if there is anything I can help contribute to the development of Filebot, but that is for another time).
Problem is, this whole Groovy expression thing is kicking my ass.
Normally I'd embrace this as a learning opportunity (I loved learning Python through trial and error), but I am absolutely swamped with work for the next couple weeks. That said, if y'all will help me with my stupid, noob questions (some of which might come across as me being lazy, although I'll work to keep that to an absolute minimum).
My naming scheme was always about using a modified (and I would argue standardized, more logical) version of scene/P2P file naming conventions.
Resolution
My python code:
Audio Codecs
For audio codecs, I would like some to include "channels" and others not/
Acceptable audio formats would be:
Now, this is where it gets embarrassing.
I can't even figure out how to make a proper Groovy expression for something as simple as "if ac is ac3, leave out channels, else ' '+channels. Why doesn't
work?
There will be many questions to come. However, I promise the upside of me being an idiot about some of this stuff is that I make fantastic tutorials once I understand it.
Thank you so much for this wonderful product, and thanks in advance for your support! <3
First off, that you SO much to the developer. A couple years back I taught myself python to do essentially the same renaming functions Filebot does (at some point I'd actually like to see if there is anything I can help contribute to the development of Filebot, but that is for another time).
Problem is, this whole Groovy expression thing is kicking my ass.
Normally I'd embrace this as a learning opportunity (I loved learning Python through trial and error), but I am absolutely swamped with work for the next couple weeks. That said, if y'all will help me with my stupid, noob questions (some of which might come across as me being lazy, although I'll work to keep that to an absolute minimum).
My naming scheme was always about using a modified (and I would argue standardized, more logical) version of scene/P2P file naming conventions.
Resolution
My python code:
Code: Select all
media_resolution="1080p" if media_video_stream["height"] in range(1070,1090) else "720p" if media_video_stream["height"] in range(710,730) else "540p" if media_video_stream["height"] in range(530,550) else "480p" if media_video_stream["height"] in range(470,490) and media_video_stream["codec_name"]=="h264" else "SD" if media_video_stream["height"]<=480 else ""
For audio codecs, I would like some to include "channels" and others not/
Acceptable audio formats would be:
- DTS-HD MA 7.1
DTS-HD MA 5.1
DTS-HR MA 5.1
LPCM 7.1
LPCM 5.1
TrueHD 7.1
TrueHD 5.1
DD5.1
DD2.0
24bit 192kHz FLAC
24bit 96kHz FLAC
24bit FLAC
FLAC
DTS
MP3
AAC2.0
AAC-LC
AAC
OOG
WMA
Code: Select all
audio_formats=["DTS-HD MA 7.1","DTS-HD MA 5.1","DTS-HR MA 5.1","LPCM 7.1","LPCM 5.1","TrueHD 7.1","TrueHD 5.1","DD5.1","DD2.0","24bit 192kHz FLAC","24bit 96kHz FLAC","24bit FLAC","FLAC","DTS","MP3","AAC2.0","AAC-LC","AAC","OOG","WMA"]
media_audio_tracks=sorted([af for af in set([("DTS-HD MA 7.1" if s["profile"]=="DTS-HD MA" and s["channels"]==8 else "DTS-HD MA 6.1" if s["profile"]=="DTS-HD MA" and s["channels"]==7 else "DTS-HD MA 5.1" if s["profile"]=="DTS-HD MA" and s["channels"]==6 else "TrueHD 7.1" if s["codec_name"]=="truehd" and s["channels"]==8 else "TrueHD 5.1" if s["codec_name"]=="truehd" and s["channels"]==6 else "DTS" if s["codec_name"]=="dca" and s["channels"]==6 else "DD5.1" if s["codec_name"]=="ac3" and s["channels"]==6 else "DD2.0" if s["codec_name"]=="ac3" and s["channels"]==2 else "AAC2.0" if s["codec_name"]=="aac" and s["channels"]==2 else "AAC" if s["codec_name"]=="aac" else "MP3" if s["codec_name"]=="mp3" else "WMA" if s["codec_name"]=="wmapro" else "") for s in media_audio_streams]) if af],key=lambda fmt: audio_formats.index(fmt) if fmt else "")
//I am taking the highest quality audio format, as that is all I'm interested in putting in the file name
I can't even figure out how to make a proper Groovy expression for something as simple as "if ac is ac3, leave out channels, else ' '+channels. Why doesn't
Code: Select all
{(ac == /AC3/) ? '' : ' '+channels}
There will be many questions to come. However, I promise the upside of me being an idiot about some of this stuff is that I make fantastic tutorials once I understand it.
Thank you so much for this wonderful product, and thanks in advance for your support! <3