The branch, dharma has been updated
via 607b034cc4e8396018dc17bba24265c5d0b7d7b1 (commit)
from cf6f7775b9f53514d920d3fe0923abca931aa033 (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=607b034cc4e8396018dc17bba24265c5d0b7d7b1
commit 607b034cc4e8396018dc17bba24265c5d0b7d7b1
Author: amet <[email protected]>
Date: Tue Feb 8 10:33:28 2011 +0400
[script.xbmc.subtitles] -v2.3.0
- fixed: temporary folder needs xbmc.translatePath()
- removed Addic7ed service, requested by alex from Addic7ed.com
diff --git a/script.xbmc.subtitles/addon.xml b/script.xbmc.subtitles/addon.xml
index a82c031..d13aeeb 100644
--- a/script.xbmc.subtitles/addon.xml
+++ b/script.xbmc.subtitles/addon.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.xbmc.subtitles"
name="XBMC Subtitles"
- version="2.2.9"
+ version="2.3.0"
provider-name="Amet">
<requires>
<import addon="xbmc.python" version="1.0"/>
@@ -16,12 +16,12 @@
<summary lang="sr">XBMC ÐÑеводи</summary>
<summary lang="nl">XBMC Ondertitels</summary>
<summary lang="bg">XBMC СÑбÑиÑÑи</summary>
- <description lang="en">Search and download subtitles from 14
websites:OpenSubtitles.org, Podnapisi.net, Sublight.si, Bierdopje.com,
Subscene.com, Undertexter.se, Ondertitel.com, Napiprojekt.pl, Titulky.com,
Subdivx.com, Legendas.tv, Italiansubs.net, theSubDB.com, Swesub.nu and
Titlovi.com.Subtitle button on OSD needs to be activated and path set to XBMC
Subtitles under System-> Skin-> Addon Scripts</description>
- <description lang="es">Busca y descarga subtÃtulos de:OpenSubtitles.org,
Podnapisi.net, Sublight.si, Bierdopje.com, Subscene.com, Undertexter.se,
Ondertitel.com, Napiprojekt.pl, Titulky.com, Subdivx.com, Legendas.tv,
Italiansubs.net, theSubDB.com, Swesub.nu y Titlovi.com.El botón de subtitulos
en el OSD debe ser añadido, y la ruta al addon debe ponerse en Sistema->
Skin-> Addons de Scripts</description>
- <description lang="hu">Film feliratok keresése letöltése
az:OpenSubtitles.org, Podnapisi.net, Sublight.si, Bierdopje.com, Subscene.com,
Undertexter.se, Ondertitel.com, Napiprojekt.pl, Titulky.com, Subdivx.com,
Legendas.tv, Italiansubs.net, theSubDB.com, Swesub.nu és Titlovi.com
webhelyekról.A dalszöveg OSD gombot aktiválni kell az elérési út
megadásával a BeállÃtások -> Skin -> Szkriptek alatt.</description>
- <description lang="sr">ÐÑеÑÑажи и Ñкини пÑеводе Ñа
14 веб ÑÑÑаниÑа:OpenSubtitles.org, Podnapisi.net, Sublight.si,
Bierdopje.com, Subscene.com, Undertexter.se, Ondertitel.com, Napiprojekt.pl,
Titulky.com, Subdivx.com, Legendas.tv, Italiansubs.net, theSubDB.com, Swesub.nu
и Titlovi.com.ÐÑгме за пÑеводе на OSD ÑÑеба да Ñе
акÑивиÑа и изабеÑе XBMC Subtitles Ñ Ð¡Ð¸ÑÑем->
ÐаÑка-> СкÑÐ¸Ð¿Ñ Ð´Ð¾Ð´Ð°Ñи</description>
- <description lang="nl">Zoek en download ondertitels van 14
websites:OpenSubtitles.org, Podnapisi.net, Sublight.si, Bierdopje.com,
Subscene.com, Undertexter.se, Ondertitel.com, Napiprojekt.pl, Titulky.com,
Subdivx.com, Legendas.tv, Italiansubs.net, theSubDB.com, Swesub.nu en
Titlovi.com.De ondertitel knop in het OSD scherm moet zijn geactiveerd met het
pad naar XBMC Subtitles via Systeem-> Skin-> Addon Scripts.</description>
- <description lang="bg"> ТÑÑÑи и ÑвалÑй ÑÑбÑиÑÑи оÑ
14 ÑебÑайÑа: OpenSubtitles.org (ÐÑепоÑÑÑвам за Ñилми,
ÑÑÑо за ÑеÑиали), Podnapisi.net (ÐÑепоÑÑÑвам за
ÑеÑиали), Sublight.si, Bierdopje.com, Subscene.com, Undertexter.se,
Ondertitel.com, Napiprojekt.pl, Titulky.com, Subdivx.com, Legendas.tv,
Swesub.nu, theSubDB.com, Italiansubs.net and Titlovi.com. ÐÑÑонÑÑ Ð·Ð°
ÑÑбÑиÑÑи в OSD менÑÑо над Ñилма ÑÑÑбва да
бÑде акÑивиÑан и пÑÑÑ ÐºÑм пÑиложениеÑо
ÑÑÑбва да бÑде Ñказан, каÑо и за двеÑе
оÑиваÑе в менÑÑо на СиÑÑема(System)-> Ðожа(Skin)->
Ðобавка(Addon Scripts)</description> <platform>all</platform>
+ <description lang="en">Search and download subtitles from 15
websites:Bierdopje.com, Italiansubs.net, Legendas.tv, Napiprojekt.pl,
Ondertitel.com, OpenSubtitles.org, Podnapisi.net, theSubDB.com, Subdivx.com,
Sublight.si, Subscene.com, Swesub.nu, Titlovi.com, Titulky.com and
Undertexter.se.Subtitle button on OSD needs to be activated and path set to
XBMC Subtitles under System-> Skin-> Addon Scripts</description>
+ <description lang="es">Busca y descarga subtÃtulos de:Bierdopje.com,
Italiansubs.net, Legendas.tv, Napiprojekt.pl, Ondertitel.com,
OpenSubtitles.org, Podnapisi.net, theSubDB.com, Subdivx.com, Sublight.si,
Subscene.com, Swesub.nu, Titlovi.com, Titulky.com y Undertexter.se.El botón de
subtitulos en el OSD debe ser añadido, y la ruta al addon debe ponerse en
Sistema-> Skin-> Addons de Scripts</description>
+ <description lang="hu">Film feliratok keresése letöltése
az:Bierdopje.com, Italiansubs.net, Legendas.tv, Napiprojekt.pl, Ondertitel.com,
OpenSubtitles.org, Podnapisi.net, theSubDB.com, Subdivx.com, Sublight.si,
Subscene.com, Swesub.nu, Titlovi.com, Titulky.com és Undertexter.se
webhelyekról.A dalszöveg OSD gombot aktiválni kell az elérési út
megadásával a BeállÃtások -> Skin -> Szkriptek alatt.</description>
+ <description lang="sr">ÐÑеÑÑажи и Ñкини пÑеводе Ñа
15 веб ÑÑÑаниÑа:Bierdopje.com, Italiansubs.net, Legendas.tv,
Napiprojekt.pl, Ondertitel.com, OpenSubtitles.org, Podnapisi.net, theSubDB.com,
Subdivx.com, Sublight.si, Subscene.com, Swesub.nu, Titlovi.com, Titulky.com и
Undertexter.se.ÐÑгме за пÑеводе на OSD ÑÑеба да Ñе
акÑивиÑа и изабеÑе XBMC Subtitles Ñ Ð¡Ð¸ÑÑем->
ÐаÑка-> СкÑÐ¸Ð¿Ñ Ð´Ð¾Ð´Ð°Ñи</description>
+ <description lang="nl">Zoek en download ondertitels van 15
websites:Bierdopje.com, Italiansubs.net, Legendas.tv, Napiprojekt.pl,
Ondertitel.com, OpenSubtitles.org, Podnapisi.net, theSubDB.com, Subdivx.com,
Sublight.si, Subscene.com, Swesub.nu, Titlovi.com, Titulky.com en
Undertexter.se.De ondertitel knop in het OSD scherm moet zijn geactiveerd met
het pad naar XBMC Subtitles via Systeem-> Skin-> Addon Scripts.</description>
+ <description lang="bg"> ТÑÑÑи и ÑвалÑй ÑÑбÑиÑÑи оÑ
15 ÑебÑайÑа: Bierdopje.com, Italiansubs.net, Legendas.tv,
Napiprojekt.pl, Ondertitel.com, OpenSubtitles.org, Podnapisi.net, theSubDB.com,
Subdivx.com, Sublight.si, Subscene.com, Swesub.nu, Titlovi.com, Titulky.com и
Undertexter.se. ÐÑÑонÑÑ Ð·Ð° ÑÑбÑиÑÑи в OSD менÑÑо над
Ñилма ÑÑÑбва да бÑде акÑивиÑан и пÑÑÑ ÐºÑм
пÑиложениеÑо ÑÑÑбва да бÑде Ñказан, каÑо и
за двеÑе оÑиваÑе в менÑÑо на СиÑÑема(System)->
Ðожа(Skin)-> Ðобавка(Addon Scripts)</description>
<platform>all</platform>
<platform>all</platform>
</extension>
</addon>
diff --git a/script.xbmc.subtitles/changelog.txt
b/script.xbmc.subtitles/changelog.txt
index 6f72121..a5b8dca 100644
--- a/script.xbmc.subtitles/changelog.txt
+++ b/script.xbmc.subtitles/changelog.txt
@@ -1,3 +1,7 @@
+2.3.0
+- fixed: temporary folder needs xbmc.translatePath()
+- removed Addic7ed service, requested by alex from Addic7ed.com
+
2.2.9
- fixed: undertexter download
diff --git a/script.xbmc.subtitles/resources/lib/gui.py
b/script.xbmc.subtitles/resources/lib/gui.py
index 273fd84..75d7d11 100644
--- a/script.xbmc.subtitles/resources/lib/gui.py
+++ b/script.xbmc.subtitles/resources/lib/gui.py
@@ -117,7 +117,7 @@ class GUI( xbmcgui.WindowXMLDialog ):
else:
self.file_name = "%s (%s)" % (self.title.encode('utf-8'),
str(self.year),)
- self.tmp_sub_dir = os.path.join( __profile__ ,"sub_tmp" )
+ self.tmp_sub_dir = os.path.join( xbmc.translatePath(__profile__)
,"sub_tmp" )
if not self.tmp_sub_dir.endswith(':') and not
os.path.exists(self.tmp_sub_dir):
os.makedirs(self.tmp_sub_dir)
diff --git a/script.xbmc.subtitles/resources/lib/services/Itasa/service.py
b/script.xbmc.subtitles/resources/lib/services/Itasa/service.py
index 8b75941..3a04882 100644
--- a/script.xbmc.subtitles/resources/lib/services/Itasa/service.py
+++ b/script.xbmc.subtitles/resources/lib/services/Itasa/service.py
@@ -158,20 +158,34 @@ def download_subtitles (subtitles_list, pos, zip_subs,
tmp_sub_dir, sub_folder,
if packed:
files = os.listdir(tmp_sub_dir)
init_filecount = len(files)
+ max_mtime = 0
filecount = init_filecount
+ # determine the newest file from tmp_sub_dir
+ for file in files:
+ mtime = os.stat(os.path.join(tmp_sub_dir,
file)).st_mtime
+ if mtime > max_mtime:
+ max_mtime = mtime
+ init_max_mtime = max_mtime
+ time.sleep(2) # wait 2 seconds so that the unpacked files
are at least 1 second newer
xbmc.executebuiltin("XBMC.Extract(" + local_tmp_file + ","
+ tmp_sub_dir +")")
waittime = 0
- while (filecount == init_filecount) and (waittime < 20): #
nothing yet extracted
+ while (filecount == init_filecount) and (waittime < 20)
and (init_max_mtime == max_mtime): # nothing yet extracted
time.sleep(1) # wait 1 second to let the builtin
function 'XBMC.extract' unpack
files = os.listdir(tmp_sub_dir)
filecount = len(files)
+ # determine if there is a newer file created in
tmp_sub_dir (marks that the extraction had completed)
+ for file in files:
+ mtime = os.stat(os.path.join(tmp_sub_dir,
file)).st_mtime
+ if mtime > max_mtime:
+ max_mtime = mtime
waittime = waittime + 1
if waittime == 20:
log( __name__ ," Failed to unpack subtitles in '%s'" %
(tmp_sub_dir))
else:
log( __name__ ," Unpacked files in '%s'" %
(tmp_sub_dir))
for file in files:
- if string.split(file, '.')[-1] in ['srt', 'sub',
'txt']: # unpacked file is a subtitle file
+ # there could be more subtitle files in
tmp_sub_dir, so make sure we get the newly created subtitle file
+ if (string.split(file, '.')[-1] in ['srt', 'sub',
'txt']) and (os.stat(os.path.join(tmp_sub_dir, file)).st_mtime >
init_max_mtime): # unpacked file is a newly created subtitle file
log( __name__ ," Unpacked subtitles file '%s'"
% (file))
subs_file = os.path.join(tmp_sub_dir, file)
return False, language, subs_file #standard output
diff --git a/script.xbmc.subtitles/resources/lib/services/Subdivx/service.py
b/script.xbmc.subtitles/resources/lib/services/Subdivx/service.py
index d6e28f5..413a81c 100644
--- a/script.xbmc.subtitles/resources/lib/services/Subdivx/service.py
+++ b/script.xbmc.subtitles/resources/lib/services/Subdivx/service.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
# Subdivx.com subtitles, based on a mod of Undertext subtitles
import os, sys, re, xbmc, xbmcgui, string, time, urllib, urllib2
@@ -24,7 +24,7 @@ debug_pretext = "subdivx"
"""
subtitle_pattern =
"<div\sid=\"buscador_detalle_sub\">(.+?)</div><div\sid=\"buscador_detalle_sub_datos\"><b>Downloads:</b>(.+?)<b>Cds:</b>(.+?)<b>Comentarios:</b>\s.+?\s<b>Formato:</b>.+?<b>Subido\spor:</b>\s<a\sclass=\"link1\"\shref=.+?</a>\s<.+?>.*?<a\srel=\"nofollow\"\starget=\"new\"\shref=\"http://www.subdivx.com/bajar.php\?id=(.+?)&u=(.+?)\">"
-# group(1) = user comments, may content filename, group(2)= downloads used for
ratings, group(3) = #files, group(4) = id, group(5) = server
+# group(1) = user comments, may content filename, group(2)= downloads used for
ratings, group(3) = #files, group(4) = id, group(5) = server
@@ -37,7 +37,7 @@ def getallsubs(searchstring, languageshort, languagelong,
file_original_path, su
page = 1
if languageshort == "es":
url = main_url + "index.php?accion=5&masdesc=&oxdown=1&pg=" +
str(page) + "&buscar=" + urllib.quote_plus(searchstring)
-
+
content = geturl(url)
log( __name__ ,"%s Getting '%s' subs ..." % (debug_pretext, languageshort))
while re.search(subtitle_pattern, content, re.IGNORECASE | re.DOTALL |
re.MULTILINE | re.UNICODE):
@@ -63,16 +63,16 @@ def getallsubs(searchstring, languageshort, languagelong,
file_original_path, su
page = page + 1
url = main_url + "index.php?accion=5&masdesc=&oxdown=1&pg=" +
str(page) + "&buscar=" + urllib.quote_plus(searchstring)
content = geturl(url)
-
+
# Bubble sort, to put syncs on top
- for n in range(0,len(subtitles_list)):
- for i in range(1, len(subtitles_list)):
+ for n in range(0,len(subtitles_list)):
+ for i in range(1, len(subtitles_list)):
temp = subtitles_list[i]
if subtitles_list[i]["sync"] > subtitles_list[i-1]["sync"]:
subtitles_list[i] = subtitles_list[i-1]
subtitles_list[i-1] = temp
-
+
@@ -129,7 +129,7 @@ def download_subtitles (subtitles_list, pos, zip_subs,
tmp_sub_dir, sub_folder,
packed = True
elif header == 'PK':
local_tmp_file = os.path.join(tmp_sub_dir, "subdivx.zip")
- packed = True
+ packed = True
else: # never found/downloaded an unpacked subtitles file, but just to
be sure ...
local_tmp_file = os.path.join(tmp_sub_dir, "subdivx.srt") # assume
unpacked sub file is an '.srt'
subs_file = local_tmp_file
@@ -147,20 +147,34 @@ def download_subtitles (subtitles_list, pos, zip_subs,
tmp_sub_dir, sub_folder,
init_filecount = len(files)
log( __name__ ,"%s subdivx: número de init_filecount %s" %
(debug_pretext, init_filecount)) #EGO
filecount = init_filecount
+ max_mtime = 0
+ # determine the newest file from tmp_sub_dir
+ for file in files:
+ mtime = os.stat(os.path.join(tmp_sub_dir, file)).st_mtime
+ if mtime > max_mtime:
+ max_mtime = mtime
+ init_max_mtime = max_mtime
+ time.sleep(2) # wait 2 seconds so that the unpacked files are at
least 1 second newer
xbmc.executebuiltin("XBMC.Extract(" + local_tmp_file + "," +
tmp_sub_dir +")")
waittime = 0
- while (filecount == init_filecount) and (waittime < 20): # nothing
yet extracted
+ while (filecount == init_filecount) and (waittime < 20) and
(init_max_mtime == max_mtime): # nothing yet extracted
time.sleep(1) # wait 1 second to let the builtin function
'XBMC.extract' unpack
files = os.listdir(tmp_sub_dir)
filecount = len(files)
+ # determine if there is a newer file created in tmp_sub_dir
(marks that the extraction had completed)
+ for file in files:
+ mtime = os.stat(os.path.join(tmp_sub_dir, file)).st_mtime
+ if mtime > max_mtime:
+ max_mtime = mtime
waittime = waittime + 1
if waittime == 20:
log( __name__ ,"%s Failed to unpack subtitles in '%s'" %
(debug_pretext, tmp_sub_dir))
else:
- log( __name__ ,"%s Unpacked files in '%s'" % (debug_pretext,
tmp_sub_dir))
+ log( __name__ ,"%s Unpacked files in '%s'" % (debug_pretext,
tmp_sub_dir))
for file in files:
- if string.split(file, '.')[-1] in ['srt', 'sub', 'txt']: #
unpacked file is a subtitle file
- log( __name__ ,"%s Unpacked subtitles file '%s'" %
(debug_pretext, file))
+ # there could be more subtitle files in tmp_sub_dir, so
make sure we get the newly created subtitle file
+ if (string.split(file, '.')[-1] in ['srt', 'sub', 'txt'])
and (os.stat(os.path.join(tmp_sub_dir, file)).st_mtime > init_max_mtime): #
unpacked file is a newly created subtitle file
+ log( __name__ ,"%s Unpacked subtitles file '%s'" %
(debug_pretext, file))
subs_file = os.path.join(tmp_sub_dir, file)
return False, language, subs_file #standard output
-
+
diff --git a/script.xbmc.subtitles/resources/lib/services/Subscene/service.py
b/script.xbmc.subtitles/resources/lib/services/Subscene/service.py
index b7840f6..8e00d84 100644
--- a/script.xbmc.subtitles/resources/lib/services/Subscene/service.py
+++ b/script.xbmc.subtitles/resources/lib/services/Subscene/service.py
@@ -248,20 +248,34 @@ def download_subtitles (subtitles_list, pos, zip_subs,
tmp_sub_dir, sub_folder,
if packed:
files = os.listdir(tmp_sub_dir)
init_filecount = len(files)
+ max_mtime = 0
filecount = init_filecount
+ # determine the newest file from tmp_sub_dir
+ for file in files:
+ mtime = os.stat(os.path.join(tmp_sub_dir,
file)).st_mtime
+ if mtime > max_mtime:
+ max_mtime = mtime
+ init_max_mtime = max_mtime
+ time.sleep(2) # wait 2 seconds so that the
unpacked files are at least 1 second newer
xbmc.executebuiltin("XBMC.Extract(" +
local_tmp_file + "," + tmp_sub_dir +")")
waittime = 0
- while (filecount == init_filecount) and
(waittime < 20): # nothing yet extracted
+ while (filecount == init_filecount) and
(waittime < 20) and (init_max_mtime == max_mtime): # nothing yet extracted
time.sleep(1) # wait 1 second to let the
builtin function 'XBMC.extract' unpack
files = os.listdir(tmp_sub_dir)
filecount = len(files)
+ # determine if there is a newer file
created in tmp_sub_dir (marks that the extraction had completed)
+ for file in files:
+ mtime =
os.stat(os.path.join(tmp_sub_dir, file)).st_mtime
+ if mtime > max_mtime:
+ max_mtime = mtime
waittime = waittime + 1
if waittime == 20:
log( __name__ ,"%s Failed to unpack
subtitles in '%s'" % (debug_pretext, tmp_sub_dir))
else:
log( __name__ ,"%s Unpacked files in '%s'"
% (debug_pretext, tmp_sub_dir))
for file in files:
- if string.split(file, '.')[-1] in
["srt", "sub", "txt", "ssa", "smi"]: # unpacked file is a subtitle file
+ # there could be more subtitle files
in tmp_sub_dir, so make sure we get the newly created subtitle file
+ if (string.split(file, '.')[-1] in
['srt', 'sub', 'txt']) and (os.stat(os.path.join(tmp_sub_dir, file)).st_mtime >
init_max_mtime): # unpacked file is a newly created subtitle file
log( __name__ ,"%s Unpacked
subtitles file '%s'" % (debug_pretext, file))
subs_file =
os.path.join(tmp_sub_dir, file)
log( __name__ ,"%s Subtitles saved to '%s'" %
(debug_pretext, local_tmp_file))
diff --git a/script.xbmc.subtitles/resources/lib/services/Swesub/service.py
b/script.xbmc.subtitles/resources/lib/services/Swesub/service.py
index becd972..f407e13 100644
--- a/script.xbmc.subtitles/resources/lib/services/Swesub/service.py
+++ b/script.xbmc.subtitles/resources/lib/services/Swesub/service.py
@@ -97,20 +97,34 @@ def download_subtitles (subtitles_list, pos, zip_subs,
tmp_sub_dir, sub_folder,
if packed:
files = os.listdir(tmp_sub_dir)
init_filecount = len(files)
- filecount = init_filecount
+ max_mtime = 0
+ filecount = init_filecount
+ # determine the newest file from tmp_sub_dir
+ for file in files:
+ mtime = os.stat(os.path.join(tmp_sub_dir, file)).st_mtime
+ if mtime > max_mtime:
+ max_mtime = mtime
+ init_max_mtime = max_mtime
+ time.sleep(2) # wait 2 seconds so that the unpacked files are at
least 1 second newer
xbmc.executebuiltin("XBMC.Extract(" + local_tmp_file + "," +
tmp_sub_dir +")")
waittime = 0
- while (filecount == init_filecount) and (waittime < 20): # nothing
yet extracted
+ while (filecount == init_filecount) and (waittime < 20) and
(init_max_mtime == max_mtime): # nothing yet extracted
time.sleep(1) # wait 1 second to let the builtin function
'XBMC.extract' unpack
files = os.listdir(tmp_sub_dir)
filecount = len(files)
+ # determine if there is a newer file created in tmp_sub_dir
(marks that the extraction had completed)
+ for file in files:
+ mtime = os.stat(os.path.join(tmp_sub_dir, file)).st_mtime
+ if mtime > max_mtime:
+ max_mtime = mtime
waittime = waittime + 1
if waittime == 20:
log( __name__ ,"Failed to unpack subtitles in '%s'" %
(tmp_sub_dir))
else:
log( __name__ ,"Unpacked files in '%s'" % (tmp_sub_dir))
for file in files:
- if string.split(file, '.')[-1] in ['srt', 'sub', 'txt']: #
unpacked file is a subtitle file
+ # there could be more subtitle files in tmp_sub_dir, so
make sure we get the newly created subtitle file
+ if (string.split(file, '.')[-1] in ['srt', 'sub', 'txt'])
and (os.stat(os.path.join(tmp_sub_dir, file)).st_mtime > init_max_mtime): #
unpacked file is a newly created subtitle file
log( __name__ ,"Unpacked subtitles file '%s'" %
(file))
subs_file = os.path.join(tmp_sub_dir, file)
return False, language, subs_file #standard output
diff --git a/script.xbmc.subtitles/resources/lib/services/Titlovi/service.py
b/script.xbmc.subtitles/resources/lib/services/Titlovi/service.py
index 2fe369a..3250c3a 100644
--- a/script.xbmc.subtitles/resources/lib/services/Titlovi/service.py
+++ b/script.xbmc.subtitles/resources/lib/services/Titlovi/service.py
@@ -13,7 +13,7 @@ subtitles_list = []
"""
<a class="naslovFl"
href="http://titlovi.com/titlovi/house-m-d--101198/">HOUSE M D </a> <span
class="godinaFl"> (2004) 1 CD Sezona6 Epizoda20</span><br />
> 720p.WEB-DL.DD5.1.h.264-LP
-
+
</td>
"""
subtitle_pattern = "<a class=\"naslovFl\"
href=\"http://titlovi\.com/titlovi/[^\r\n\t]*?(\d{1,10})/\">([^\r\n\t]*?)</a>
<span class=\"godinaFl\"> \(([12]\d{3})\) 1 CD (.{1,20})</span><br />\
@@ -34,8 +34,8 @@ def to_titlovi_lang(language):
elif language == "Cyrillic": return "cirilica" # not a supported
search language in addon settings
elif language == "Slovenian": return "slovenski"
elif language == "BosnianLatin": return "bosanski"
- elif language == "Macedonian": return "makedonski"
- elif language == "English": return "english"
+ elif language == "Macedonian": return "makedonski"
+ elif language == "English": return "english"
else: return None
def unescape(s):
@@ -67,7 +67,7 @@ def getallsubs(content, language, search_string, season,
episode):
if season_episode == season_episode_found:
subtitles_list.append({'rating': '0', 'sync': False,
'filename': filename, 'subtitle_id': subtitle_id, 'language_flag': 'flags/' +
languageshort+ '.gif', 'language_name': language})
log( __name__ ,"%s Subtitles found: %s (id = %s)" %
(debug_pretext, filename, subtitle_id))
- else:
+ else:
if len(season_episode_found) == 0:
subtitles_list.append({'rating': '0', 'sync': False,
'filename': filename, 'subtitle_id': subtitle_id, 'language_flag': 'flags/' +
languageshort+ '.gif', 'language_name': language})
log( __name__ ,"%s Subtitles found: %s (id = %s)" %
(debug_pretext, filename, subtitle_id))
@@ -75,7 +75,7 @@ def getallsubs(content, language, search_string, season,
episode):
def getnextpage(content):
i = 0
for matches in re.finditer(pages_pattern, content, re.IGNORECASE |
re.DOTALL):
- i = i + 1
+ i = i + 1
if i == 1:
return matches.group(1)
else:
@@ -101,9 +101,9 @@ def search_subtitles( file_original_path, title, tvshow,
year, season, episode,
searchstring = title
if len(tvshow) > 0:
searchstring = tvshow
- searchstring = searchstring.replace("The", "")
+ searchstring = searchstring.replace("The", "")
log( __name__ ,"%s Search string = %s" % (debug_pretext, searchstring))
-
+
if to_titlovi_lang(lang1) is not None:
url = main_url + "prijevod=" + urllib.quote(searchstring) + "&jezik="
+ to_titlovi_lang(lang1)
content = geturl(url)
@@ -112,10 +112,10 @@ def search_subtitles( file_original_path, title, tvshow,
year, season, episode,
nextpage = getnextpage(content)
while nextpage is not None:
url = main_url + "prijevod=" + urllib.quote(searchstring) +
"&jezik=" + to_titlovi_lang(lang1) + "&stranica=" + str(nextpage)
- content = geturl(url)
+ content = geturl(url)
getallsubs(content, lang1, searchstring, str(season),
str(episode))
- nextpage = getnextpage(content)
-
+ nextpage = getnextpage(content)
+
if (lang2 != lang1):
if to_titlovi_lang(lang2) is not None:
url = main_url + "prijevod=" + urllib.quote(searchstring) +
"&jezik=" + to_titlovi_lang(lang2)
@@ -125,10 +125,10 @@ def search_subtitles( file_original_path, title, tvshow,
year, season, episode,
nextpage = getnextpage(content)
while nextpage is not None:
url = main_url + "prijevod=" + urllib.quote(searchstring)
+ "&jezik=" + to_titlovi_lang(lang2) + "&stranica=" + str(nextpage)
- content = geturl(url)
+ content = geturl(url)
getallsubs(content, lang2, searchstring, str(season),
str(episode))
- nextpage = getnextpage(content)
-
+ nextpage = getnextpage(content)
+
if ((lang3 != lang2) and (lang3 != lang1)):
if to_titlovi_lang(lang3) is not None:
url = main_url + "prijevod=" + urllib.quote(searchstring) +
"&jezik=" + to_titlovi_lang(lang3)
@@ -138,9 +138,9 @@ def search_subtitles( file_original_path, title, tvshow,
year, season, episode,
nextpage = getnextpage(content)
while nextpage is not None:
url = main_url + "prijevod=" + urllib.quote(searchstring)
+ "&jezik=" + to_titlovi_lang(lang3) + "&stranica=" + str(nextpage)
- content = geturl(url)
+ content = geturl(url)
getallsubs(content, lang3, searchstring, str(season),
str(episode))
- nextpage = getnextpage(content)
+ nextpage = getnextpage(content)
return subtitles_list, "", msg #standard output
@@ -158,7 +158,7 @@ def download_subtitles (subtitles_list, pos, zip_subs,
tmp_sub_dir, sub_folder,
packed = True
elif header == 'PK':
local_tmp_file = os.path.join(tmp_sub_dir, "titlovi.zip")
- packed = True
+ packed = True
else: # never found/downloaded an unpacked subtitles file, but just to
be sure ...
local_tmp_file = os.path.join(tmp_sub_dir, "titlovi.srt") # assume
unpacked subtitels file is an '.srt'
subs_file = local_tmp_file
@@ -173,21 +173,34 @@ def download_subtitles (subtitles_list, pos, zip_subs,
tmp_sub_dir, sub_folder,
if packed:
files = os.listdir(tmp_sub_dir)
init_filecount = len(files)
+ max_mtime = 0
filecount = init_filecount
+ # determine the newest file from tmp_sub_dir
+ for file in files:
+ mtime = os.stat(os.path.join(tmp_sub_dir, file)).st_mtime
+ if mtime > max_mtime:
+ max_mtime = mtime
+ init_max_mtime = max_mtime
+ time.sleep(2) # wait 2 seconds so that the unpacked files are at
least 1 second newer
xbmc.executebuiltin("XBMC.Extract(" + local_tmp_file + "," +
tmp_sub_dir +")")
waittime = 0
- while (filecount == init_filecount) and (waittime < 20): # nothing
yet extracted
+ while (filecount == init_filecount) and (waittime < 20) and
(init_max_mtime == max_mtime): # nothing yet extracted
time.sleep(1) # wait 1 second to let the builtin function
'XBMC.extract' unpack
files = os.listdir(tmp_sub_dir)
filecount = len(files)
+ # determine if there is a newer file created in tmp_sub_dir
(marks that the extraction had completed)
+ for file in files:
+ mtime = os.stat(os.path.join(tmp_sub_dir, file)).st_mtime
+ if mtime > max_mtime:
+ max_mtime = mtime
waittime = waittime + 1
if waittime == 20:
log( __name__ ,"%s Failed to unpack subtitles in '%s'" %
(debug_pretext, tmp_sub_dir))
else:
- log( __name__ ,"%s Unpacked files in '%s'" % (debug_pretext,
tmp_sub_dir))
+ log( __name__ ,"%s Unpacked files in '%s'" % (debug_pretext,
tmp_sub_dir))
for file in files:
- if string.split(file, '.')[-1] in ['srt', 'sub', 'txt']: #
unpacked file is a subtitle file
- log( __name__ ,"%s Unpacked subtitles file '%s'" %
(debug_pretext, file))
+ # there could be more subtitle files in tmp_sub_dir, so
make sure we get the newly created subtitle file
+ if (string.split(file, '.')[-1] in ['srt', 'sub', 'txt'])
and (os.stat(os.path.join(tmp_sub_dir, file)).st_mtime > init_max_mtime): #
unpacked file is a newly created subtitle file
+ log( __name__ ,"%s Unpacked subtitles file '%s'" %
(debug_pretext, file))
subs_file = os.path.join(tmp_sub_dir, file)
return False, language, subs_file #standard output
-
\ No newline at end of file
diff --git
a/script.xbmc.subtitles/resources/lib/services/Undertexter/service.py
b/script.xbmc.subtitles/resources/lib/services/Undertexter/service.py
index 7f49ac4..fe78859 100644
--- a/script.xbmc.subtitles/resources/lib/services/Undertexter/service.py
+++ b/script.xbmc.subtitles/resources/lib/services/Undertexter/service.py
@@ -61,7 +61,16 @@ def geturl(url):
log( __name__ ,"%s Getting url: %s" % (debug_pretext, url))
try:
response = my_urlopener.open(url)
- content = response.read()
+ content = response.read()
+ return_url = response.geturl()
+ if url != return_url:
+ log( __name__ ,"%s Getting redirected url: %s" % (debug_pretext,
return_url))
+ if (' ' in return_url):
+ log( __name__ ,"%s Redirected url contains space (workaround a
bug in python redirection: 'http://bugs.python.org/issue1153027', should be
solved, but isn't)" % (debug_pretext))
+ return_url = return_url.replace(' ','%20')
+ response = my_urlopener.open(return_url)
+ content = response.read()
+ return_url = response.geturl()
except:
log( __name__ ,"%s Failed to get url:%s" % (debug_pretext, url))
content = None
@@ -123,7 +132,7 @@ def download_subtitles (subtitles_list, pos, zip_subs,
tmp_sub_dir, sub_folder,
packed = True
elif header == 'PK':
local_tmp_file = os.path.join(tmp_sub_dir, "undertexter.zip")
- packed = True
+ packed = True
else: # never found/downloaded an unpacked subtitles file, but just to
be sure ...
local_tmp_file = os.path.join(tmp_sub_dir, "undertexter.srt") #
assume unpacked subtitels file is an '.srt'
subs_file = local_tmp_file
@@ -138,21 +147,34 @@ def download_subtitles (subtitles_list, pos, zip_subs,
tmp_sub_dir, sub_folder,
if packed:
files = os.listdir(tmp_sub_dir)
init_filecount = len(files)
+ max_mtime = 0
filecount = init_filecount
+ # determine the newest file from tmp_sub_dir
+ for file in files:
+ mtime = os.stat(os.path.join(tmp_sub_dir, file)).st_mtime
+ if mtime > max_mtime:
+ max_mtime = mtime
+ init_max_mtime = max_mtime
+ time.sleep(2) # wait 2 seconds so that the unpacked files are at
least 1 second newer
xbmc.executebuiltin("XBMC.Extract(" + local_tmp_file + "," +
tmp_sub_dir +")")
waittime = 0
- while (filecount == init_filecount) and (waittime < 20): # nothing
yet extracted
+ while (filecount == init_filecount) and (waittime < 20) and
(init_max_mtime == max_mtime): # nothing yet extracted
time.sleep(1) # wait 1 second to let the builtin function
'XBMC.extract' unpack
files = os.listdir(tmp_sub_dir)
filecount = len(files)
+ # determine if there is a newer file created in tmp_sub_dir
(marks that the extraction had completed)
+ for file in files:
+ mtime = os.stat(os.path.join(tmp_sub_dir, file)).st_mtime
+ if mtime > max_mtime:
+ max_mtime = mtime
waittime = waittime + 1
if waittime == 20:
log( __name__ ,"%s Failed to unpack subtitles in '%s'" %
(debug_pretext, tmp_sub_dir))
else:
- log( __name__ ,"%s Unpacked files in '%s'" % (debug_pretext,
tmp_sub_dir))
+ log( __name__ ,"%s Unpacked files in '%s'" % (debug_pretext,
tmp_sub_dir))
for file in files:
- if string.split(file, '.')[-1] in ['srt', 'sub', 'txt']: #
unpacked file is a subtitle file
- log( __name__ ,"%s Unpacked subtitles file '%s'" %
(debug_pretext, file))
+ # there could be more subtitle files in tmp_sub_dir, so
make sure we get the newly created subtitle file
+ if (string.split(file, '.')[-1] in ['srt', 'sub', 'txt'])
and (os.stat(os.path.join(tmp_sub_dir, file)).st_mtime > init_max_mtime): #
unpacked file is a newly created subtitle file
+ log( __name__ ,"%s Unpacked subtitles file '%s'" %
(debug_pretext, file))
subs_file = os.path.join(tmp_sub_dir, file)
return False, language, subs_file #standard output
-
\ No newline at end of file
diff --git a/script.xbmc.subtitles/resources/settings.xml
b/script.xbmc.subtitles/resources/settings.xml
index 5289ddf..353187a 100644
--- a/script.xbmc.subtitles/resources/settings.xml
+++ b/script.xbmc.subtitles/resources/settings.xml
@@ -24,7 +24,6 @@
<setting id="Titulkyuser" type="text" visible= "eq(-1,true)"
enable="eq(-1,true)" label="30128" default=""/>
<setting id="Titulkypass" type="text" option ="hidden" visible=
"eq(-2,true)" enable="eq(-2,true)" label="30129" default=""/>
<setting id="Subdivx" type="bool" label="Subdivx.com (Spanish subs
only)" default="false"/>
- <setting id="Addic7ed" type="bool" label="Addic7ed.com" default="false"/>
<setting id="Swesub" type="bool" label="Swesub.nu" default="false"/>
<setting id="Itasa" type="bool" label="Itasa (Italiansubs.net, TV Shows
and Italian only)" default="false"/>
<setting id="ITuser" type="text" visible= "eq(-1,true)"
enable="eq(-1,true)" label="30126" default=""/>
-----------------------------------------------------------------------
Summary of changes:
script.xbmc.subtitles/addon.xml | 14 +-
script.xbmc.subtitles/changelog.txt | 4 +
script.xbmc.subtitles/resources/lib/gui.py | 2 +-
.../resources/lib/services/Addic7ed/__init__.py | 1 -
.../resources/lib/services/Addic7ed/logo.png | Bin 11162 -> 0 bytes
.../resources/lib/services/Addic7ed/service.py | 123 --------------------
.../resources/lib/services/Itasa/service.py | 18 +++-
.../resources/lib/services/Subdivx/service.py | 40 +++++--
.../resources/lib/services/Subscene/service.py | 18 +++-
.../resources/lib/services/Swesub/service.py | 20 +++-
.../resources/lib/services/Titlovi/service.py | 55 ++++++----
.../resources/lib/services/Undertexter/service.py | 36 +++++-
script.xbmc.subtitles/resources/settings.xml | 1 -
13 files changed, 151 insertions(+), 181 deletions(-)
delete mode 100644
script.xbmc.subtitles/resources/lib/services/Addic7ed/__init__.py
delete mode 100644
script.xbmc.subtitles/resources/lib/services/Addic7ed/logo.png
delete mode 100644
script.xbmc.subtitles/resources/lib/services/Addic7ed/service.py
hooks/post-receive
--
Scripts
------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons