birchill / 10ten-ja-reader

A browser extension to translate Japanese by hovering over words.
https://addons.mozilla.org/firefox/addon/10ten-ja-reader/
GNU General Public License v3.0
601 stars 45 forks source link

[FEATURE] Support for Plex subtitles #976

Open erlisdhima opened 2 years ago

erlisdhima commented 2 years ago

Hi,

It would be nice if this extension had support for Plex subtitles.

Imported SRT subtitles are not rendered in the video, but are accessible in the browser as text. The only problem is that you need to access the dom element for subtitles since when you pause the video, the first layer is the play button overlay.

I'm not sure how achievable this is, but it will be really nice as it helps when watching content with japanese subs.

Thanks!

birtles commented 2 years ago

Hi!

Thanks for filing this. From your description this sounds possible. For example, for some sites like asahi.com and nikkei.com we have special handling that digs in behind overlay elements to get to the text.

I'm not familiar with Plex, unfortunately. Do you have an example video and set of steps I can follow to test with?

Thanks!

erlisdhima commented 2 years ago

Thanks for getting back!

I'm testing this with "Nausicaa of the Valley of the Wind".

You can upload a SRT subtitle as below (click on settings bottom-right). Screenshot from 2022-08-01 20-17-12

When you pause the video, the subs are under the play button (but the play button is on a separate button element - I guess different z-index?) Screenshot from 2022-08-01 20-18-40

Finally, if I search for the sentence, it looks as below: Screenshot from 2022-08-01 20-21-41

Seems like the subtitle element is under the following path: #plex > .PlayerContainer-container-* > .Player-fullPlayerContainer-* > Subtitles-measure-* > .Subtitles-renderer-* > .paused > div > div > div > span > span

I don't know if there's a better way to go to this path, if it changes between different videos, screens etc, or if this is going to change in the future, but seemed consistent with other tests I've done.

Let me know if this helps.

Thanks!

birtles commented 2 years ago

Thanks for getting back!

Likewise, thank you!

I'm testing this with "Nausicaa of the Valley of the Wind".

I signed up for Plex and searched for Nausicaa of the Valley of the Wind but no results came up, I'm afraid.

You can upload a SRT subtitle as below (click on settings bottom-right).

Can you suggest somewhere I can find SRT subtitles? Thanks.

birtles commented 2 years ago

Seems like the subtitle element is under the following path: #plex > .PlayerContainer-container-* > .Player-fullPlayerContainer-* > Subtitles-measure-* > .Subtitles-renderer-* > .paused > div > div > div > span > span

I'll need to test but it might be that we don't need the full path to the text element. Instead, we need to detect the overlay element, temporarily neuter it, do the text lookup, then restore the overlay. We do something similar for newspaper websites but we have so far managed to keep the code very general.

erlisdhima commented 2 years ago

I signed up for Plex and searched for Nausicaa of the Valley of the Wind but no results came up, I'm afraid.

With Plex you need to have your own media, as its a media server. I have it as a blu ray rip.

I guess you don't need to have the correct film. As long as you're able to upload a srt subtitle to any film, try any from this page: https://kitsunekko.net/dirlist.php?dir=subtitles%2Fjapanese%2F

Let me know if it helps.