A really helpful addition to the available functions would be one to truncate a string at a given length.
I have found that some episode titles returned by TheTVDB are unmanageable. If you want some insane examples, look at the titles of Rocky & Bullwinkle Show episodes. (The writers obviously had a lot of fun naming them.)
This causes problems in two cases I've run into:
1) Path + filename length > 256. Once renamed, these files can't be copied elsewhere because the destination path name exceeds the maximum Windows length of 256 characters.
2) Encrypted volume constraints. One of the shares on my NAS is encrypted and that limits the maximum length of any filename to 143 characters.
Thanks.
Function Request: String.Truncate(length)
Re: Function Request: String.Truncate(length)
e.g.
https://stackoverflow.com/a/15713996/1514467
By default, {t} is truncated at ~150 characters.
Code: Select all
{t.take(80)}Re: Function Request: String.Truncate(length)
is there a way to truncate to the nearest word after that length? for example: if the showname would normally resolve to 'Special Intake Machinator 9000' and i set {n.take(20)} it will resolve to 'Special Intake Machi'. it would be cool if it could use something like {n.take(w,3)} and resolve to 'Special Intake Machinator' instead, making it easier to recognize series titles. and, yeah, this is more applicable when sorting anime. most often i don't want the exhaustive title, just the first 'n' words of it.
Re: Function Request: String.Truncate(length)
Try this:
Format: Select all
{ n.tokenize(' ').take(3).join(' ') }Format: Select all
{ n.truncate(20, /\W/) }