joolswills / plugin.video.iplayer

This plugin is broken.
10 stars 4 forks source link

Subtitles not working // different souce format (xml) #132

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Watch Sherlock, Subtitles not working.
Watch EastEnders, Subtitles working.

Reason: Different XML File Formats
Sherlock: 
http://www.bbc.co.uk/iplayer/subtitles/ng/modav/p01n6lw7_b03nh9m6_1388621734545.
xml
EastEnders: 
http://www.bbc.co.uk/iplayer/subtitles/ng/modav/p01n6lw7_b03nh9m6_1388621734545.
xml

Solution (Diff):
747a748,752
>     import xml.etree.ElementTree as ET
>     root = ET.fromstring(txt)
>     body = root.find("{http://www.w3.org/2006/10/ttaf1}body")
>     div = body.find("{http://www.w3.org/2006/10/ttaf1}div")
> 
753c758
<     for line in txt.split('\n'):

---
>     for line in div.findall("{http://www.w3.org/2006/10/ttaf1}p"):
755,758c760,783
<         m = p.match(line)
<         if m:
<             start_mil = "%s000" % m.group(2) # pad out to ensure 3 digits
<             end_mil   = "%s000" % m.group(4)

---
>         m = line
> 
>         if m is not None:
>             xml_begin = m.get('begin')
>             xml_begin_sec = xml_begin
>             xml_begin_mil = ""
>             
>             if '.' in xml_begin:
>                 xml_begin_sec = xml_begin.rsplit('.', 1)[0]
>                 xml_begin_mil = xml_begin.rsplit('.', 1)[1]
> 
>             xml_end = m.get('end')
>             xml_end_sec = xml_end
>             xml_end_mil = ""
>             
>             if '.' in xml_end:
>                 xml_end_sec = xml_end.rsplit('.', 1)[0]
>                 xml_end_mil = xml_end.rsplit('.', 1)[1]
> 
>             start_mil = "%s000" % xml_begin_mil # pad out to ensure 3 digits
>             end_mil   = "%s000" % xml_end_mil
>             subtitle = ""
> 
>             if m.text is not None: subtitle = m.text
760c785
<             ma = {'start'     : m.group(1),

---
>             ma = {'start'     : xml_begin_sec,
762c787
<                   'end'       : m.group(3),

---
>                   'end'       : xml_end_sec,
764c789
<                   'text'      : m.group(5)}

---
>                   'text'      : subtitle}

Original issue reported on code.google.com by m...@alexrieger.de on 5 Jan 2014 at 5:03

GoogleCodeExporter commented 9 years ago
sorry but a old style (not unified) diff posted into the main message is not 
too useful. Please do an svn checkout, edit/replace the file and provide a diff 
using "svn diff" or tortoise svn on windows and then attach it as a file 
attachment here. 

Thanks.

commandline svn  
http://ariejan.net/2007/07/03/how-to-create-and-apply-a-patch-with-subversion/

windows gui client (tortoise svn) 
http://tortoisesvn.net/docs/nightly/TortoiseSVN_en/tsvn-dug-patch.html

Original comment by exob...@gmail.com on 6 Jan 2014 at 2:48

GoogleCodeExporter commented 9 years ago
Please can you repost the subtitle examples too, as they are the same link in 
your message. Cheers.

Original comment by exob...@gmail.com on 6 Jan 2014 at 2:50

GoogleCodeExporter commented 9 years ago
The SVN Diff has to wait until tomorrow, I am on the iPad today.

As for the Subtitle Examples, here are the correct links:

Sherlock (not working): 
http://www.bbc.co.uk/iplayer/subtitles/ng/modav/p01n6lw7_b03nh9m6_1388621734545.
xml

EastEnders (working): 
http://www.bbc.co.uk/iplayer/subtitles/ng/modav/bUnknown-6608ee98-7276-4325-b7b0
-3c928d77a1f3_b03mzc0z_1388746317001.xml

My approach is to look for root->body->div, get all the p-Tags, use begin and 
end attribute and text and don't care about the rest :-)

Original comment by m...@alexrieger.de on 6 Jan 2014 at 4:21

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Sorry for the delay, been ill and busy. Here is the patch file.

Two more issues with my patch (?)

Multiline Subtitles are not showing correctly, only the first line is 
displayed. And if the stream has a glitch and skips (in my case 30 seconds 
back) the Subtitles are no longer in sync. If you stop the stream and fast 
forward to the position where the skip happend it gets even worse...

Original comment by m...@alexrieger.de on 13 Jan 2014 at 2:43

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Note - this ticket got a bit confusing due to another issue being discussed 
unrelated to the new subtitle format. My fault for not forcing it into a new 
ticket. As there was no way to split the ticket, I've removed them, so this 
ticket is back on track regarding the changed subtitle format. Apologies for 
any confusion.

Original comment by exob...@gmail.com on 13 May 2014 at 7:17