mikf / gallery-dl

Command-line program to download image galleries and collections from several image hosting sites
GNU General Public License v2.0
10.68k stars 881 forks source link

Indicate the title was too long #5770

Closed a84r7a3rga76fg closed 6 days ago

a84r7a3rga76fg commented 1 week ago

When the title exceeds 20 i.e. {title[:20]}, how do I add something to it to indicate it exceeded 20?

Hrxn commented 1 week ago

What, exactly, is the issue here?

[:20] is using slicing on the {title} to extract a sequence starting with the first element to the element with the index 20, what is supposed to "exceed" here?

komoreshi commented 1 week ago

I'm guessing if {title} exceeds 20, they want something printed to stdout/as part of the log?

mikf commented 1 week ago

So something similar to :L20/too long/ (docs), but instead of replacing the entire string with "too long", it should still ensure that the string is shorter than the given limit and put an indicator at the end if its length does exceed the limit, e.g. Title Title too long in this particular example.

edit: this is already possible with f-strings:

"\fF {title if len(title) <= 200 else title[:196] + ' ...'}"
mikf commented 1 week ago

You can now do {title:X20/ .../} to have title end with ... if it is longer than 20 characters. Is this kind of what you wanted?

a84r7a3rga76fg commented 1 week ago

Yes, thanks