The branch, eden has been updated
via a86348f2023130fa78790caefe95561e6b50e573 (commit)
from 4e74acea65db18d3d9d034d4a83abadd7a794673 (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=a86348f2023130fa78790caefe95561e6b50e573
commit a86348f2023130fa78790caefe95561e6b50e573
Author: Martijn Kaijser <[email protected]>
Date: Mon May 21 17:58:46 2012 +0200
[plugin.video.ted.talks] update to v3.1.1
diff --git a/plugin.video.ted.talks/README.md b/plugin.video.ted.talks/README.md
index 5ba841e..ccc38b9 100644
--- a/plugin.video.ted.talks/README.md
+++ b/plugin.video.ted.talks/README.md
@@ -1,6 +1,5 @@
xbmc-plugin.video.ted.talks
---------------------------
-
This is a fork of the project started by rwparris, see
[here](http://forum.xbmc.org/showthread.php?tid=36866).
For installation instructions see
[Installing](https://github.com/moreginger/xbmc-plugin.video.ted.talks/wiki/Installing)
@@ -19,5 +18,11 @@ Subtitle language
The plugin attempts to fetch subtitles in the current XBMC language.
Alternatively a _custom language code_ (ISO639-1) can be entered in the addon
settings.
-It is also possible to enter a comma separated list of language codes (e.g.
_fr,es,en_)
-which will show subtitles in the first language which matches.
\ No newline at end of file
+
+It is also possible to enter a comma separated list of language codes (e.g.
_pt-br,pt,en_)
+which will show subtitles in the first language which matches.
+
+Bugs
+----
+Known bugs and enhancement suggestions are tracked
[here](https://github.com/moreginger/xbmc-plugin.video.ted.talks/issues).
+
diff --git a/plugin.video.ted.talks/addon.xml b/plugin.video.ted.talks/addon.xml
index a17f757..67fcc08 100644
--- a/plugin.video.ted.talks/addon.xml
+++ b/plugin.video.ted.talks/addon.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="plugin.video.ted.talks" name="TED Talks" version="3.1.0"
provider-name="rwparris2, moreginger">
+<addon id="plugin.video.ted.talks" name="TED Talks" version="3.1.1"
provider-name="rwparris2, moreginger">
<requires>
<import addon="xbmc.python" version="2.0"/>
<import addon="script.module.simplejson" version="2.0.10"/>
diff --git a/plugin.video.ted.talks/changelog.txt
b/plugin.video.ted.talks/changelog.txt
index 2fb428b..48aaee0 100644
--- a/plugin.video.ted.talks/changelog.txt
+++ b/plugin.video.ted.talks/changelog.txt
@@ -1,3 +1,6 @@
+[B]Version 3.1.1[/B]
+Support subtitles with language subcodes, such as pt-br (issue#10)
+
[B]Version 3.1.0[/B]
Subtitle support (issue#10)
Fix favorites (issue#17)
diff --git a/plugin.video.ted.talks/resources/lib/model/subtitles_scraper.py
b/plugin.video.ted.talks/resources/lib/model/subtitles_scraper.py
index 251521f..1e328c0 100644
--- a/plugin.video.ted.talks/resources/lib/model/subtitles_scraper.py
+++ b/plugin.video.ted.talks/resources/lib/model/subtitles_scraper.py
@@ -29,7 +29,7 @@ def get_languages(languages):
'''
languages Escaped languages param from flashVars
'''
- language_code_re = re.compile('"LanguageCode":"(\w+)"')
+ language_code_re = re.compile('"LanguageCode":"([a-zA-Z-]+)"')
matches = filter(None, [language_code_re.search(param) for param in
urllib.unquote(languages).split(',')])
return [m.group(1) for m in matches]
@@ -74,22 +74,11 @@ def get_subtitles_for_talk(talk_soup, accepted_languages,
logger):
logger('Could not display subtitles: %s' % (e), __friendly_message__)
return None
- if 'languages' in flashvars:
- languages = get_languages(flashvars['languages'])
- if len(languages) == 0:
- msg = 'No subtitles found'
- logger(msg, msg)
- return None
- matches = [l for l in languages if l in accepted_languages]
- if not matches:
- msg = 'No subtitles in: %s' % (",".join(accepted_languages))
- logger(msg, msg)
- return None
- else:
- # If we don't find 'languages' in flashvars, may as well take a punt
anyway.
- logger('Could not find languages in flashvars.')
- matches = accepted_languages
-
+ if 'languages' not in flashvars:
+ # Some talks really don't.
+ # See
https://github.com/moreginger/xbmc-plugin.video.ted.talks/issues/20
+ logger('No languages in flashvars.', 'No subtitles found')
+ return None
if 'ti' not in flashvars:
logger('Could not determine talk ID for subtitles.',
__friendly_message__)
return None
@@ -97,5 +86,16 @@ def get_subtitles_for_talk(talk_soup, accepted_languages,
logger):
logger('Could not determine intro duration for subtitles.',
__friendly_message__)
return None
+ languages = get_languages(flashvars['languages'])
+ if len(languages) == 0:
+ msg = 'No subtitles found'
+ logger(msg, msg)
+ return None
+ matches = [l for l in languages if l in accepted_languages]
+ if not matches:
+ msg = 'No subtitles in: %s' % (",".join(accepted_languages))
+ logger(msg, msg)
+ return None
+
raw_subtitles = get_subtitles(flashvars['ti'], matches[0])
return format_subtitles(raw_subtitles, int(flashvars['introDuration']))
diff --git
a/plugin.video.ted.talks/resources/lib/model/subtitles_scraper_test.py
b/plugin.video.ted.talks/resources/lib/model/subtitles_scraper_test.py
index eed0998..a3bdda6 100644
--- a/plugin.video.ted.talks/resources/lib/model/subtitles_scraper_test.py
+++ b/plugin.video.ted.talks/resources/lib/model/subtitles_scraper_test.py
@@ -4,15 +4,10 @@ import urllib
import tempfile
from BeautifulSoup import MinimalSoup
-def get_talk_1253():
- '''
- Return soup for an arbitrary fixed talk.
- '''
- return
MinimalSoup(urllib.urlopen('http://www.ted.com/talks/richard_wilkinson.html').read())
class TestSubtitlesScraper(unittest.TestCase):
- __sample_languages__ =
'%5B%7B%22LanguageCode%22%3A%22sq%22%2C%22OldLanguageCode%22%3A%22alb%22%2C%22Name%22%3A%22Albanian%22%2C%22Description%22%3Anull%2C%22CommunityUrl%22%3Anull%2C%22TranslationCount%22%3A288%2C%22DotsubOnly%22%3Afalse%2C%22CreatedAt%22%3A%222009-05-12+22%3A17%3A26%22%2C%22UpdatedAt%22%3A%222012-03-26+18%3A27%3A09%22%7D%2C%7B%22LanguageCode%22%3A%22ar%22%2C%22OldLanguageCode%22%3A%22ara%22%2C%22Name%22%3A%22Arabic%22%2C%22Description%22%3Anull%2C%22CommunityUrl%22%3Anull%2C%22TranslationCount%22%3A1086%2C%22DotsubOnly%22%3Afalse%2C%22CreatedAt%22%3A%222009-05-12+22%3A17%3A26%22%2C%22UpdatedAt%22%3A%222012-03-26+18%3A26%3A46%22%7D%2C%'
+ __sample_languages__ =
'%5B%7B%22LanguageCode%22%3A%22sq%22%2C%22OldLanguageCode%22%3A%22alb%22%2C%22Name%22%3A%22Albanian%22%2C%22Description%22%3Anull%2C%22CommunityUrl%22%3Anull%2C%22TranslationCount%22%3A288%2C%22DotsubOnly%22%3Afalse%2C%22CreatedAt%22%3A%222009-05-12+22%3A17%3A26%22%2C%22UpdatedAt%22%3A%222012-03-26+18%3A27%3A09%22%7D%2C%7B%22LanguageCode%22%3A%22ar%22%2C%22OldLanguageCode%22%3A%22ara%22%2C%22Name%22%3A%22Arabic%22%2C%22Description%22%3Anull%2C%22CommunityUrl%22%3Anull%2C%22TranslationCount%22%3A1086%2C%22DotsubOnly%22%3Afalse%2C%22CreatedAt%22%3A%222009-05-12+22%3A17%3A26%22%2C%22UpdatedAt%22%3A%222012-03-26+18%3A26%3A46%22%7D%2C%2C%7B%22LanguageCode%22%3A%22pt-br%22%2C%22OldLanguageCode%22%3A%22por_br%22%2C%22Name%22%3A%22Portuguese%2C+Brazilian%22%2C%22Description%22%3Anull%2C%22CommunityUrl%22%3Anull%2C%22TranslationCount%22%3A1112%2C%22DotsubOnly%22%3Afalse%2C%22CreatedAt%22%3A%222009-05-12+22%3A17%3A27%22%2C%22UpdatedAt%22%3A%222012-05-16+17%3A00%3A07%22%7D%'
def test_format_time(self):
self.assertEqual('00:00:00,000', subtitles_scraper.format_time(0))
@@ -32,16 +27,7 @@ World
''', formatted_subs)
def test_get_languages(self):
- self.assertEquals(['sq', 'ar'],
subtitles_scraper.get_languages(self.__sample_languages__))
-
- def test_get_flashvars(self):
- soup = get_talk_1253()
- # This should be the language list once we get back the point of
parsing the languages param
- # expected = ['sq', 'ar', 'hy', 'bg', 'ca', 'zh-cn', 'zh-tw', 'hr',
'cs', 'da', 'nl', 'en', 'fr', 'ka', 'de', 'el', 'he', 'hu', 'id', 'it', 'ja',
'ko', 'fa', 'pl', 'pt-br', 'pt', 'ro', 'ru', 'sr', 'sk', 'es', 'th', 'tr',
'uk', 'vi']
- flashvars = subtitles_scraper.get_flashvars(soup)
- self.assertTrue('languages' in flashvars) # subtitle languages
- self.assertTrue('15330', flashvars['introDuration']) # TED intro, need
to offset subtitles with this
- self.assertEquals('1253', flashvars['ti']) # talk ID
+ self.assertEquals(['sq', 'ar', 'pt-br'],
subtitles_scraper.get_languages(self.__sample_languages__))
def test_get_flashvars_not_there(self):
soup = MinimalSoup('<html><head/><body><script>Not much
here</script></body></html>')
@@ -71,33 +57,15 @@ World
subs_file.close()
self.assertEqual([{'duration': 3000, 'start': 0, 'content': 'What'},
{'duration': 4000, 'start': 3000, 'content': 'Began'}], subs)
- def test_get_subtitles_for_talk_live(self):
- '''
- This one is the real deal.
- '''
- soup = get_talk_1253()
- subs = subtitles_scraper.get_subtitles_for_talk(soup, ['banana',
'fr'], None)
- self.assertTrue(subs.startswith('''1
-00:00:15,330 --> 00:00:18,330
-Vous savez tous que ce que je vais dire est vrai.
-
-2'''))
-
- def test_get_subtitles_for_talk_no_subs(self):
+ def test_get_subtitles_for_talk_no_languages(self):
def logger(gnarly, pretty):
+ self.gnarly = gnarly
self.pretty = pretty
- soup = MinimalSoup('<script>flashVars = { languages:"%5B%5D" }
</script>')
+ soup = MinimalSoup('<script>flashVars = { } </script>')
self.assertIsNone(subtitles_scraper.get_subtitles_for_talk(soup,
['fr'], logger))
self.assertEqual('No subtitles found', self.pretty)
-
- def test_get_subtitles_for_talk_no_language_match(self):
- def logger(gnarly, pretty):
- self.pretty = pretty
-
- soup = MinimalSoup('<script>flashVars = { languages:"%s" } </script>'
% (self.__sample_languages__))
- self.assertIsNone(subtitles_scraper.get_subtitles_for_talk(soup,
['fr', 'de'], logger))
- self.assertEqual('No subtitles in: fr,de', self.pretty)
+ self.assertEqual('No languages in flashvars.', self.gnarly)
def test_get_subtitles_for_talk_no_talk_id(self):
def logger(gnarly, pretty):
@@ -119,17 +87,29 @@ Vous savez tous que ce que je vais dire est vrai.
self.assertEqual('Error showing subtitles', self.pretty)
self.assertEqual('Could not determine intro duration for subtitles.',
self.gnarly)
- def test_get_subtitles_for_talk_no_languages(self):
- gnarlys = []
- prettys = []
- # Note that it logs and proceeds past the language checks before
failing at the next step.
- def logger(gnarly, pretty=None):
- gnarlys.append(gnarly)
- prettys.append(pretty)
+ def test_get_subtitles_for_talk_no_language_match(self):
+ def logger(gnarly, pretty):
+ self.pretty = pretty
+ self.gnarly = gnarly
- soup = MinimalSoup('<script>flashVars = { } </script>')
- self.assertIsNone(subtitles_scraper.get_subtitles_for_talk(soup,
['fr'], logger))
- self.assertEqual('Could not find languages in flashvars.', gnarlys[0])
- self.assertIsNone(prettys[0]) # No notification message.
- # Second message is logged
- self.assertEqual('Error showing subtitles', prettys[1])
+ soup = MinimalSoup('<script>flashVars = {
languages:"%s",\nti:1234,\nintroDuration:5678 } </script>' %
(self.__sample_languages__))
+ self.assertIsNone(subtitles_scraper.get_subtitles_for_talk(soup,
['fr', 'de'], logger))
+ self.assertEqual('No subtitles in: fr,de', self.pretty)
+ self.assertEqual('No subtitles in: fr,de', self.gnarly)
+
+ def test_real_talk(self):
+ soup =
MinimalSoup(urllib.urlopen('http://www.ted.com/talks/richard_wilkinson.html').read())
+ flashvars = subtitles_scraper.get_flashvars(soup)
+ self.assertTrue('languages' in flashvars) # subtitle languages
+ self.assertTrue('15330', flashvars['introDuration']) # TED intro, need
to offset subtitles with this
+ self.assertEquals('1253', flashvars['ti']) # talk ID
+
+ expected = set(['sq', 'ar', 'hy', 'bg', 'ca', 'zh-cn', 'zh-tw', 'hr',
'cs', 'da', 'nl', 'en', 'fr', 'ka', 'de', 'el', 'he', 'hu', 'id', 'it', 'ja',
'ko', 'fa', 'pl', 'pt', 'pt-br', 'ro', 'ru', 'sr', 'sk', 'es', 'th', 'tr',
'uk', 'vi'])
+ self.assertEquals(expected,
set(subtitles_scraper.get_languages(flashvars['languages'])))
+
+ subs = subtitles_scraper.get_subtitles_for_talk(soup, ['banana',
'fr'], None)
+ self.assertTrue(subs.startswith('''1
+00:00:15,330 --> 00:00:18,330
+Vous savez tous que ce que je vais dire est vrai.
+
+2'''))
-----------------------------------------------------------------------
Summary of changes:
plugin.video.ted.talks/README.md | 11 ++-
plugin.video.ted.talks/addon.xml | 2 +-
plugin.video.ted.talks/changelog.txt | 3 +
.../resources/lib/model/subtitles_scraper.py | 34 ++++----
.../resources/lib/model/subtitles_scraper_test.py | 82 ++++++++------------
5 files changed, 60 insertions(+), 72 deletions(-)
hooks/post-receive
--
Plugins
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons