OpenSubtitlesDownload icon indicating copy to clipboard operation
OpenSubtitlesDownload copied to clipboard

Searching by filename breaks when there's a number in the title

Open Huntracony opened this issue 3 years ago • 1 comments

When the filename includes the episode's title and that includes a number, it never seems to find any subtitles. Examples: The Americans S03E13 March 8, 1983.mkv The Americans S05E05 Lotus 1-2-3.mkv

(Guess what series I've been watching recently.) The search works fine when you remove the episode titles form the filenames. I also tested a random episode of Babylon 5 to see if numbers in the series name would break it too, but that seemed to work fine.

In case it matters, I'm using Windows CLI. And thanks for the tool! It's been very useful.

Huntracony avatar Nov 25 '21 13:11 Huntracony

True i confirm this but the problem is on opensubtitles.org.

Example:

I added this custom change as a workaround:

    # ==== Get file hash, size and name
    videoTitle = ''
    videoHash = hashFile(currentVideoPath)
    videoSize = os.path.getsize(currentVideoPath)
    videoFileName = os.path.basename(currentVideoPath)

    # Custom Change: Remove the episode number at the beginning
    # `opensubtitles.org` would not find any result with it.
    # https://github.com/emericg/OpenSubtitlesDownload/issues/84
    # Expectation: The character "-" split the episode number from the title
    if "-" in videoFileName[:5]:
        episode_number , videoFileName = videoFileName.split("-", maxsplit=1)

    # ==== Search for available subtitles

So 01 - My Title would be searched as My Title. The episode number has to be at the beginning and separated by a - in the first 5 characters. Of course, you can adapt the rules to match your naming preference.

Morikko avatar Sep 18 '22 10:09 Morikko

This doesn't happen anymore with the "new" provider opensubtitles.com

emericg avatar Jan 02 '24 16:01 emericg