The branch, gotham has been updated
via 51eee84847931a2e224d83e7af83e954c762dd3a (commit)
from a6104ff32e7eeab85d3f94528f6f7c626b219c54 (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=51eee84847931a2e224d83e7af83e954c762dd3a
commit 51eee84847931a2e224d83e7af83e954c762dd3a
Author: amet <[email protected]>
Date: Mon Jun 23 00:50:17 2014 +0400
[service.subtitles.podnapisi] -5.0.7
5.0.7
- cleanup, notify if login fails
diff --git a/service.subtitles.podnapisi/addon.xml
b/service.subtitles.podnapisi/addon.xml
index 0af7bbf..524424d 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.6"
+ version="5.0.7"
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 6346891..7b60b65 100644
--- a/service.subtitles.podnapisi/changelog.txt
+++ b/service.subtitles.podnapisi/changelog.txt
@@ -1,3 +1,6 @@
+5.0.7
+- cleanup, notify if login fails
+
5.0.6
- add new extract method, should take care of accented characters
diff --git a/service.subtitles.podnapisi/resources/language/English/strings.po
b/service.subtitles.podnapisi/resources/language/English/strings.po
index 6b86035..0912359 100644
--- a/service.subtitles.podnapisi/resources/language/English/strings.po
+++ b/service.subtitles.podnapisi/resources/language/English/strings.po
@@ -28,4 +28,8 @@ msgstr ""
msgctxt "#32004"
msgid "Manual search not supported"
-msgstr ""
\ No newline at end of file
+msgstr ""
+
+msgctxt "#32005"
+msgid "Authenticate [InvalidCredentials]"
+msgstr ""
diff --git a/service.subtitles.podnapisi/resources/lib/pn_utilities.py
b/service.subtitles.podnapisi/resources/lib/pn_utilities.py
index d25fa58..1619129 100644
--- a/service.subtitles.podnapisi/resources/lib/pn_utilities.py
+++ b/service.subtitles.podnapisi/resources/lib/pn_utilities.py
@@ -21,6 +21,8 @@ except ImportError:
__addon__ = sys.modules[ "__main__" ].__addon__
__scriptname__ = sys.modules[ "__main__" ].__scriptname__
__version__ = sys.modules[ "__main__" ].__version__
+__cwd__ = sys.modules[ "__main__" ].__cwd__
+__language__ = sys.modules[ "__main__" ].__language__
USER_AGENT = "%s_v%s" % (__scriptname__.replace(" ","_"),__version__ )
@@ -137,47 +139,33 @@ def hashFile(file_path, rar=False):
class OSDBServer:
def create(self):
- self.subtitles_hash_list = []
self.subtitles_list = []
- self.subtitles_name_list = []
def mergesubtitles( self, stack ):
- if( len ( self.subtitles_hash_list ) > 0 ):
- for item in self.subtitles_hash_list:
- if item["format"].find( "srt" ) == 0 or item["format"].find( "sub" )
== 0:
- self.subtitles_list.append( item )
-
- if( len ( self.subtitles_name_list ) > 0 ):
- for item in self.subtitles_name_list:
- if item["format"].find( "srt" ) == 0 or item["format"].find( "sub" )
== 0:
- self.subtitles_list.append( item )
-
if( len ( self.subtitles_list ) > 0 ):
self.subtitles_list = sorted(self.subtitles_list, compare_columns)
def searchsubtitles_pod( self, movie_hash, lang , stack):
-# movie_hash = "e1b45885346cfa0b" # Matrix Hash, Debug only
+ # movie_hash = "e1b45885346cfa0b" # Matrix Hash, Debug only
podserver = xmlrpclib.Server('http://ssp.podnapisi.net:8000')
- pod_session = ""
- hash_pod =[str(movie_hash)]
try:
init = podserver.initiate(USER_AGENT)
hash = md5()
hash.update(__addon__.getSetting( "PNpass" ))
password256 = sha256(str(hash.hexdigest()) +
str(init['nonce'])).hexdigest()
- if str(init['status']) == "200":
+ if init['status'] == 200:
pod_session = init['session']
podserver.authenticate(pod_session, __addon__.getSetting( "PNuser" ),
password256)
podserver.setFilters(pod_session, True, lang , False)
- search = podserver.search(pod_session , hash_pod)
- if str(search['status']) == "200" and len(search['results']) > 0 :
+ search = podserver.search(pod_session , [str(movie_hash)])
+
+ if search['status'] == 200 and len(search['results']) > 0 :
search_item = search["results"][movie_hash]
for item in search_item["subtitles"]:
if item["lang"]:
flag_image = item["lang"]
else:
flag_image = "-"
- link = str(item["id"])
if item['release'] == "":
episode = search_item["tvEpisode"]
if str(episode) == "0":
@@ -186,26 +174,20 @@ class OSDBServer:
name = "%s S(%s)E(%s)" %
(str(search_item["movieTitle"]),str(search_item["tvSeason"]), str(episode), )
else:
name = item['release']
- if item["inexact"]:
- sync1 = False
- else:
- sync1 = True
-
- self.subtitles_hash_list.append({'filename' : name,
- 'link' : link,
- "language_name" :
languageTranslate((item["lang"]),2,0),
- "language_flag" : flag_image,
- "language_id" : item["lang"],
- "ID" : item["id"],
- "sync" : sync1,
- "format" : "srt",
- "rating" :
str(int(item['rating'])*2),
- "hearing_imp" : "n" in
item['flags']
- })
+
+ self.subtitles_list.append({'filename' : name,
+ 'link' : str(item["id"]),
+ 'language_name' :
languageTranslate((item["lang"]),2,0),
+ 'language_flag' : flag_image,
+ 'rating' :
str(int(item['rating'])*2),
+ 'sync' : not item["inexact"],
+ 'hearing_imp' : "n" in item['flags']
+ })
+
self.mergesubtitles(stack)
- return self.subtitles_list,pod_session
+ return self.subtitles_list
except :
- return self.subtitles_list,pod_session
+ return self.subtitles_list
def searchsubtitlesbyname_pod( self, name, tvshow, season, episode, lang,
year, stack ):
if len(tvshow) > 1:
@@ -226,48 +208,20 @@ class OSDBServer:
subtitles = temp_subs
try:
if subtitles:
- url_base = "http://www.podnapisi.net/ppodnapisi/download/i/"
for subtitle in subtitles:
- subtitle_id = 0
- rating = 0
- filename = ""
- movie = ""
- lang_name = ""
- lang_id = ""
- flag_image = ""
- link = ""
- format = "srt"
- hearing_imp = False
- if subtitle.getElementsByTagName("title")[0].firstChild:
- movie = subtitle.getElementsByTagName("title")[0].firstChild.data
- if subtitle.getElementsByTagName("release")[0].firstChild:
- filename =
subtitle.getElementsByTagName("release")[0].firstChild.data
- if len(filename) < 2 :
- filename = "%s (%s).srt" % (movie,year,)
- else:
- filename = "%s (%s).srt" % (movie,year,)
- if subtitle.getElementsByTagName("rating")[0].firstChild:
- rating =
int(subtitle.getElementsByTagName("rating")[0].firstChild.data)*2
- if subtitle.getElementsByTagName("languageId")[0].firstChild:
- lang_name =
languageTranslate(subtitle.getElementsByTagName("languageId")[0].firstChild.data,
1,2)
- if subtitle.getElementsByTagName("id")[0].firstChild:
- subtitle_id =
subtitle.getElementsByTagName("id")[0].firstChild.data
- if subtitle.getElementsByTagName("flags")[0].firstChild:
- hearing_imp = "n" in
subtitle.getElementsByTagName("flags")[0].firstChild.data
- flag_image = lang_name
- link = str(subtitle_id)
- self.subtitles_name_list.append({'filename':filename,
- 'link':link,
- 'language_name' :
languageTranslate((lang_name),2,0),
- 'language_id' : lang_id,
- 'language_flag' : flag_image,
- 'movie' : movie,
- "ID" : subtitle_id,
- "rating" : str(rating),
- "format" : format,
- "sync" : False,
- "hearing_imp" : hearing_imp
- })
+ filename = self.get_element(subtitle, "release")
+
+ if filename == "":
+ filename = self.get_element(subtitle, "title")
+
+ self.subtitles_list.append({'filename' : filename,
+ 'link' :
self.get_element(subtitle, "id"),
+ 'language_name' :
languageTranslate(self.get_element(subtitle, "languageId"),1,0),
+ 'language_flag' :
languageTranslate(self.get_element(subtitle, "languageId"),1,2),
+ 'rating' :
str(int(self.get_element(subtitle, "rating"))*2),
+ 'sync' : False,
+ 'hearing_imp' : "n" in
self.get_element(subtitle, "flags")
+ })
self.mergesubtitles(stack)
return self.subtitles_list
except :
@@ -281,11 +235,17 @@ class OSDBServer:
id_pod =[]
id_pod.append(str(id))
password256 = sha256(str(hash.hexdigest()) +
str(init['nonce'])).hexdigest()
- if str(init['status']) == "200":
+ if init['status'] == 200:
pod_session = init['session']
auth = podserver.authenticate(pod_session, __addon__.getSetting(
"PNuser" ), password256)
if auth['status'] == 300:
- log( __name__ ,"Authenticate [%s]" % "InvalidCredentials")
+ log( __name__ ,__language__(32005))
+ xbmc.executebuiltin(u'Notification(%s,%s,5000,%s)' %(__scriptname__,
+
__language__(32005),
+
os.path.join(__cwd__,"icon.png")
+ )
+ )
+ return None
download = podserver.download(pod_session , id_pod)
if str(download['status']) == "200" and len(download['names']) > 0 :
download_item = download["names"][0]
@@ -293,7 +253,13 @@ class OSDBServer:
return "http://www.podnapisi.net/static/podnapisi/%s" %
download["names"][0]['filename']
return None
-
+
+ def get_element(self, element, tag):
+ if element.getElementsByTagName(tag)[0].firstChild:
+ return element.getElementsByTagName(tag)[0].firstChild.data
+ else:
+ return ""
+
def fetch(self,url):
socket = urllib.urlopen( url )
result = socket.read()
diff --git a/service.subtitles.podnapisi/service.py
b/service.subtitles.podnapisi/service.py
index 786140a..f7d14c6 100644
--- a/service.subtitles.podnapisi/service.py
+++ b/service.subtitles.podnapisi/service.py
@@ -23,8 +23,6 @@ __profile__ = xbmc.translatePath(
__addon__.getAddonInfo('profile') ).decode(
__resource__ = xbmc.translatePath( os.path.join( __cwd__, 'resources', 'lib'
) ).decode("utf-8")
__temp__ = xbmc.translatePath( os.path.join( __profile__, 'temp')
).decode("utf-8")
-
-
sys.path.append (__resource__)
from pn_utilities import OSDBServer, log, hashFile, normalizeString,
languageTranslate
@@ -53,7 +51,7 @@ def Search( item ):
log( __name__ ,"File Hash [%s]" % SubHash)
if hash_search :
log( __name__ ,"Search for [%s] by hash" % (os.path.basename(
item['file_original_path'] ),))
- subtitles_list, session_id = osdb_server.searchsubtitles_pod( SubHash
,item['3let_language'], False)
+ subtitles_list = osdb_server.searchsubtitles_pod( SubHash
,item['3let_language'], False)
if not subtitles_list:
log( __name__ ,"Search for [%s] by name" % (os.path.basename(
item['file_original_path'] ),))
subtitles_list = osdb_server.searchsubtitlesbyname_pod(item['title'],
@@ -73,13 +71,12 @@ def Search( item ):
)
listitem.setProperty( "sync", ("false", "true")[it["sync"]] )
- listitem.setProperty( "hearing_imp", ("false",
"true")[it.get("hearing_imp", False)] )
+ listitem.setProperty( "hearing_imp", ("false",
"true")[it["hearing_imp"]] )
- url = "plugin://%s/?action=download&link=%s&ID=%s&filename=%s" %
(__scriptid__,
-
it["link"],
-
it["ID"],
-
it["filename"]
- )
+ url = "plugin://%s/?action=download&link=%s&filename=%s" % (__scriptid__,
+ it["link"],
+
it["filename"]
+ )
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=listitem,isFolder=False)
@@ -91,7 +88,7 @@ def Download(url,filename):
subtitle_list = []
try:
- log( __name__ ,"Download using 'ZipFile' method")
+ log( __name__ ,"Extract using 'ZipFile' method")
response = urllib2.urlopen(url)
raw = response.read()
archive = ZipFile(StringIO(raw), 'r')
@@ -112,10 +109,9 @@ def Download(url,filename):
f.write(contents)
f.close()
subtitle_list.append(dest)
-
index += 1
except:
- log( __name__ ,"Download using 'old' method")
+ log( __name__ ,"Extract using 'XBMC.Extract' method")
exts = [".srt", ".sub", ".txt", ".smi", ".ssa", ".ass" ]
zip = os.path.join( __temp__, "PN.zip")
f = urllib.urlopen(url)
@@ -196,18 +192,17 @@ elif params['action'] == 'download':
osdb_server = OSDBServer()
url = osdb_server.download("", params["link"])
- subs = Download(url,params["filename"])
- for sub in subs:
- listitem = xbmcgui.ListItem(label=sub)
-
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=sub,listitem=listitem,isFolder=False)
+ if url:
+ subs = Download(url,params["filename"])
+ for sub in subs:
+ listitem = xbmcgui.ListItem(label=sub)
+
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=sub,listitem=listitem,isFolder=False)
-
elif params['action'] == 'manualsearch':
- xbmc.executebuiltin(u'Notification(%s,%s,2000,%s)' %
- (__scriptname__,
- __language__(32004),
- os.path.join(__cwd__,"icon.png")
- )
+ xbmc.executebuiltin(u'Notification(%s,%s,2000,%s)' %(__scriptname__,
+ __language__(32004),
+
os.path.join(__cwd__,"icon.png")
+ )
)
xbmcplugin.endOfDirectory(int(sys.argv[1]))
-----------------------------------------------------------------------
Summary of changes:
service.subtitles.podnapisi/addon.xml | 2 +-
service.subtitles.podnapisi/changelog.txt | 3 +
.../resources/language/English/strings.po | 6 +-
.../resources/lib/pn_utilities.py | 128 +++++++------------
service.subtitles.podnapisi/service.py | 39 +++----
5 files changed, 73 insertions(+), 105 deletions(-)
hooks/post-receive
--
Scripts
------------------------------------------------------------------------------
HPCC Systems Open Source Big Data Platform from LexisNexis Risk Solutions
Find What Matters Most in Your Big Data with HPCC Systems
Open Source. Fast. Scalable. Simple. Ideal for Dirty Data.
Leverages Graph Analysis for Fast Processing & Easy Data Exploration
http://p.sf.net/sfu/hpccsystems
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons