Closed frenchdj closed 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.
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)
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.
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.
@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.
it s from youtube-dl as itself, the youtube-dl plugin of Kodi doesn't support subtitle yet.
Then we dont have a change because we only parse the video to the kodi player.
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.
Nice maybe you could create a PR with your work so It could be integrated in the plugin.
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