The branch, frodo has been updated
       via  fd1b6b4213871193f59f1ff5ed8a5d930da2413f (commit)
      from  f46ed72fc45340a0b1de9014bdf489ec5b7d88ea (commit)

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

commit fd1b6b4213871193f59f1ff5ed8a5d930da2413f
Author: amet <amet.nos...@gmail.com>
Date:   Tue Jul 30 13:15:52 2013 +0200

    [script.xbmc.subtitles] -v 3.9.11
    
    3.9.11
    - [fix] Subs4Free and SubtitlesGR, lambda81
    - [fix] SubtitlesGR, jded76
    - [fix] SubtitulosES, David Soms

diff --git a/script.xbmc.subtitles/addon.xml b/script.xbmc.subtitles/addon.xml
index 5c27e10..3d71a1d 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="3.9.10"
+       version="3.9.11"
        provider-name="amet, mr_blobby">
   <requires>
     <import addon="xbmc.python" version="2.1.0"/>
diff --git a/script.xbmc.subtitles/changelog.txt 
b/script.xbmc.subtitles/changelog.txt
index 6fd13c2..78668a5 100644
--- a/script.xbmc.subtitles/changelog.txt
+++ b/script.xbmc.subtitles/changelog.txt
@@ -1,3 +1,8 @@
+3.9.11
+- [fix] Subs4Free and SubtitlesGR, lambda81
+- [fix] SubtitlesGR, jded76
+- [fix] SubtitulosES, David Soms
+
 3.9.10
 - [fix] serialzone.cz typo,Ondrej Bima
 - [fix] extract other than zip archives,Ondrej Bima
diff --git a/script.xbmc.subtitles/resources/lib/services/Subs4Free/service.py 
b/script.xbmc.subtitles/resources/lib/services/Subs4Free/service.py
index 1ca90ae..e5f2a09 100644
--- a/script.xbmc.subtitles/resources/lib/services/Subs4Free/service.py
+++ b/script.xbmc.subtitles/resources/lib/services/Subs4Free/service.py
@@ -45,6 +45,7 @@ def get_rating(downloads):
     return rating
 
 def unpack_subtitles(local_tmp_file, zip_subs, tmp_sub_dir, sub_folder):
+    subs_file = ""
     files = os.listdir(tmp_sub_dir)
     init_filecount = len(files)
     max_mtime = 0
@@ -59,7 +60,7 @@ def unpack_subtitles(local_tmp_file, zip_subs, tmp_sub_dir, 
sub_folder):
     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) and 
(init_max_mtime == max_mtime): # nothing yet extracted
+    while (filecount == init_filecount) and (waittime < 10) 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)
@@ -70,7 +71,7 @@ def unpack_subtitles(local_tmp_file, zip_subs, tmp_sub_dir, 
sub_folder):
                 if (mtime > max_mtime):
                     max_mtime =  mtime
         waittime  = waittime + 1
-    if waittime == 20:
+    if waittime == 10:
         log( __name__ ," Failed to unpack subtitles in '%s'" % (tmp_sub_dir))
         pass
     else:
@@ -81,6 +82,7 @@ def unpack_subtitles(local_tmp_file, zip_subs, tmp_sub_dir, 
sub_folder):
             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 subs_file
 
 def search_subtitles(file_original_path, title, tvshow, year, season, episode, 
set_temp, rar, lang1, lang2, lang3, stack): #standard input
     subtitles_list = []
@@ -116,6 +118,7 @@ def search_subtitles(file_original_path, title, tvshow, 
year, season, episode, s
     return subtitles_list, "", msg #standard output
 
 def download_subtitles(subtitles_list, pos, zip_subs, tmp_sub_dir, sub_folder, 
session_id): #standard input
+    subs_file = ""
     id = subtitles_list[pos][ "id" ]
     language = subtitles_list[pos][ "language_name" ]
     name = subtitles_list[pos][ "filename" ]
@@ -146,19 +149,36 @@ def download_subtitles(subtitles_list, pos, zip_subs, 
tmp_sub_dir, sub_folder, s
         type = response.info()["Content-type"]
     except:
         log( __name__ ,"%s Failed to parse url:%s" % (debug_pretext, id))
-        return True,language, "" #standard output
+        return False, language, subs_file #standard output
 
     if type == 'application/x-rar-compressed':
         local_tmp_file = os.path.join(tmp_sub_dir, "subs4series.rar")
+        redirect = False
         packed = True
     elif type == 'application/zip':
         local_tmp_file = os.path.join(tmp_sub_dir, "subs4series.zip")
+        redirect = False
         packed = True
-    elif not type.startswith('text/html'): # never found/downloaded an 
unpacked subtitles file, but just to be sure ...
+    elif not type.startswith('text/html'):
         local_tmp_file = os.path.join(tmp_sub_dir, "subs4series.srt") # assume 
unpacked subtitels file is an '.srt'
         subs_file = local_tmp_file
+        redirect = False
         packed = False
     else:
+        redirect = True
+
+    if redirect is False:
+        try:
+            log( __name__ ,"%s Saving subtitles to '%s'" % (debug_pretext, 
local_tmp_file))
+            local_file_handle = open(local_tmp_file, "wb")
+            local_file_handle.write(content)
+            local_file_handle.close()
+            if packed:
+                subs_file = unpack_subtitles(local_tmp_file, zip_subs, 
tmp_sub_dir, sub_folder)
+        except:
+            log( __name__ ,"%s Failed to save subtitles to '%s'" % 
(debug_pretext, local_tmp_file))
+            pass
+    else:
         try:
             log( __name__ ,"%s Getting subtitles by subz.tv" % (debug_pretext))
             subtitles = re.compile("(<li 
style='margin-bottom.+?</li>)").findall(content.replace('\n',''))
@@ -176,19 +196,20 @@ def download_subtitles(subtitles_list, pos, zip_subs, 
tmp_sub_dir, sub_folder, s
                     if re.search(subz,name) is not None:
                         response = browser.open(id)
                         content = response.read()
-                        type = response.info()["Content-type"]
-                        if type == 'application/x-rar-compressed':
+                        try:
                             local_tmp_file = os.path.join(tmp_sub_dir, 
"subztv.rar")
-                            packed = True
-                        elif type == 'application/zip':
-                            local_tmp_file = os.path.join(tmp_sub_dir, 
"subztv.zip")
-                            packed = True
-                        elif not type.startswith('text/html'):
-                            local_tmp_file = os.path.join(tmp_sub_dir, 
"subztv.srt") # assume unpacked subtitels file is an '.srt'
-                            subs_file = local_tmp_file
-                            packed = False
-                        else:
-                            local_tmp_file = None
+                            log( __name__ ,"%s Saving subtitles to '%s'" % 
(debug_pretext, local_tmp_file))
+                            local_file_handle = open(local_tmp_file, "wb")
+                            local_file_handle.write(content)
+                            local_file_handle.close()
+                            subs_file = unpack_subtitles(local_tmp_file, 
zip_subs, tmp_sub_dir, sub_folder)
+                            if subs_file == "":
+                                local_tmp_file2 = os.path.join(tmp_sub_dir, 
"subztv.srt")
+                                os.rename(local_tmp_file, local_tmp_file2)
+                                subs_file = local_tmp_file2
+                        except:
+                            log( __name__ ,"%s Failed to save subtitles to 
'%s'" % (debug_pretext, local_tmp_file))
+                            pass
                         break
                 except:
                     pass
@@ -196,20 +217,7 @@ def download_subtitles(subtitles_list, pos, zip_subs, 
tmp_sub_dir, sub_folder, s
             log( __name__ ,"%s Failed to get subtitles by subz.tv" % 
(debug_pretext))
             pass
 
-    if local_tmp_file is not None:
-        try:
-            log( __name__ ,"%s Saving subtitles to '%s'" % (debug_pretext, 
local_tmp_file))
-            local_file_handle = open(local_tmp_file, "wb")
-            local_file_handle.write(content)
-            local_file_handle.close()
-            if packed:
-                unpack_subtitles(local_tmp_file, zip_subs, tmp_sub_dir, 
sub_folder)
-            return True,language, "" #standard output
-        except:
-            log( __name__ ,"%s Failed to save subtitles to '%s'" % 
(debug_pretext, local_tmp_file))
-            pass
-
-    return True,language, "" #standard output
+    return False, language, subs_file #standard output
 
 def get_movie_subtitles_list(searchstring, languageshort, languagelong, 
subtitles_list):
     url = '%s/search_report.php?search=%s&x=14&y=11&searchType=1' % 
(movie_url, urllib.quote_plus(searchstring))
diff --git 
a/script.xbmc.subtitles/resources/lib/services/SubtitlesGR/service.py 
b/script.xbmc.subtitles/resources/lib/services/SubtitlesGR/service.py
index 228429b..8e5787e 100644
--- a/script.xbmc.subtitles/resources/lib/services/SubtitlesGR/service.py
+++ b/script.xbmc.subtitles/resources/lib/services/SubtitlesGR/service.py
@@ -45,6 +45,7 @@ def get_rating(downloads):
     return rating
 
 def unpack_subtitles(local_tmp_file, zip_subs, tmp_sub_dir, sub_folder):
+    subs_file = ""
     files = os.listdir(tmp_sub_dir)
     init_filecount = len(files)
     max_mtime = 0
@@ -81,6 +82,7 @@ def unpack_subtitles(local_tmp_file, zip_subs, tmp_sub_dir, 
sub_folder):
             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 subs_file
 
 def search_subtitles(file_original_path, title, tvshow, year, season, episode, 
set_temp, rar, lang1, lang2, lang3, stack): #standard input
     subtitles_list = []
@@ -111,6 +113,7 @@ def search_subtitles(file_original_path, title, tvshow, 
year, season, episode, s
     return subtitles_list, "", msg #standard output
 
 def download_subtitles(subtitles_list, pos, zip_subs, tmp_sub_dir, sub_folder, 
session_id): #standard input
+    subs_file = ""
     language = subtitles_list[pos][ "language_name" ]
     name = subtitles_list[pos][ "filename" ]
     id = subtitles_list[pos][ "id" ]
@@ -161,17 +164,15 @@ def download_subtitles(subtitles_list, pos, zip_subs, 
tmp_sub_dir, sub_folder, s
             local_tmp_file = os.path.join(tmp_sub_dir, file)
             if (file.endswith('.rar') or file.endswith('.zip')):
                 shutil.copy(local_tmp_extract_file, tmp_sub_dir)
-                unpack_subtitles(local_tmp_file, zip_subs, tmp_sub_dir, 
sub_folder)
-                return True,language, "" #standard output
+                subs_file = unpack_subtitles(local_tmp_file, zip_subs, 
tmp_sub_dir, sub_folder)
             elif (file.endswith('.srt') or file.endswith('.sub')):
                 shutil.copy(local_tmp_extract_file, tmp_sub_dir)
                 subs_file = local_tmp_file
-                return True,language, "" #standard output
     except:
         log( __name__ ,"%s Failed to save subtitles to '%s'" % (debug_pretext, 
local_tmp_file))
         pass
 
-    return True,language, "" #standard output
+    return False, language, subs_file #standard output
 
 def get_subtitles_list(searchstring, languageshort, languagelong, 
subtitles_list):
     url = '%s/search.php?name=%s&sort=downloads+desc' % (main_url, 
urllib.quote_plus(searchstring))
diff --git 
a/script.xbmc.subtitles/resources/lib/services/SubtitulosES/service.py 
b/script.xbmc.subtitles/resources/lib/services/SubtitulosES/service.py
index 7c9e502..20af66e 100644
--- a/script.xbmc.subtitles/resources/lib/services/SubtitulosES/service.py
+++ b/script.xbmc.subtitles/resources/lib/services/SubtitulosES/service.py
@@ -86,7 +86,7 @@ def getallsubsforurl(url, languageshort, langlong, 
file_original_path, subtitles
                         estado = re.sub(r'\n', '', estado)
 
                         id = matches.group(6)
-                        id = id[44:61]
+                        id = id[44:62]
                         id = re.sub(r'"', '', id)
 
                         if estado == "green'>Completado" and languagelong == 
langlong:
@@ -273,4 +273,4 @@ def download_subtitles (subtitles_list, pos, zip_subs, 
tmp_sub_dir, sub_folder,
                     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
+        return False, language, subs_file #standard output

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

Summary of changes:
 script.xbmc.subtitles/addon.xml                    |    2 +-
 script.xbmc.subtitles/changelog.txt                |    5 ++
 .../resources/lib/services/Subs4Free/service.py    |   68 +++++++++++---------
 .../resources/lib/services/SubtitlesGR/service.py  |    9 ++-
 .../resources/lib/services/SubtitulosES/service.py |    4 +-
 5 files changed, 51 insertions(+), 37 deletions(-)


hooks/post-receive
-- 
Scripts

------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
Xbmc-addons mailing list
Xbmc-addons@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to