jellyfin / jellyfin-plugin-opensubtitles

https://jellyfin.org
GNU General Public License v3.0
119 stars 25 forks source link

Cannot download subtitles for .strm files #122

Closed Xaque8787 closed 1 year ago

Xaque8787 commented 1 year ago

JF server 10.8.10 OS Windows 10 Valid opensubtitles.com account with API key All shows and movies have correct imbd and tmdb id meta data.

When trying to download subtitles for a tv show or movie that is a .strm file I get this error.

When trying to determine the hash of a show or movie that is a .strm file that points to a remote location(not on local disk), the hash fails. There appears to be no fallback to use the imdb id if the hash fails.

looking at the code in OpenSubtitleDownloader.cs, I can see the imdbid is taken into account

ERROR BELOW

[2023-05-15 11:44:53.953 -07:00] [ERR] [47] MediaBrowser.Providers.Subtitles.SubtitleManager: Error downloading subtitles from "Open Subtitles" System.IO.IOException: IOException while computing hash for C:\Users\path\to\Media\tvshows\HouseBroken\HouseBroken Season 02\HouseBroken S02E06.strm ---> System.IO.IOException: The parameter is incorrect. : 'C:\users\path\to\Media\tvshows\HouseBroken\HouseBroken Season 02\HouseBroken S02E06.strm' at System.IO.Strategies.FileStreamHelpers.ThrowInvalidArgument(SafeFileHandle handle) at System.IO.Strategies.OSFileStreamStrategy.Seek(Int64 offset, SeekOrigin origin) at System.IO.Strategies.BufferedFileStreamStrategy.Seek(Int64 offset, SeekOrigin origin) at System.IO.FileStream.Seek(Int64 offset, SeekOrigin origin) at Jellyfin.Plugin.OpenSubtitles.OpenSubtitlesHandler.OpenSubtitlesRequestHelper.ComputeHash(Stream input) at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Search(SubtitleSearchRequest request, CancellationToken cancellationToken) at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Search(SubtitleSearchRequest request, CancellationToken cancellationToken) --- End of inner exception stack trace --- at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Search(SubtitleSearchRequest request, CancellationToken cancellationToken) at MediaBrowser.Providers.Subtitles.SubtitleManager.<>c__DisplayClass11_0.<b__2>d.MoveNext()

MBR-0001 commented 1 year ago

.strm files are not supported by the plugin, afaik even before the rewrite I did they weren't supported.

It seems that computing the hash of a .strm file (the actual remote file) might not be an easy task, so I believe the best course would be to just skip that part for .strm files and use the other data that is available.

Xaque8787 commented 1 year ago

.strm files are not supported by the plugin, afaik even before the rewrite I did they weren't supported.

It seems that computing the hash of a .strm file (the actual remote file) might not be an easy task, so I believe the best course would be to just skip that part for .strm files and use the other data that is available.

Yeah it seems to be the case. The code doesn't seem to fallback to imdb I'd if the hash fails. I've fiddled around a bit and perhaps found a way to give a "dummy" hash (000000), in the hopes that then it will at least iterate to the part of the code that uses imdbid. I'm no dev or coder or anything so I'm a little stuck at building the edited plugin.

Any chance this will be addressed in the future? Would be as simple as instead of throwing an I/O error when hash failed to have some sort of fallback to imdbid?

Also would like to mention that sometime last year I believe, either in the late 10.7.x or early 10.8.x that plugin was successfully downloading subtitles from .strm. files. Sorry I can't recall the exact release, but I do know that one point in time it did work.

MBR-0001 commented 1 year ago

I've created the pull request for this (#124) in which the code skips the hash for .strm files, I don't know when that will be merged and available, that is up to jellyfin maintainers

MBR-0001 commented 1 year ago

You should be able to download a build from here https://github.com/MBR-0001/jellyfin-plugin-opensubtitles/actions/runs/5105670190 (artifacts), let me know how it works

Xaque8787 commented 1 year ago

Thanks for the quick response. I can confirm it works for both manual search and for scheduled tasks. Much appreciated!