The branch, gotham has been updated
       via  c6361fc5f24d5b220edc6054945c342ec04c550b (commit)
      from  fe20443f30c3db700137f865dad01b24e3fb2981 (commit)

- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=c6361fc5f24d5b220edc6054945c342ec04c550b

commit c6361fc5f24d5b220edc6054945c342ec04c550b
Author: taxigps <[email protected]>
Date:   Wed Apr 9 14:12:24 2014 +0800

    [service.subtitles.shooter] updated to version 1.0.2

diff --git a/service.subtitles.shooter/addon.xml 
b/service.subtitles.shooter/addon.xml
index 6023bc9..1b3992a 100644
--- a/service.subtitles.shooter/addon.xml
+++ b/service.subtitles.shooter/addon.xml
@@ -1,17 +1,20 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <addon id="service.subtitles.shooter"
        name="Shooter"
-       version="1.0.1"
+       version="1.0.2"
        provider-name="taxigps">
   <requires>
     <import addon="xbmc.python" version="2.1.0"/>
+    <import addon="script.module.chardet" version="2.1.1"/>
   </requires>
   <extension point="xbmc.subtitle.module"
              library="service.py" />
   <extension point="xbmc.addon.metadata">
     <summary lang="en">Shooter</summary>
     <summary lang="zh">射手字幕</summary>
+    <summary lang="zh_TW">射手字幕</summary>
     <description lang="en">Search and download subtitles from 
Shooter.cn</description>
     <description 
lang="zh">从射手网(Shooter.cn)下载字幕</description>
+    <description 
lang="zh_TW">從射手網(Shooter.cn)下載字幕</description>
   </extension>
 </addon>
diff --git a/service.subtitles.shooter/changelog.txt 
b/service.subtitles.shooter/changelog.txt
index fa95e4b..5ddcc22 100644
--- a/service.subtitles.shooter/changelog.txt
+++ b/service.subtitles.shooter/changelog.txt
@@ -1,3 +1,8 @@
+1.0.2
+- added setting to save subtitles as UTF-8
+- added setting for Simplified and Traditional conversion
+- changed to use zlib to decompress incomplete zipped subtitle
+
 1.0.1
 - fixed to show language flag
 
diff --git a/service.subtitles.shooter/service.py 
b/service.subtitles.shooter/service.py
index c659e8e..7ad5b75 100644
--- a/service.subtitles.shooter/service.py
+++ b/service.subtitles.shooter/service.py
@@ -10,12 +10,13 @@ import xbmcgui
 import xbmcplugin
 import shutil
 import unicodedata
+import chardet
 
 import hashlib
 from httplib import HTTPConnection, OK
 import struct
 from cStringIO import StringIO
-import gzip
+import zlib
 import random
 from urlparse import urlparse
 
@@ -32,6 +33,7 @@ __resource__   = xbmc.translatePath( os.path.join( __cwd__, 
'resources', 'lib' )
 __temp__       = xbmc.translatePath( os.path.join( __profile__, 'temp') 
).decode("utf-8")
 
 sys.path.append (__resource__)
+from langconv import *
 
 SVP_REV_NUMBER = 1543
 CLIENTKEY = "SP,aerSP,aer %d &e(\xd7\x02 %s %s"
@@ -115,6 +117,7 @@ def urlopen(url, svprev, formdata):
     h.putheader("Host", r.hostname)
     h.putheader("Accept", "*/*")
     h.putheader("Content-Length", cl)
+    h.putheader("Expect", "100-continue")
     h.putheader("Content-Type", "multipart/form-data; boundary=" + boundary)
     h.endheaders()
 
@@ -169,7 +172,10 @@ class Package(object):
         log(sys._getframe().f_code.co_name, "SubPackageCount: %d" % 
(self.SubPackageCount))
         self.SubPackages = []
         for i in range(self.SubPackageCount):
-            sub = SubPackage(s)
+            try:
+                sub = SubPackage(s)
+            except:
+                break
             self.SubPackages.append(sub)
 
 class SubPackage(object):
@@ -197,8 +203,8 @@ class SubFile(object):
         self.FileDataLength = struct.unpack("!I", c)[0]
         self.FileData = s.read(self.FileDataLength)
         if self.FileData.startswith("\x1f\x8b"):
-            gzipper = gzip.GzipFile(fileobj=StringIO(self.FileData))
-            self.FileData = gzipper.read()
+            d = zlib.decompressobj(16+zlib.MAX_WBITS)
+            self.FileData = d.decompress(self.FileData)
 
 def getSub(fpath, languagesearch, languageshort, languagelong):
     subdata = downloadSubs(fpath, languagesearch)
@@ -210,6 +216,15 @@ def getSub(fpath, languagesearch, languageshort, 
languagelong):
         for sub in package.SubPackages:
             id += 1
             for file in sub.Files:
+                if __addon__.getSetting("transUTF8") == "true" and 
(file.ExtName in ["srt", "txt", "ssa", "ass", "smi"]):
+                    enc = chardet.detect(file.FileData)['encoding']
+                    if enc:
+                        data = file.FileData.decode(enc, 'ignore')
+                        if __addon__.getSetting("transJianFan") == "1":   # 
translate to Simplified
+                            data = Converter('zh-hans').convert(data)
+                        elif __addon__.getSetting("transJianFan") == "2": # 
translate to Traditional
+                            data = Converter('zh-hant').convert(data)
+                        file.FileData = data.encode('utf-8', 'ignore')
                 local_tmp_file = os.path.join(__temp__, ".".join([barename, 
languageshort, str(id), file.ExtName]))
                 try:
                     local_file_handle = open(local_tmp_file, "wb")

-----------------------------------------------------------------------

Summary of changes:
 service.subtitles.shooter/addon.xml                |    5 +-
 service.subtitles.shooter/changelog.txt            |    5 +
 .../resources/language/Chinese (Simple)/strings.po |   24 +
 .../language/Chinese (Traditional)/strings.po      |   24 +
 .../resources/language/English/strings.po          |   24 +
 .../resources/lib}/__init__.py                     |    0
 .../resources/lib/langconv.py                      |  277 +
 service.subtitles.shooter/resources/lib/zh_wiki.py | 8286 ++++++++++++++++++++
 service.subtitles.shooter/resources/settings.xml   |    5 +
 service.subtitles.shooter/service.py               |   23 +-
 10 files changed, 8668 insertions(+), 5 deletions(-)
 create mode 100644 service.subtitles.shooter/resources/language/Chinese 
(Simple)/strings.po
 create mode 100644 service.subtitles.shooter/resources/language/Chinese 
(Traditional)/strings.po
 create mode 100644 
service.subtitles.shooter/resources/language/English/strings.po
 copy {script.cu.lrclyrics/resources/lib/culrcscrapers => 
service.subtitles.shooter/resources/lib}/__init__.py (100%)
 create mode 100644 service.subtitles.shooter/resources/lib/langconv.py
 create mode 100644 service.subtitles.shooter/resources/lib/zh_wiki.py
 create mode 100644 service.subtitles.shooter/resources/settings.xml


hooks/post-receive
-- 
Scripts

------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to