The branch, gotham has been updated
via 4f96ee9ff3d596c06dcd6137e6427d09191add18 (commit)
from b9088fe5864faa2668319e85e7dfedc74683dcc9 (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=4f96ee9ff3d596c06dcd6137e6427d09191add18
commit 4f96ee9ff3d596c06dcd6137e6427d09191add18
Author: amet <[email protected]>
Date: Wed Apr 16 23:17:06 2014 +0400
[service.subtitles.podnapisi] -v 5.0.6
5.0.6
- add new extract method, should take care of accented characters
diff --git a/service.subtitles.podnapisi/addon.xml
b/service.subtitles.podnapisi/addon.xml
index e0f725a..0af7bbf 100755
--- a/service.subtitles.podnapisi/addon.xml
+++ b/service.subtitles.podnapisi/addon.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.subtitles.podnapisi"
name="Podnapisi.net"
- version="5.0.5"
+ version="5.0.6"
provider-name="amet">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
diff --git a/service.subtitles.podnapisi/changelog.txt
b/service.subtitles.podnapisi/changelog.txt
index 994b15f..6346891 100644
--- a/service.subtitles.podnapisi/changelog.txt
+++ b/service.subtitles.podnapisi/changelog.txt
@@ -1,3 +1,6 @@
+5.0.6
+- add new extract method, should take care of accented characters
+
5.0.5
- cosmetics
- Fix unzip issues with non-ascii in ziplib library
diff --git a/service.subtitles.podnapisi/service.py
b/service.subtitles.podnapisi/service.py
index 7074eff..786140a 100644
--- a/service.subtitles.podnapisi/service.py
+++ b/service.subtitles.podnapisi/service.py
@@ -3,10 +3,13 @@
import os
import sys
import xbmc
-import urllib
+import urllib,urllib2
import xbmcvfs
import xbmcaddon
import xbmcgui,xbmcplugin,shutil
+from zipfile import ZipFile
+from cStringIO import StringIO
+import uuid
__addon__ = xbmcaddon.Addon()
__author__ = __addon__.getAddonInfo('author')
@@ -86,22 +89,46 @@ def Download(url,filename):
shutil.rmtree(__temp__)
xbmcvfs.mkdirs(__temp__)
subtitle_list = []
- exts = [".srt", ".sub", ".txt", ".smi", ".ssa", ".ass" ]
- zip = os.path.join( __temp__, "PN.zip")
- f = urllib.urlopen(url)
- with open(zip, "wb") as subFile:
- subFile.write(f.read())
- subFile.close()
- xbmc.sleep(500)
-# zipf = zipfile.ZipFile(zip, mode='r')
-# for subfile in zipf.namelist():
-# zipf.extract(subfile, __temp__)
- xbmc.executebuiltin(('XBMC.Extract("%s","%s")' %
(zip,__temp__,)).encode('utf-8'), True)
- for subfile in xbmcvfs.listdir(zip)[1]:
- file = os.path.join(__temp__, subfile.decode('utf-8'))
- if (os.path.splitext( file )[1] in exts):
- subtitle_list.append(file)
+
+ try:
+ log( __name__ ,"Download using 'ZipFile' method")
+ response = urllib2.urlopen(url)
+ raw = response.read()
+ archive = ZipFile(StringIO(raw), 'r')
+ files = archive.namelist()
+ files.sort()
+ index = 1
+ for file in files:
+ contents = archive.read(file)
+ extension = file[file.rfind('.') + 1:]
+
+ if len(files) == 1:
+ dest = os.path.join(__temp__, "%s.%s" %(str(uuid.uuid4()), extension))
+ else:
+ dest = os.path.join(__temp__, "%s.%d.%s" %(str(uuid.uuid4()), index,
extension))
+
+ f = open(dest, 'wb')
+ f.write(contents)
+ f.close()
+ subtitle_list.append(dest)
+
+ index += 1
+ except:
+ log( __name__ ,"Download using 'old' method")
+ exts = [".srt", ".sub", ".txt", ".smi", ".ssa", ".ass" ]
+ zip = os.path.join( __temp__, "PN.zip")
+ f = urllib.urlopen(url)
+ with open(zip, "wb") as subFile:
+ subFile.write(f.read())
+ subFile.close()
+ xbmc.sleep(500)
+ xbmc.executebuiltin(('XBMC.Extract("%s","%s")' %
(zip,__temp__,)).encode('utf-8'), True)
+ for subfile in xbmcvfs.listdir(zip)[1]:
+ file = os.path.join(__temp__, subfile.decode('utf-8'))
+ if (os.path.splitext( file )[1] in exts):
+ subtitle_list.append(file)
+
return subtitle_list
-----------------------------------------------------------------------
Summary of changes:
service.subtitles.podnapisi/addon.xml | 2 +-
service.subtitles.podnapisi/changelog.txt | 3 +
service.subtitles.podnapisi/service.py | 59 +++++++++++++++++++++--------
3 files changed, 47 insertions(+), 17 deletions(-)
hooks/post-receive
--
Scripts
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons