jellyfin / jellyfin-plugin-opensubtitles

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

Download error: System.Xml.XmlException: Root element is missin #41

Closed Robpizza closed 3 years ago

Robpizza commented 3 years ago

Describe the bug The plugin does not work in the latest version.

System (please complete the following information):

To Reproduce Install the plugin, login and run the scheduled task.

Expected behavior Subtitle download, but it throws errors.

Logs

System.Xml.XmlException: Root element is missing. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at XmlRpcHandler.XmlRpcGenerator.DecodeMethodResponse(String xmlResponse) at OpenSubtitlesHandler.OpenSubtitles.LogInAsync(String username, String password, String language, CancellationToken cancellationToken) at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Login(CancellationToken cancellationToken) at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Search(SubtitleSearchRequest request, CancellationToken cancellationToken) at MediaBrowser.Providers.Subtitles.SubtitleManager.SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken) [2021-03-09 11:32:31.357 +00:00] [INF] "Download missing subtitles" Completed after 0 minute(s) and 42 seconds [2021-03-09 11:32:31.357 +00:00] [INF] ExecuteQueuedTasks

Additional context This is Anime content, I do not know if this is a direct problem!

AlexDias95 commented 3 years ago

I am having problems with opensubtitles too. My logs are:

[2021-03-09 11:38:55.725 +00:00] [ERR] [57] MediaBrowser.Providers.Subtitles.SubtitleManager: Error downloading subtitles from "Open Subtitles" System.Xml.XmlException: The 'hr' start tag on line 6 position 2 does not match the end tag of 'body'. Line 7, position 3. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag) at System.Xml.XmlTextReaderImpl.ParseEndElement() at System.Xml.XmlTextReaderImpl.ParseElementContent() at XmlRpcHandler.XmlRpcGenerator.DecodeMethodResponse(String xmlResponse) at OpenSubtitlesHandler.OpenSubtitles.LogInAsync(String username, String password, String language, CancellationToken cancellationToken) at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Login(CancellationToken cancellationToken) at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Search(SubtitleSearchRequest request, CancellationToken cancellationToken) at MediaBrowser.Providers.Subtitles.SubtitleManager.SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken)

cvium commented 3 years ago

Wrong repository. Moved.

Robpizza commented 3 years ago

Any updates on this?

voarsh2 commented 3 years ago

I am getting this on 10.7.0 Open Subtitles 9.0.0.0 - malfunctioned status

theroflcoptr commented 3 years ago

I am having problems with opensubtitles too. My logs are:

[2021-03-09 11:38:55.725 +00:00] [ERR] [57] MediaBrowser.Providers.Subtitles.SubtitleManager: Error downloading subtitles from "Open Subtitles" System.Xml.XmlException: The 'hr' start tag on line 6 position 2 does not match the end tag of 'body'. Line 7, position 3. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag) at System.Xml.XmlTextReaderImpl.ParseEndElement() at System.Xml.XmlTextReaderImpl.ParseElementContent() at XmlRpcHandler.XmlRpcGenerator.DecodeMethodResponse(String xmlResponse) at OpenSubtitlesHandler.OpenSubtitles.LogInAsync(String username, String password, String language, CancellationToken cancellationToken) at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Login(CancellationToken cancellationToken) at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Search(SubtitleSearchRequest request, CancellationToken cancellationToken) at MediaBrowser.Providers.Subtitles.SubtitleManager.SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken)

I was getting this error. I uninstalled the plugin, restarted jellyfin, re-installed the plugin, and restarted jellyfin again and that seemed to take care of it.

MayeulC commented 3 years ago

I can reproduce on jellyfin/jellyfin:latest docker image.

I am logged in to a premium opensubtitle account, have a few plugins installed, and running 10.7.1.

[2021-04-07 09:06:59.481 +00:00] [ERR] [5] MediaBrowser.Providers.Subtitles.SubtitleManager: Error downloading subtitles from "Open Subtitles"
System.Xml.XmlException: Root element is missing.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
   at XmlRpcHandler.XmlRpcGenerator.DecodeMethodResponse(String xmlResponse)
   at OpenSubtitlesHandler.OpenSubtitles.LogInAsync(String username, String password, String language, CancellationToken cancellationToken)
   at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Login(CancellationToken cancellationToken)
   at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Search(SubtitleSearchRequest request, CancellationToken cancellationToken)
   at MediaBrowser.Providers.Subtitles.SubtitleManager.SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken)

Before updating to the latest tag (was using stable-rc), I used to get:

[2021-04-07 08:56:03.246 +00:00] [ERR] [42] MediaBrowser.Providers.Subtitles.SubtitleManager: Error downloading subtitles from "Open Subtitles"
System.Xml.XmlException: The 'hr' start tag on line 6 position 2 does not match the end tag of 'body'. Line 7, position 3.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)
   at System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag)
   at System.Xml.XmlTextReaderImpl.ParseEndElement()
   at System.Xml.XmlTextReaderImpl.ParseElementContent()
   at XmlRpcHandler.XmlRpcGenerator.DecodeMethodResponse(String xmlResponse)
   at OpenSubtitlesHandler.OpenSubtitles.LogInAsync(String username, String password, String language, CancellationToken cancellationToken)
   at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Login(CancellationToken cancellationToken)
   at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Search(SubtitleSearchRequest request, CancellationToken cancellationToken)
   at MediaBrowser.Providers.Subtitles.SubtitleManager.SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken)

I will try the workaround posted above with reinstalling the plugin.

MayeulC commented 3 years ago

Reinstalling the plugin and deleted config doesn't work. The only thing I can think of that would be specific to my configuration is that I have a premium Opensubtitles account.

The error seems to come from that function, but I don't yet have a dev environment, so debugging is tricky:

https://github.com/jellyfin/jellyfin-plugin-opensubtitles/blob/af68848d4c70d06497d2f606b6f133a2b2b89d1e/OpenSubtitlesHandler/XML-RPC/XmlRpcGenerator.cs#L102

Robpizza commented 3 years ago

I think OpenSubTitles changed their api responses, atleast thats what I can think of when errors like The 'hr' start tag on line 6 position 2 does not match the end tag of 'body'. Line 7, position 3. start ocurring without any changes in Jellyfin.

MayeulC commented 3 years ago

Yes, that wouldn't be surprising. BTW, would you mind changing this issue title so something a bit more descriptive like Download error: System.Xml.XmlException: Root element is missing ?

uranderu commented 3 years ago

I am getting this on 10.7.0 Open Subtitles 9.0.0.0 - malfunctioned status

@voarsh2 fyi Open Subtitles 10 is the version you should use for 10.7. I get the same errors as OP in my logs: [2021-04-22 15:58:04.678 +00:00] [ERR] Error downloading subtitles from "Open Subtitles" System.Xml.XmlException: Root element is missing. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at XmlRpcHandler.XmlRpcGenerator.DecodeMethodResponse(String xmlResponse) at OpenSubtitlesHandler.OpenSubtitles.LogInAsync(String username, String password, String language, CancellationToken cancellationToken) at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Login(CancellationToken cancellationToken) at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Search(SubtitleSearchRequest request, CancellationToken cancellationToken) at MediaBrowser.Providers.Subtitles.SubtitleManager.SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken)

ManuLinares commented 3 years ago

OpenSubtitles plugin 10, jellyfin 10.7.2, same errors

abr 26 19:15:54 think jellyfin[76235]: [19:15:54] [ERR] [42] Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader: Invalid response type
abr 26 19:15:55 think jellyfin[76235]: [19:15:55] [ERR] [42] Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader: Invalid response type
abr 26 19:15:55 think jellyfin[76235]: [19:15:55] [ERR] [42] Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader: Invalid response type
abr 26 19:15:55 think jellyfin[76235]: [19:15:55] [ERR] [26] Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader: Invalid response type
abr 26 19:15:55 think jellyfin[76235]: [19:15:55] [ERR] [26] MediaBrowser.Providers.Subtitles.SubtitleManager: Error downloading subtitles from Open Subtitles
abr 26 19:15:55 think jellyfin[76235]: System.Xml.XmlException: 'src' is an unexpected token. The expected token is '='. Line 10, position 16.
abr 26 19:15:55 think jellyfin[76235]:    at System.Xml.XmlTextReaderImpl.Throw(Exception e)
abr 26 19:15:55 think jellyfin[76235]:    at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args)
abr 26 19:15:55 think jellyfin[76235]:    at System.Xml.XmlTextReaderImpl.ThrowUnexpectedToken(String expectedToken1, String expectedToken2)
abr 26 19:15:55 think jellyfin[76235]:    at System.Xml.XmlTextReaderImpl.ParseAttributes()
abr 26 19:15:55 think jellyfin[76235]:    at System.Xml.XmlTextReaderImpl.ParseElement()
abr 26 19:15:55 think jellyfin[76235]:    at System.Xml.XmlTextReaderImpl.ParseElementContent()
abr 26 19:15:55 think jellyfin[76235]:    at XmlRpcHandler.XmlRpcGenerator.DecodeMethodResponse(String xmlResponse)
abr 26 19:15:55 think jellyfin[76235]:    at OpenSubtitlesHandler.OpenSubtitles.SearchSubtitlesAsync(SubtitleSearchParameters[] parameters, CancellationToken cancellationToken)
abr 26 19:15:55 think jellyfin[76235]:    at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Search(SubtitleSearchRequest request, CancellationToken cancellationToken)
abr 26 19:15:55 think jellyfin[76235]:    at MediaBrowser.Providers.Subtitles.SubtitleManager.SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken)
abr 26 18:24:02 think jellyfin[16785]: [18:24:02] [ERR] [176] MediaBrowser.Providers.Subtitles.SubtitleManager: Error downloading subtitles from Open Subtitles
abr 26 18:24:02 think jellyfin[16785]: System.Xml.XmlException: Root element is missing.
abr 26 18:24:02 think jellyfin[16785]:    at System.Xml.XmlTextReaderImpl.Throw(Exception e)
abr 26 18:24:02 think jellyfin[16785]:    at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
abr 26 18:24:02 think jellyfin[16785]:    at XmlRpcHandler.XmlRpcGenerator.DecodeMethodResponse(String xmlResponse)
abr 26 18:24:02 think jellyfin[16785]:    at OpenSubtitlesHandler.OpenSubtitles.LogInAsync(String username, String password, String language, CancellationToken cancellationToken)
abr 26 18:24:02 think jellyfin[16785]:    at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Login(CancellationToken cancellationToken)
abr 26 18:24:02 think jellyfin[16785]:    at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Search(SubtitleSearchRequest request, CancellationToken cancellationToken)
abr 26 18:24:02 think jellyfin[16785]:    at MediaBrowser.Providers.Subtitles.SubtitleManager.SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken)
douglasparker commented 3 years ago

Does anyone know if this bug is going to be resolved soon?

hackmonker commented 3 years ago

I guess I am not the only one. This a major plugin bug afaik

zjeffer commented 3 years ago

Has anyone found a fix yet?

douglasparker commented 3 years ago

Has anyone found a fix yet?

No fix or response from the dev team it seems.

MayeulC commented 3 years ago

Looks like the plugin still works for some people, though.

I have a VIP account, I wonder if this is related.

To whoever reads this, could you react with:

Thanks. This could help diagnosing the issue.

uranderu commented 3 years ago

I have changed my password to a very simple one (no ciphers or symbols) and now I get different errors: [2021-05-24 23:27:18.382 +00:00] [ERR] Error downloading subtitles from "Open Subtitles" System.Xml.XmlException: The 'hr' start tag on line 6 position 2 does not match the end tag of 'body'. Line 7, position 3. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.ThrowTagMismatch(NodeData startTag) at System.Xml.XmlTextReaderImpl.ParseEndElement() at System.Xml.XmlTextReaderImpl.ParseElementContent() at XmlRpcHandler.XmlRpcGenerator.DecodeMethodResponse(String xmlResponse) at OpenSubtitlesHandler.OpenSubtitles.LogInAsync(String username, String password, String language, CancellationToken cancellationToken) at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Login(CancellationToken cancellationToken) at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Search(SubtitleSearchRequest request, CancellationToken cancellationToken) at MediaBrowser.Providers.Subtitles.SubtitleManager.SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken) Can anyone else try to do the same so we could diagnose the problem better?

gabri94 commented 3 years ago

I'm having the same error. Jellyfin: v10.7.1 on Docker. Plugin version: 10.0.0

Glad to help if I can

Robpizza commented 3 years ago

Well to me it still looks like an endpoint problem. Like OpenSubtitles changed the way the API requests response, I do not have time to look into it, but if someone else could try looking into their api and maybe look into the changes made since begin April maybe.

zjeffer commented 3 years ago

If I build the plugin using the latest git version, I get this error instead after running the Download missing subtitles task:

[2021-05-25 19:28:19.632 +02:00] [ERR] Error downloading subtitles from "Open Subtitles"
System.NullReferenceException: Object reference not set to an instance of an object.
   at OpenSubtitlesHandler.Utilities.SendRequestAsync(Byte[] request, String userAgent, CancellationToken cancellationToken)
   at OpenSubtitlesHandler.OpenSubtitles.LogInAsync(String username, String password, String language, CancellationToken cancellationToken)
   at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Login(CancellationToken cancellationToken)
   at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Search(SubtitleSearchRequest request, CancellationToken cancellationToken)
   at MediaBrowser.Providers.Subtitles.SubtitleManager.SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken)

I'm not sure if it's related.

uranderu commented 3 years ago

@Robpizza I tried looking for some kind of changelog but personally I find it really hard to find some kind of official source. Their NPM package was last updated over a year ago (don't know if that is official or not). However they upgrading their API as you can see here: https://trac.opensubtitles.org/projects/opensubtitles. Maybe that is causing this error? However I would also like to point out that these issues have started appearing with V10 of this plugin, this can be a coincidence but I doubt it to be honest.

MBR-0001 commented 3 years ago

If I build the plugin using the latest git version, I get this error instead after running the Download missing subtitles task:

Latest git version is broken

I've rewritten the plugin to use the new REST API, mostly for my personal use but if anyone wants I can give instructions on how to get it running (it uses the new version of opensubtitles, opensubtitles.com so you'd need to migrate your account). From what I've seen so far it works fine, definitely better than the 10.0.0.0 lol

zjeffer commented 3 years ago

I've rewritten the plugin to use the new REST API, mostly for my personal use but if anyone wants I can give instructions on how to get it running (it uses the new version of opensubtitles, opensubtitles.com so you'd need to migrate your account). From what I've seen so far it works fine, definitely better than the 10.0.0.0 lol

@MBR-0001 I tested your fork, but I get this error:

<html><body>You are being <a href="http://api.opensubtitles.com/users/sign_in">redirected</a>.</body></html>
   at RESTOpenSubtitlesHandler.APIResponse`1..ctor(ValueTuple`4 obj)
   at RESTOpenSubtitlesHandler.OpenSubtitles.LogInAsync(String username, String password, CancellationToken cancellationToken)
   at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Login(CancellationToken cancellationToken)
   at Jellyfin.Plugin.OpenSubtitles.OpenSubtitleDownloader.Search(SubtitleSearchRequest request, CancellationToken cancellationToken)
   at MediaBrowser.Providers.Subtitles.SubtitleManager.SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken)
[2021-06-17 22:26:27.239 +02:00] [ERR] Error downloading subtitles from "Open Subtitles"
System.Exception: Failed to parse JSON: '<' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.

EDIT: Nevermind, it suddenly started working.

crobibero commented 3 years ago

I've rewritten the plugin to use the new REST API

Since you have it working, why not make a PR to bring your changes into the org? Every time I've tested this plugin it works fine for me, so it's very difficult to fix.

MBR-0001 commented 3 years ago

I've rewritten the plugin to use the new REST API

Since you have it working, why not make a PR to bring your changes into the org? Every time I've tested this plugin it works fine for me, so it's very difficult to fix.

Well I originally thought about it but then I found out the new API is in beta and it requires account migration, if that's not a problem I guess I could open a PR :thinking:

crobibero commented 3 years ago

Ah I see.. Glad you have it working, hopefully the new API will be ready for production use soon

uranderu commented 3 years ago

Well, this is just my opinion, but I would rather use a beta API that works (or partially works) than nothing at all.

MBR-0001 commented 3 years ago

I asked the developer what the current state of new API is and got the following response

Well it is rather stable, but we run without safety net, we don't have any monitoring, backup or replication,
so in case of problem we could have some pretty long downtime.

We are now configuring new servers to handle this, but we are surfing in so much unknown territory,
I really can't tell if it's gonna take 2 or 6 month

I'll open a PR if you think this is considered good enough

douglasparker commented 3 years ago

I asked the developer what the current state of new API is and got the following response

Well it is rather stable, but we run without safety net, we don't have any monitoring, backup or replication,
so in case of problem we could have some pretty long downtime.

We are now configuring new servers to handle this, but we are surfing in so much unknown territory,
I really can't tell if it's gonna take 2 or 6 month

I'll open a PR if you think this is considered good enough

I think a PR should be opened. Simply because as it stands the current implementation isn't working, so it might as well be considered down 24/7 for those of us experiencing this issue.

As for their lack of monitoring, they can easily use a free service like UptimeRobot to monitor http endpoints or even better, a NetData server for in depth metrics and monitoring.

pieterhouwen commented 3 years ago

@MBR-0001 I've built and ran the plugin and it works very nicely. However now I'm getting alot of Authentication to Opensubtitles failed errors while the username, password and api key are all correct. Any idea what might be causing this?

pieterhouwen commented 3 years ago

This shows up in the frontend:

image

Which is weird because I can still login to OS using my username and password.

MBR-0001 commented 3 years ago

This shows up in the frontend:

image

Which is weird because I can still login to OS using my username and password.

Their API seems to be down, I believe the website doesn't use it which is why it works

It'd probably be a good idea to include a link to the status page in the error message 🤔

EDIT: to keep this issue "clean" it would probably be best to do rewrite-related discussions in https://github.com/jellyfin/jellyfin-plugin-opensubtitles/pull/54