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 Player.OpenSubtitles() public #544

Open
insomniachi opened this issue Jan 12, 2025 · 0 comments
Open

Make Player.OpenSubtitles() public #544

insomniachi opened this issue Jan 12, 2025 · 0 comments

Comments

@insomniachi
Copy link

I'm trying to open subtitles from a url.
something like
http://example.com/Stream.subrip?api_key=<key>

the generic Open method that takes a url string doesn't recognize this as a subtitle

    public static string GetUrlExtention(string url)
        => url.LastIndexOf(".") > 0 ? url[(url.LastIndexOf(".") + 1)..].ToLower() : "";

this method detects the extension as .subrib?api_key=

even if it correctly parsed extension, it's not on this list.

    public static List<string> ExtensionsSubtitles = new()
    {
        "ass", "ssa", "srt", "sub", "txt", "text", "vtt"
    };

So i tried using reflection to call the OpenSubtitles method. and it worked perfectly fine.

MethodInfo? dynMethod = player.GetType().GetMethod("OpenSubtitles", BindingFlags.NonPublic | BindingFlags.Instance);
dynMethod?.Invoke(player, [url]);

Fixes could be

  1. let me call OpenSubtitles directly since i know for 100% that it's a subtitle
  2. Fix Generic open method. while getting extention, query parameters should be ignored. and ExtensionsSubtitles should contain all supported extensions.
  3. There is an Open overload that takes System.IO.Stream. from comments it looks like it only opens audio/video so no use for me.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant