Kolifanes / plugin.video.youtube

YouTube for Kodi with API fixed
GNU General Public License v2.0
119 stars 44 forks source link

Subtitles #40

Closed frenchdj closed 8 years ago

frenchdj commented 8 years ago

Hello, my name is João, i´m from portugal and i made 3 addons that only works with your pluggin. In one of my addons i´ve adden documentarys that needs subtitles. It works fine if the subtitle in portuguese is hardcoded in the video, but, if its not it doens´t apear in the video on kodi. Can you add subtitle item on the addon? Hope you understand my issue. Sorry my bad english Thanks a lot for the great plugin

h0d3nt3uf3l commented 8 years ago

Hi João, this might be a problem because we can only play the videos via the player of kodi. I know that ffmpeg (the programm which are the player based on) support such an funciton. Sadly I don't know if the player this can do. Maybe we're able to get this included with inputstream (an available plugin in kodi v17 (krypton)).

I see what I can do.

mac1202 commented 8 years ago

maybe you can have a look at the youtube-dl source, as support youtube subtitle. Here is a example output of mpv (that use youtube-dl for playing youtube url)

mpv https://www.youtube.com/watch\?v\=rlJTnzyCKEA
[cplayer] Run command: sub-add, flags=0, args=[https://www.youtube.com/api/timedtext?v=rlJTnzyCKEA&name=&fmt=vtt&lang=en, auto, vtt, en]
[ffmpeg] Opening https://www.youtube.com/api/timedtext?v=rlJTnzyCKEA&name=&fmt=vtt&lang=en
[ffmpeg] Mime-type: 'text/vtt; charset=UTF-8'
[lavf] Found 'webvtt' at score=100 size=2048.
[demux] Detected file format: webvtt (libavformat)
[cplayer] Run command: sub-add, flags=0, args=[https://www.youtube.com/api/timedtext?v=rlJTnzyCKEA&name=&fmt=vtt&lang=fi, auto, vtt, fi]
[ffmpeg] Opening https://www.youtube.com/api/timedtext?v=rlJTnzyCKEA&name=&fmt=vtt&lang=fi
[ffmpeg] Mime-type: 'text/vtt; charset=UTF-8'
[lavf] Found 'webvtt' at score=100 size=2048.
[demux] Detected file format: webvtt (libavformat)
[cplayer] Run command: sub-add, flags=0, args=[https://www.youtube.com/api/timedtext?v=rlJTnzyCKEA&name=&fmt=vtt&lang=de, auto, vtt, de]
[ffmpeg] Opening https://www.youtube.com/api/timedtext?v=rlJTnzyCKEA&name=&fmt=vtt&lang=de
[ffmpeg] Mime-type: 'text/vtt; charset=UTF-8'
[lavf] Found 'webvtt' at score=100 size=2048.
[demux] Detected file format: webvtt (libavformat)
[cplayer]      Subs  --sid=1 --slang=en 'vtt' (webvtt) (external)
[cplayer]      Subs  --sid=2 --slang=fi 'vtt' (webvtt) (external)
[cplayer]      Subs  --sid=3 --slang=de 'vtt' (webvtt) (external)
jdf76 commented 8 years ago

It’s not as simple as it looks. #1 you have to look at the code from youtube-dl. Is it written completely in python, plugins for Kodi have to be completely in python as far as I know.

2, we have 2 other pressing issues that need to be fixed before this Feature can be added.

3 Both h0d3nt3uf3l http://forum.kodi.tv/member.php?action=profile&uid=319537 and I are working on other projects for work and since h0d3nt3uf3l http://forum.kodi.tv/member.php?action=profile&uid=319537 is the main project maintainer at the moment, i help with I can. We has time he’s got other things he’s working on.

What i’m boiling down to is you will have to be patient with us. It’s not going to happen over night.

One thing you may want to do, and this is a suggestion not an order, is fork the plugin from github and work on the subtitle part yourself. it’s ok if you aren’t a coder but dabble in python, if you’re interested in learning python this may be a good start. This is a very popular project so feel free to tackle it if you fee like it.

Thanks Jeff

On Jul 12, 2016, at 7:55 AM, mac1202 notifications@github.com wrote:

maybe you can take a look at the youtube-dl program source, it support youtube subtitle. Here is a example output of mpv (that use youtube-dl for playing youtube url)

mpv https://www.youtube.com/watch\?v\=rlJTnzyCKEA [cplayer] Run command: sub-add, flags=0, args=[https://www.youtube.com/api/timedtext?v=rlJTnzyCKEA&name=&fmt=vtt&lang=en, auto, vtt, en] [ffmpeg] Opening https://www.youtube.com/api/timedtext?v=rlJTnzyCKEA&name=&fmt=vtt&lang=en [ffmpeg] Mime-type: 'text/vtt; charset=UTF-8' [lavf] Found 'webvtt' at score=100 size=2048. [demux] Detected file format: webvtt (libavformat) [cplayer] Run command: sub-add, flags=0, args=[https://www.youtube.com/api/timedtext?v=rlJTnzyCKEA&name=&fmt=vtt&lang=fi, auto, vtt, fi] [ffmpeg] Opening https://www.youtube.com/api/timedtext?v=rlJTnzyCKEA&name=&fmt=vtt&lang=fi [ffmpeg] Mime-type: 'text/vtt; charset=UTF-8' [lavf] Found 'webvtt' at score=100 size=2048. [demux] Detected file format: webvtt (libavformat) [cplayer] Run command: sub-add, flags=0, args=[https://www.youtube.com/api/timedtext?v=rlJTnzyCKEA&name=&fmt=vtt&lang=de, auto, vtt, de] [ffmpeg] Opening https://www.youtube.com/api/timedtext?v=rlJTnzyCKEA&name=&fmt=vtt&lang=de [ffmpeg] Mime-type: 'text/vtt; charset=UTF-8' [lavf] Found 'webvtt' at score=100 size=2048. [demux] Detected file format: webvtt (libavformat) [cplayer] Subs --sid=1 --slang=en 'vtt' (webvtt) (external) [cplayer] Subs --sid=2 --slang=fi 'vtt' (webvtt) (external) [cplayer] Subs --sid=3 --slang=de 'vtt' (webvtt) (external) — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Kolifanes/plugin.video.youtube/issues/40#issuecomment-232024056, or mute the thread https://github.com/notifications/unsubscribe/ALozLUxyTB6Gr3WgPhMZJ_X5rq6_58L9ks5qU4CggaJpZM4IzgWt.

h0d3nt3uf3l commented 8 years ago

@mac1202 is this from the youtube-dl plugin of Kodi or the youtube-dl as itself? Think to implement it in Kodi its maybe not possible for us without sample-code.

mac1202 commented 8 years ago

it s from youtube-dl as itself, the youtube-dl plugin of Kodi doesn't support subtitle yet.

h0d3nt3uf3l commented 8 years ago

Then we dont have a change because we only parse the video to the kodi player.

Uukrull commented 8 years ago

The subtitles can be downloaded easily.

For example, for this video we can get the list of available subtitles with http://video.google.com/timedtext?v=MD25QKh6mGA&type=list and download the english subtitle with https://www.youtube.com/api/timedtext?v=MD25QKh6mGA&fmt=vtt&lang=en

edit: I did a quick hack and this works for english subtitles

diff --git a/resources/lib/kodion/impl/xbmc/xbmc_items.py b/resources/lib/kodion/impl/xbmc/xbmc_items.py
index d7e847f..52c8897 100755
--- a/resources/lib/kodion/impl/xbmc/xbmc_items.py
+++ b/resources/lib/kodion/impl/xbmc/xbmc_items.py
@@ -23,6 +23,10 @@ def to_video_item(context, video_item):

     item.setProperty(u'IsPlayable', u'true')

+    video_id = context.get_param('video_id')
+    url = ("https://www.youtube.com/api/timedtext?v=%s&fmt=vtt&lang=en" % (video_id))
+    item.setSubtitles([url])
+
     _info_labels = info_labels.create_from_item(context, video_item)

     # This should work for all versions of XBMC/KODI.
mac1202 commented 8 years ago

Nice maybe you could create a PR with your work so It could be integrated in the plugin.