jellyfin / jellyfin-plugin-opensubtitles

Home Page:https://jellyfin.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The OpenSubtitle task should stop when the prescribed number of downloads is reached.

develroo opened this issue · comments

Self-explanatory really. The plugin now correctly reports the amount of downloads left.

[23:58:33] [INF] [22] Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader: Remaining downloads: 60

So when the limit of 100 is reached

[00:33:59] [INF] [22] Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader: Remaining downloads: 0

The task should end and restart the next day when the quota has been reset. Otherwise, it will just clog the logs and put unnecessary load on the Opensubtitles servers.

[00:34:33] [ERR] [20] Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader: OpenSubtitles download limit reached
[00:34:51] [ERR] [18] Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader: OpenSubtitles download limit reached
....
[08:48:55] [ERR] [10] Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader: OpenSubtitles download limit reached
[08:49:02] [ERR] [18] Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader: OpenSubtitles download limit reached

As of right now I don’t believe the server has any way to handle this

we are sending in reset time in /login and will be also later in /download - so you know what is cooldown time until downloader counter is reset

The plugin already uses that to keep track of limits, the issue is that the jellyfin server (which tells the plugin to download subtitles) can't handle that so it attempts to download even after the quota is used up (but the plugin just throws an error)

It currently gets the reset time from /infos/user and /download (from the "Your quota will be renewed in 20 hours and 52 minutes (2021-08-24 12:02:10 UTC) " string, don't know if you remember but I asked if that could be added a couple of months ago 😆)
It would certainly be nice to have a reset_time_utc in /download since the current implementation isn't very "nice"

I am somewhat confused about the server not having some sort of signalling that can tell it a plugin has crashed or got stuck in a loop? That seems positively weird to me.

If there is some sort of signalling from the plugins to the server, even a keep alive signal, then it should be trivial either for the plugin to send "Terminate now" or the server to say "Have not heard for X plugin for 5 minutes terminate it"

So which is it? Is this really so hard to do ?

There's no signalling really, when the "download missing subtitles" task is ran the server goes through all libraries and for each episode/movie that is missing a subtitle "tells" the plugin to download it, it doesn't really care if the plugin succeeded or failed, it just keeps going

This can be changed but the server code is quite complex, I should be able to look into it once .NET 6 is fully released

Well is is planned in the new factoring? For sure as a programmer and sysadmin the idea of a plugin addon crashing or getting into an infinite loop is a serious oversight and it would be pragmatic and practical to not let plugins gobble up resource (or spam the log).

Let me know if this is a thing because atm the logs are a mess when you have thousands of titles timing out.

Well is is planned in the new factoring? For sure as a programmer and sysadmin the idea of a plugin addon crashing or getting into an infinite loop is a serious oversight and it would be pragmatic and practical to not let plugins gobble up resource (or spam the log).

Let me know if this is a thing because atm the logs are a mess when you have thousands of titles timing out.

function download_missing_subtitles_task()
  for movie in library do
    if movie.missing_subtitles then
      -- Prints an error to the log if we can't download the subs right now
      opensubtitles.try_download_subtitle(movie)
    end
  end
end

No crashes nor infinite loops, just a scary [ERR] in the logs cause we can't right now.
One per attempted and failed subtitle download.

Nothing serious, just noisy in the logs.


That aside, would blocking in the opensubtitles plugin until we get a refill be feasible? I'm assuming it runs in it's own async land, and won't actually block anything else by doing this (worst case blocks other subtitle providers?).

Well is is planned in the new factoring?

I don't know really, there isn't a public "to-do" list since jellyfin is an open source project and everyone contributes as much as they can, I personally hope I get it done before 10.8 is released (if nobody else does)

That aside, would blocking in the opensubtitles plugin until we get a refill be feasible? I'm assuming it runs in it's own async land, and won't actually block anything else by doing this (worst case blocks other subtitle providers?).

That's an interesting solution, it can be done that way I guess, I originally wanted to somehow add a way for a provider to let the core know subtitles can't be downloaded right now (so it cancels the automated task if there aren't any other providers? That sounds complicated now when I think about it)