firsttris / plugin.video.sendtokodi

:tv: plays various stream sites on kodi using youtube-dl
MIT License
125 stars 28 forks source link

Support available Subtitles #75

Closed GautamMKGarg closed 1 year ago

GautamMKGarg commented 2 years ago

Describe the bug In the videos in which subtitles are available, subtitles should be added to kodi while playing video.

To Reproduce Try to open this video in Kodi via sendtokodi. Subtitles will not be played in kodi https://www.youtube.com/watch?v=NFHDHcs4BvQ

./yt-dlp.sh --list-subs https://www.youtube.com/watch?v=NFHDHcs4BvQ above command shows list of available subtitles.

Expected behavior Subtitles should be played if available

Kodi and sendtokodi version (please complete the following information):

GautamMKGarg commented 2 years ago

@nullket and @firsttris I know this is new feature and it might be difficult to implement in short time. But can this be launched in next update?

nullket commented 2 years ago

I currently do not have the time and with the little time I have I am currently focusing on the adaptive streaming thing to get broken websites work again and also achieve a higher video quality.

I highly encourage you to learn a bit python if you can’t program yet, this feature could be a nice first project afterwards as our little plugin here is not to complicated for beginners!

Otherwise another contributor might find the time or you have to wait

nullket commented 2 years ago

Posting some research for another contributor/another day:

nullket commented 1 year ago

@GautamMKGarg you wanted this feature, can you check if https://github.com/firsttris/plugin.video.sendtokodi/pull/82 works or breaks anything for you?

@zmousm you wrote: "Checking for Kodi compatibility not feasible". What happens if an unplayable subtitle gets passed? Will it simply be ignored?

zmousm commented 1 year ago

@zmousm you wrote: "Checking for Kodi compatibility not feasible". What happens if a unplayable subtitle gets passed? Will it simply be ignored?

I can't say. I have only managed to test locally on recent arm64 nightly builds, which do support WebVTT anyway. So I couldn't come up with a test case, namely a yt-dlp supported URL with a Kodi-unsupported subtitle; but if you have any ideas I'd be happy to try something out, for example by adding a dummy extractor to yt-dlp.

nullket commented 1 year ago

Ah I see, you already got the VTT support. Then lets see what @GautamMKGarg says how it works form him.

Just a minor thing: I know the plugin needs refactoring but to not make it worse, could you please be so kind and change result.get('subtitles') or {} to result.get('subtitles', None) or result.get('subtitles', {}) so the fallback if the key is missing is more in style with the rest of the code

zmousm commented 1 year ago

Ah I see, you already got the VTT support. Then lets see what @GautamMKGarg says how it works form him.

So I got the artifact from the PR build and installed it on my Android box running Kodi 19.3, over a regular installation (from the repository). I sent it a yt-dlp supported URL which provides an external VTT subtitle, and Kodi surprisingly loaded it just fine... I can't say how come this is supported; I couldn't find if it was somehow back-ported to Matrix.

Just a minor thing: I know the plugin needs refactoring but to not make it worse, could you please be so kind and change result.get('subtitles') or {} to result.get('subtitles', None) or result.get('subtitles', {}) so the fallback if the key is missing is more in style with the rest of the code

Sure

GautamMKGarg commented 1 year ago

Hello Team

Thanks for implementation, will check and update you soon.

GautamMKGarg commented 1 year ago

I tried 3 videos, for 2 of them, it does not work and for 1 video it worked for me on 19.4. Kodi was not crashed with any URL.

URL1: https://www.youtube.com/watch?v=NFHDHcs4BvQ Not working

URL 2: https://na-training-1.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=8285224a-9a2b-4957-84f2-acb0000c4ea9 Not Working

URL 3: https://www.megatv.com/tvshows/734141/epeisodio-1-88/ Working

Please check if we can add support for more subtitles somehow else this pull request looks fine because at-least it started supporting some of the subtitles and also, it's not crashing Kodi if subtitle is not supported.

zmousm commented 1 year ago

I tried 3 videos, for 2 of them, it does not work and for 1 video it worked for me on 19.4. Kodi was not crashed with any URL.

URL1: https://www.youtube.com/watch?v=NFHDHcs4BvQ Not working

WFM on Kodi 19.3. Kodi shows 6 subtitles.

yt-dlp --list-subs
[...]
Language Name    Formats
en       English vtt, ttml, srv3, srv2, srv1, json3

URL 2: https://na-training-1.hosted.panopto.com/Panopto/Pages/Viewer.aspx?id=8285224a-9a2b-4957-84f2-acb0000c4ea9 Not Working

Does not WFM on Kodi 19.3. It does WFM on Kodi 20 nightly.

yt-dlp --list-subs
[...]
Language Formats
en-US    srt
es-ES    srt

Not sure what goes on with Kodi 19.3, I may try to check the log. One difference between the two is that on Kodi 19.3 I have not enabled the adaptive streaming setting. It also seemed to have a hard time playing back the content.

GautamMKGarg commented 1 year ago

WFM on Kodi 19.3. Kodi shows 6 subtitles.

Yes, now first URL working fine for me. I think there was some issue with configuration. Not sure, but now it's working. Out of 6 subtitles, only 6th is working. I think remaining are not supported in version 19.4

zmousm commented 1 year ago

Out of 6 subtitles, only 6th is working. I think remaining are not supported in version 19.4

I recall that kodi 19.3 was showing subtitle 1/6, which should have been the vtt version. But I can't say for sure currently.

GautamMKGarg commented 1 year ago

I think code can be released, as supported subtitles are getting played and none supported subtitles are not crashing/not causing any other issue in kodi. @nullket and @firsttris what's your opinion on this?