The branch, gotham has been updated
via e423dccc8b8e63a77b80fa7a9702ec888fb01b26 (commit)
from c18450ea1080b8ca12c66f3c61feab20efc941e3 (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=e423dccc8b8e63a77b80fa7a9702ec888fb01b26
commit e423dccc8b8e63a77b80fa7a9702ec888fb01b26
Author: taxigps <[email protected]>
Date: Sun Jul 13 11:44:27 2014 +0800
[service.subtitles.shooter] update to version 1.0.4
diff --git a/service.subtitles.shooter/addon.xml
b/service.subtitles.shooter/addon.xml
index ee92cdc..9dc3a53 100644
--- a/service.subtitles.shooter/addon.xml
+++ b/service.subtitles.shooter/addon.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.subtitles.shooter"
name="Shooter"
- version="1.0.3"
+ version="1.0.4"
provider-name="taxigps">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
@@ -17,5 +17,11 @@
<description lang="en">Search and download subtitles from
Shooter.cn</description>
<description
lang="zh">ä»å°æç½ï¼Shooter.cnï¼ä¸è½½åå¹</description>
<description
lang="zh_TW">å¾å°æç¶²ï¼Shooter.cnï¼ä¸è¼åå¹</description>
+ <platform>all</platform>
+ <license>GNU GENERAL PUBLIC LICENSE. Version 2, June 1991</license>
+ <forum>http://forum.xbmc.org/showthread.php?tid=199644</forum>
+ <website></website>
+ <email></email>
+ <source>https://github.com/taxigps/service.subtitles.shooter</source>
</extension>
</addon>
diff --git a/service.subtitles.shooter/changelog.txt
b/service.subtitles.shooter/changelog.txt
index 0c6f9a1..be793ca 100644
--- a/service.subtitles.shooter/changelog.txt
+++ b/service.subtitles.shooter/changelog.txt
@@ -1,3 +1,6 @@
+1.0.4
+- reduce unneeded coding convertion to download faster
+
1.0.3
- added search subtitles by title
diff --git a/service.subtitles.shooter/service.py
b/service.subtitles.shooter/service.py
index 8a38775..ac8a185 100644
--- a/service.subtitles.shooter/service.py
+++ b/service.subtitles.shooter/service.py
@@ -216,15 +216,6 @@ def getSubByHash(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")
@@ -232,7 +223,7 @@ def getSubByHash(fpath, languagesearch, languageshort,
languagelong):
local_file_handle.close()
except:
log(sys._getframe().f_code.co_name, "Failed to save
subtitles to '%s'" % (local_tmp_file))
- if (file.ExtName in ["srt", "txt", "ssa", "ass", "smi",
"sub"]):
+ if (file.ExtName in ["srt", "ssa", "ass", "smi", "sub"]):
showname = ".".join([barename, file.ExtName])
listitem = xbmcgui.ListItem(label=languagelong,
label2=showname,
@@ -287,7 +278,6 @@ def CalcFileHash(a):
def getSubByTitle(title, langs):
subtitles_list = []
url = 'http://www.shooter.cn/search/%s/' % title
- print url
socket = urllib.urlopen( url )
data = socket.read()
socket.close()
@@ -335,6 +325,7 @@ def rmtree(path):
def Search(item):
if xbmcvfs.exists(__temp__):
rmtree(__temp__)
+ xbmc.sleep(50)
xbmcvfs.mkdirs(__temp__)
if item['mansearch']:
@@ -347,14 +338,41 @@ def Search(item):
getSubByHash(item['file_original_path'], "eng", "en", "English")
getSubByTitle(title, item['3let_language'])
+def ChangeFileEndcoding(filepath):
+ if __addon__.getSetting("transUTF8") == "true" and
os.path.splitext(filepath)[1] in [".srt", ".ssa", ".ass", ".smi"]:
+ data = open(filepath, 'rb').read()
+ enc = chardet.detect(data)['encoding']
+ if enc:
+ data = data.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)
+ data = data.encode('utf-8', 'ignore')
+ try:
+ local_file_handle = open(filepath, "wb")
+ local_file_handle.write(data)
+ local_file_handle.close()
+ except:
+ log(sys._getframe().f_code.co_name, "Failed to save subtitles to
'%s'" % (filename))
+
def Download(filename):
subtitle_list = []
+ ChangeFileEndcoding(filename.decode('utf-8'))
subtitle_list.append(filename)
return subtitle_list
+def CheckSubList(files):
+ list = []
+ for subfile in files:
+ if os.path.splitext(subfile)[1] in [".srt", ".ssa", ".ass", ".smi",
".sub"]:
+ list.append(subfile)
+ return list
+
def DownloadID(id):
if xbmcvfs.exists(__temp__):
rmtree(__temp__)
+ xbmc.sleep(50)
xbmcvfs.mkdirs(__temp__)
subtitle_list = []
@@ -380,14 +398,15 @@ def DownloadID(id):
xbmc.executebuiltin(('XBMC.Extract("%s","%s")' %
(zip,__temp__,)).encode('utf-8'), True)
path = __temp__
dirs, files = xbmcvfs.listdir(path)
- if len(dirs) > 0:
+ list = CheckSubList(files)
+ if not list and len(dirs) > 0:
path = os.path.join(__temp__, dirs[0].decode('utf-8'))
dirs, files = xbmcvfs.listdir(path)
- list = []
- for subfile in files:
- if os.path.splitext(subfile)[1] in [".srt", ".txt", ".ssa", ".ass",
".smi", ".sub"]:
- list.append(subfile)
- filename = list[0].decode('utf-8')
+ list = CheckSubList(files)
+ if list:
+ filename = list[0].decode('utf-8')
+ else:
+ filename = ''
if len(list) > 1:
dialog = xbmcgui.Dialog()
sel = dialog.select(__language__(32006), list)
@@ -395,23 +414,8 @@ def DownloadID(id):
filename = list[sel].decode('utf-8')
if filename:
filepath = os.path.join(path, filename)
+ ChangeFileEndcoding(filepath)
subtitle_list.append(filepath)
- if __addon__.getSetting("transUTF8") == "true" and
not(os.path.splitext(filename)[1] == '.sub'):
- data = open(filepath, 'rb').read()
- enc = chardet.detect(data)['encoding']
- if enc:
- data = data.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)
- data = data.encode('utf-8', 'ignore')
- try:
- local_file_handle = open(filepath, "wb")
- local_file_handle.write(data)
- local_file_handle.close()
- except:
- log(sys._getframe().f_code.co_name, "Failed to save subtitles
to '%s'" % (filename))
return subtitle_list
-----------------------------------------------------------------------
Summary of changes:
service.subtitles.shooter/addon.xml | 8 +++-
service.subtitles.shooter/changelog.txt | 3 +
service.subtitles.shooter/service.py | 70 ++++++++++++++++--------------
3 files changed, 47 insertions(+), 34 deletions(-)
hooks/post-receive
--
Scripts
------------------------------------------------------------------------------
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons