Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make IMAX Uppercase in Edition Tags #7649

Open
1 task done
owine opened this issue Oct 2, 2022 · 8 comments · May be fixed by #9880
Open
1 task done

Make IMAX Uppercase in Edition Tags #7649

owine opened this issue Oct 2, 2022 · 8 comments · May be fixed by #9880
Labels
Area: Organizer Issue is related to the Organizer Status: Help Wanted Help Wanted, no immediate plans for effort on this Type: Feature Request Issue is a feature request.

Comments

@owine
Copy link
Contributor

owine commented Oct 2, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe

Continuation of #7566 which was over my skis.

The IMAX (and potentially other) edition tags should be hardcoded to an all caps implementation and both replace how the edition is written in the db (usually Imax) as well as ignore case preference.

Describe the solution you'd like

Per @Qstick an edition normalization method in the parser

Describe alternatives you've considered

A hack to just replace Imax with uppercase.

Anything else?

None

AB#3850

@owine owine added Status: Needs Triage New Issue needing triage Type: Feature Request Issue is a feature request. labels Oct 2, 2022
@andy-reeves
Copy link

This needs to be looked at more completely. Currently if you use {edition-{EDITION TAGS}} you'll get {edition-IMAX} in the file path. If you use {edition-{Edition Tags}} you'll get {edition-Imax}. Now consider 10th Anniversary. if you use {edition-{EDITION TAGS}} you'll get {edition-10TH ANNIVERSARY} but with {edition-{Edition Tags}} you get {edition-10Th Anniversary} . I think this is not correct. Even in proper case then 10TH should be '10th' and not '10Th' (with a capital 'T').

@andy-reeves
Copy link

More investigation. Maybe something like:

public static string ToTitleCaseIgnoreOrdinals(this string text)
        {        
            string input = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(text);
            string result = Regex.Replace(input, "([0-9]st)|([0-9]th)|([0-9]rd)|([0-9]nd)", new MatchEvaluator((m) => m.Captures[0].Value.ToLower()), RegexOptions.IgnoreCase);
            return result;
        }

which will work for English but you'd need something else if edition tags have ordinal numbers in other languages.

@andy-reeves
Copy link

Add that as a StringExtension and then update:

  private void AddEditionTagsTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, MovieFile movieFile)
        {
            if (movieFile.Edition.IsNotNullOrWhiteSpace())
            {
                tokenHandlers["{Edition Tags}"] = m => CultureInfo.CurrentCulture.TextInfo.ToTitleCase(movieFile.Edition.ToLower());
            }
        }

to be:

 private void AddEditionTagsTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, MovieFile movieFile)
        {
            if (movieFile.Edition.IsNotNullOrWhiteSpace())
            {
                tokenHandlers["{Edition Tags}"] = m => movieFile.Edition.ToTitleCaseIgnoreOrdinals();
            }
        }

@andy-reeves
Copy link

Further research suggests movie editions use exclusively English ordinal numbering so the fix above will be fine. Let me know if youd like a pull request. @Qstick

@andy-reeves
Copy link

Would you like a pull request fixing this please?

@williamsulzer
Copy link

Would love to see Andy's fix implemented.

@brandonscript
Copy link

brandonscript commented Mar 11, 2024

Ok this has been on my list of small annoyances for a long time, so I've got a fix in the works! I don't love the pattern of nested function calls (a builder pattern might be more elegant?) but it works. Would love any feedback on this implementation, then I'm happy to send in a PR.

brandonscript@5582e8b

Handles strings that should always remain uppercase, e.g. IMAX, 3D, and ordinals that should always remain lowercase, e.g. 1st, 2nd, 3rd, 10th.

Wondering if we should include SDR and HDR too?
Edit: Added this

@brandonscript
Copy link

Discussion thread here as well: brandonscript@5582e8b#commitcomment-139616872, specifically what do we want to capitalize, and when?

@bakerboy448 bakerboy448 added Status: Help Wanted Help Wanted, no immediate plans for effort on this Area: Organizer Issue is related to the Organizer and removed Status: Needs Triage New Issue needing triage labels Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Organizer Issue is related to the Organizer Status: Help Wanted Help Wanted, no immediate plans for effort on this Type: Feature Request Issue is a feature request.
Projects
None yet
5 participants