The branch, dharma-pre has been updated
       via  5ea546066e7c56f276a07b184312c828a51f7abf (commit)
      from  4bc39439b7582faa9a54675baecfd3de99bcaff8 (commit)

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

commit 5ea546066e7c56f276a07b184312c828a51f7abf
Author: amet <a...@nospam>
Date:   Sat Nov 20 11:19:29 2010 +0400

    [script.xbmc.subtitles]
    2.1.5
    - added: Bulgarian translation, Thanks to Radoslav Vasilev
    2.1.4
    - updated: LegendasTV and Brazilian string
    - fixed: if movie is in rar it wouldnt honour custom subtitle path

diff --git a/script.xbmc.subtitles/addon.xml b/script.xbmc.subtitles/addon.xml
index f633165..c658c7c 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.1.3"
+       version="2.1.5"
        provider-name="Amet">
   <requires>
     <import addon="xbmc.python" version="1.0"/>
@@ -14,12 +14,14 @@
     <summary lang="es">Subtítulos XBMC</summary> 
     <summary lang="hu">XBMC feliratok</summary> 
     <summary lang="sr">XBMC Преводи</summary>
-    <summary lang="nl">XBMC Ondertitels</summary>     
+    <summary lang="nl">XBMC Ondertitels</summary>
+    <summary lang="bg">XBMC Субтитри</summary>    
     <description lang="en">Search and download subtitles from 12 
websites:OpenSubtitles.org, Podnapisi.net, Sublight.si, Bierdopje.com, 
Subscene.com, Undertexter.se, Ondertitel.com, Napiprojekt.pl, Titulky.com, 
Subdivx.com, Legendas.tv 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 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 é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">Претражи и скини преводе са 
12 веб страница:OpenSubtitles.org, Podnapisi.net, Sublight.si, 
Bierdopje.com, Subscene.com, Undertexter.se, Ondertitel.com, Napiprojekt.pl, 
Titulky.com, Subdivx.com, Legendas.tv и Titlovi.com.Дугме за 
преводе на OSD треба да се активира и изабере 
XBMC Subtitles у Систем-> Маска-> Скрипт 
додаци</description>
     <description lang="nl">Zoek en download ondertitels van 12 
websites:OpenSubtitles.org, Podnapisi.net, Sublight.si, Bierdopje.com, 
Subscene.com, Undertexter.se, Ondertitel.com, Napiprojekt.pl, Titulky.com, 
Subdivx.com, Legendas.tv 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"> Търси и сваляй субтитри от 
12 уебсайта: OpenSubtitles.org (Препоръчвам за филми, 
също за сериали), Podnapisi.net (Препоръчвам за 
сериали), Sublight.si, Bierdopje.com, Subscene.com, Undertexter.se, 
Ondertitel.com, Napiprojekt.pl, Titulky.com, Subdivx.com, Legendas.tv and 
Titlovi.com. Бутонът за субтитри в 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 d24244a..072a3a8 100644
--- a/script.xbmc.subtitles/changelog.txt
+++ b/script.xbmc.subtitles/changelog.txt
@@ -1,3 +1,10 @@
+2.1.5
+- added: Bulgarian translation, Thanks to Radoslav Vasilev
+
+2.1.4
+- updated: LegendasTV and Brazilian string
+- fixed: if movie is in rar it wouldnt honour custom subtitle path
+
 2.1.3
 - fixed: smb hashing *should* work now :)
 
diff --git a/script.xbmc.subtitles/resources/language/Croatian/strings.xml 
b/script.xbmc.subtitles/resources/language/Croatian/strings.xml
index b2feb2a..61f8a0d 100644
--- a/script.xbmc.subtitles/resources/language/Croatian/strings.xml
+++ b/script.xbmc.subtitles/resources/language/Croatian/strings.xml
@@ -13,7 +13,7 @@
     <string id="655">Titl dostupan lokalno</string>
     <string id="656">Servis nije odgovorio u zadanom vremenskom 
periodu</string>
     <string id="657">Nije pronađen niti jedan titl!</string>
-    <string id="744">pronađeni su titlovi za</string>
+    <string id="744">titlova za</string>
     <string id="747">Pretraži koristeći ime datoteke</string>
     <string id="748">Ne možete spremiti titl na odabranu lokaciju</string>
     <string id="750">Želite li privremeno omogućiti titl?</string>
diff --git a/script.xbmc.subtitles/resources/language/Portuguese 
(Brazil)/strings.xml b/script.xbmc.subtitles/resources/language/Portuguese 
(Brazil)/strings.xml
index 22a4eab..c69954a 100644
--- a/script.xbmc.subtitles/resources/language/Portuguese (Brazil)/strings.xml  
+++ b/script.xbmc.subtitles/resources/language/Portuguese (Brazil)/strings.xml  
@@ -10,10 +10,10 @@
     <string id="649">Baixando legendas...</string>
     <string id="652">Legenda baixada e extraída</string>
     <string id="653">Falha na Conexão.</string>
-    <string id="654">Erro extraíndo legenda</string>
-    <string id="655">Local subtitle available</string>
-    <string id="656">Service did not respond within the time out limit</string>
-    <string id="657">No Subtitles Found!</string>
+    <string id="654">Erro extraindo legenda</string>
+    <string id="655">Legenda local disponível</string>
+    <string id="656">O serviço não respondeu no tempo disponível</string>
+    <string id="657">Nenhuma Legenda Encontrada!</string>
     <string id="744">legendas encontradas para</string>
     <string id="745">O serviço Podnapisi requer usuário e senha</string>
     <string id="746">Por favor registre em www.podnapisi.net</string>
@@ -24,19 +24,19 @@
     <string id="751">Digite o Nome do Filme (ano)</string>
     <string id="755">O servidor está sobrecarregado, por favor tente mais 
tarde</string>
     <string id="756">O login falhou. Verifique seus dados nas Configurações 
do addon</string>
-    <string id="760">Available Services</string> 
+    <string id="760">Serviços Disponíveis</string> 
     
   <!-- Script Settings -->
    
-    <string id="30100">Seleconar Idioma</string>
+    <string id="30100">Selecionar Idioma</string>
     <string id="30101">Idioma Principal</string>
     <string id="30102">Idioma Secundário</string>
     <string id="30103">Seleção de Serviços</string>
     <string id="30104">- Podnapisi.net Nome Do Usuário</string>
     <string id="30105">- Podnapisi.net Senha</string>
-    <string id="30106">Advanced Options</string>
-    <string id="30107">Subtitle Download Folder Same As Movie</string>
-    <string id="30108">- Set Custom Subtitle Download Path</string>
+    <string id="30106">Opções Avançadas</string>
+    <string id="30107">Gravar Legenda na Pasta do Vídeo</string>
+    <string id="30108">- Selecione a Pasta Personalizada</string>
     <string id="30110">Pesquisa Manual</string>
     <string id="30111">Idioma Terciário</string> 
     <string id="30113">Selecione o Serviço Padrão para Filmes</string>
@@ -47,53 +47,54 @@
     <string id="30122">Tempo Padrão de Timeout</string>
     <string id="30123">- Legendas.TV Nome do Usuário</string>
     <string id="30124">- Legendas.TV Senha</string>
-    <string id="30125">Disable hash search</string>
+    <string id="30125">Desabilitar pesquisa por hash</string>
   
   <!-- Languages  -->
 
-    <string id="30201">Albanian</string>
-    <string id="30202">Arabic</string>
-    <string id="30203">Belarusian</string>
-    <string id="30204">Bosnian (Latin)</string>
-    <string id="30205">Bulgarian</string>
-    <string id="30206">Catalan</string>
-    <string id="30207">Chinese</string>
-    <string id="30208">Croatian</string>
-    <string id="30209">Czech</string>
-    <string id="30210">Danish</string>
-    <string id="30211">Dutch</string>
-    <string id="30212">English</string>
-    <string id="30213">Estonian</string>
-    <string id="30214">Finnish</string>
-    <string id="30215">French</string>
-    <string id="30216">German</string>
-    <string id="30217">Greek</string>
-    <string id="30218">Hebrew</string>
-    <string id="30219">Hindi</string>
-    <string id="30220">Hungarian</string>
-    <string id="30221">Icelandic</string>
-    <string id="30222">Indonesian</string>
-    <string id="30224">Italian</string>
-    <string id="30225">Japanese</string>
-    <string id="30226">Korean</string>
-    <string id="30227">Latvian</string>
-    <string id="30228">Lithuanian</string>
-    <string id="30229">Macedonian</string>
-    <string id="30230">Norwegian</string>
-    <string id="30232">Polish</string>
-    <string id="30233">Portuguese</string>
-    <string id="30234">Portuguese (Brazil)</string>
-    <string id="30235">Romanian</string>
-    <string id="30236">Russian</string>
-    <string id="30237">SerbianLatin</string>
-    <string id="30238">Slovak</string>
-    <string id="30239">Slovenian</string>
-    <string id="30240">Spanish</string>
-    <string id="30242">Swedish</string>
-    <string id="30243">Thai</string>
-    <string id="30244">Turkish</string>
-    <string id="30245">Ukrainian</string>
-    <string id="30246">Vietnamese</string>
-    <string id="30247">Farsi</string>
+    <string id="30201">Albanês</string>
+    <string id="30202">Árabe</string>
+    <string id="30203">Bielorrusso</string>
+    <string id="30204">Bósnio (Latino)</string>
+    <string id="30205">Búlgaro</string>
+    <string id="30206">Catalão</string>
+    <string id="30207">Chinês</string>
+    <string id="30208">Croata</string>
+    <string id="30209">Checo</string>
+    <string id="30210">Dinamarquês</string>
+    <string id="30211">Holandês</string>
+    <string id="30212">Inglês</string>
+    <string id="30213">Estoniano</string>
+    <string id="30214">Finlandês</string>
+    <string id="30215">Francês</string>
+    <string id="30216">Alemão</string>
+    <string id="30217">Grego</string>
+    <string id="30218">Hebraico</string>
+    <string id="30219">Indiano</string>
+    <string id="30220">Húngaro</string>
+    <string id="30221">Islandês</string>
+    <string id="30222">indonésio</string>
+    <string id="30224">Italiano</string>
+    <string id="30225">Japonês</string>
+    <string id="30226">Coreano</string>
+    <string id="30227">Letão</string>
+    <string id="30228">Lituano</string>
+    <string id="30229">Macedônio</string>
+    <string id="30230">Norueguês</string>
+    <string id="30232">Polonês</string>
+    <string id="30233">Português</string>
+    <string id="30234">Português (Brasileiro)</string>
+    <string id="30235">Romeno</string>
+    <string id="30236">Russo</string>
+    <string id="30237">Sérvio</string>
+    <string id="30238">Eslovaco</string>
+    <string id="30239">Esloveno</string>
+    <string id="30240">Espanhol</string>
+    <string id="30242">Sueco</string>
+    <string id="30243">Tailandês</string>
+    <string id="30244">Turco</string>
+    <string id="30245">Ucraniano</string>
+    <string id="30246">Vietnamita</string>
+    <string id="30247">Persa</string>
+
       
 </strings>
diff --git a/script.xbmc.subtitles/resources/lib/gui.py 
b/script.xbmc.subtitles/resources/lib/gui.py
index 924ae39..a4d60cd 100644
--- a/script.xbmc.subtitles/resources/lib/gui.py
+++ b/script.xbmc.subtitles/resources/lib/gui.py
@@ -45,10 +45,11 @@ class GUI( xbmcgui.WindowXMLDialog ):
         if (movieFullPath.find("rar://") > -1 ):
             rar = True
             
-            movieFullPath = sub_folder = movieFullPath.replace("rar://","")
-            sub_folder = os.path.dirname(os.path.dirname( sub_folder ))
+            movieFullPath = movieFullPath.replace("rar://","")
+            if path:
+              sub_folder = os.path.dirname(os.path.dirname( movieFullPath ))
                 
-        if not path and not rar:
+        if not path:
             if len(sub_folder) < 1 :
                 sub_folder = os.path.dirname( movieFullPath )
                               
@@ -114,11 +115,11 @@ class GUI( xbmcgui.WindowXMLDialog ):
           self.file_name = os.path.basename( movieFullPath )
         else:
           if (len(str(self.year)) < 1 ) :
-            self.file_name = self.title
+            self.file_name = self.title.encode('utf-8')
             if (len(self.tvshow) > 0):
-              self.file_name = "%s S%.2dE%.2d" % (self.tvshow, 
int(self.season), int(self.episode) )
+              self.file_name = "%s S%.2dE%.2d" % (self.tvshow.encode('utf-8'), 
int(self.season), int(self.episode) )
           else:
-            self.file_name = "%s (%s)" % (self.title, str(self.year),)    
+            self.file_name = "%s (%s)" % (self.title.encode('utf-8'), 
str(self.year),)    
           
           
         self.tmp_sub_dir = os.path.join( xbmc.translatePath( 
"special://profile/" ), "addon_data", os.path.basename( __cwd__ ),"sub_tmp" )
diff --git a/script.xbmc.subtitles/resources/lib/services/LegendasTV/service.py 
b/script.xbmc.subtitles/resources/lib/services/LegendasTV/service.py
index 2279da4..b642544 100644
--- a/script.xbmc.subtitles/resources/lib/services/LegendasTV/service.py
+++ b/script.xbmc.subtitles/resources/lib/services/LegendasTV/service.py
@@ -1,7 +1,7 @@
 # Copyright, 2010, Guilherme Jardim.
 # This program is distributed under the terms of the GNU General Public 
License, version 3.
 # http://www.gnu.org/licenses/gpl.txt
-# Rev. 1.0.1
+# Rev. 1.0.2
 
 import xbmc, xbmcgui
 import cookielib, urllib2, urllib, sys, re, os, webbrowser, time, unicodedata
@@ -145,10 +145,10 @@ def LegendasLogin(cj=0):
                request = 
urllib2.Request(base_url+'/login_verificar.php',login_data)
                response = urllib2.urlopen(request).read()
                if response.__contains__('Dados incorretos'):
-                       log( __name__ ,u"%s Login Failed. Check your data at 
the addon configuration." % (debug_pretext))
+                       log( __name__ ,u" Login Failed. Check your data at the 
addon configuration.")
                        
xbmc.executebuiltin("Notification(Legendas.TV,%s,10000])"%( _( 756 
).encode('utf-8') ))
                else:
-                       log( __name__ ,u"%s Succesfully logged in." % 
(debug_pretext))
+                       log( __name__ ,u" Succesfully logged in.")
        return cj
 
 def LegendasTVMovies(file_original_path, title, year, lang1, lang2, lang3 ):
@@ -156,23 +156,22 @@ def LegendasTVMovies(file_original_path, title, year, 
lang1, lang2, lang3 ):
        # Initiating variables and languages.
        lang1, ltv_flag1, langid1, lang2, ltv_flag2, langid2, lang3, ltv_flag3, 
langid3 = LegendasLanguage(lang1,lang2,lang3)
        tipo = "2"
-       legenda_id = 0
-       subtitles = []
-       sub1 = []
-       sub2 = []
-       sub3 = []
+       subtitles, sub1, sub2, sub3, PartialSubtitles = [], [], [], [], []
        
        # Try to get the original movie name from the XBMC database, 
        # and if not available, set it to the parsed title.
-       original_title = 
re.findall("<[^>]*>([^<]*)</[^>]*>",xbmc.executehttpapi("QueryVideoDatabase(select
 c16 from movie where movie.c00 = 
'"+xbmc.Player().getVideoInfoTag().getTitle()+"')"))
-       if not original_title or not year: original_title = title
+       xbmcPlayerTitle = xbmc.getCleanMovieTitle( 
xbmc.getInfoLabel("VideoPlayer.Title") )[0]
+       original_title = 
re.sub("</?[^>]*>","",xbmc.executehttpapi("QueryVideoDatabase(select c16 from 
movie where movie.c00 = \""+xbmcPlayerTitle+"\")"))
+
+       if original_title == "" or year == "" : original_title = title
        else:
-               original_title = Uconvert(original_title[0])
+               original_title = Uconvert(original_title)
                log( __name__ ,u"%s Original Title[%s]" % (debug_pretext, 
original_title))
 
        # Encodes the first search string using the original movie title,
        # and download it.
        search_string = chomp(original_title)
+       log( __name__ ,u"Searching[%s]" % (debug_pretext))
        if len(search_string) < 3: search_string = search_string + year
        search_dict = 
{'txtLegenda':search_string,'selTipo':tipo,'int_idioma':'99'}
        search_data = urllib.urlencode(search_dict)
@@ -181,7 +180,7 @@ def LegendasTVMovies(file_original_path, title, year, 
lang1, lang2, lang3 ):
 
        # If no subtitles with the original name are found, try the parsed 
title.
        if response.__contains__('Nenhuma legenda foi encontrada') and 
original_title != title:
-               log( __name__ ,u"%s No subtitles found using the original 
title, using title instead." % (debug_pretext))
+               log( __name__ ,u" No subtitles found using the original title, 
using title instead.")
                search_string = chomp(title)
                search_dict = 
{'txtLegenda':search_string,'selTipo':tipo,'int_idioma':'99'}
                search_data = urllib.urlencode(search_dict)
@@ -213,8 +212,10 @@ def LegendasTVMovies(file_original_path, title, year, 
lang1, lang2, lang3 ):
                        td = span.find('td',{'class':'mais'})
                        
                        # Translated and original titles from LTV.
-                       ltv_title = Uconvert(td.contents[2])
-                       ltv_original_title = 
Uconvert(td.contents[0].contents[0])
+                       ltv_title = CleanLTVTitle(td.contents[2])
+                       ltv_original_title = 
CleanLTVTitle(td.contents[0].contents[0])
+                       
+                       if re.search("[0-9]+[St|Nd|Rd|Th] Season", 
ltv_original_title): continue
                        
                        # Release name of the subtitle file.
                        release = 
Uconvert(td.parent.parent.find('span',{'class':'brls'}).contents[0])
@@ -237,12 +238,13 @@ def LegendasTVMovies(file_original_path, title, year, 
lang1, lang2, lang3 ):
                        
                        # Compare the retrieved titles from LTV to those parsed 
or snatched by this service.
                        # Each language is appended to a sequence.
-                       if comparetitle(ltv_original_title, original_title) or 
comparetitle(ltv_title, title) or comparetitle(ltv_original_title, title) or 
comparetitle(original_title, ltv_title) or 
re.findall('^'+original_title+"[/s|$]",ltv_original_title) or 
re.findall(original_title+'$',ltv_original_title) or 
re.findall('^'+title,ltv_title) or re.findall(title+'$',ltv_title):
+                       original_title, title = CleanLTVTitle(original_title), 
CleanLTVTitle(title)
+                       if comparetitle(ltv_original_title, original_title) or 
comparetitle(ltv_title, title) or comparetitle(ltv_original_title, title) or 
comparetitle(original_title, ltv_title) or re.findall('^'+original_title+"[ 
|$]",ltv_original_title) or re.findall(original_title+'$',ltv_original_title) 
or re.findall('^'+title,ltv_title) or re.findall(title+'$',ltv_title):
                                if ltv_lang == ltv_flag1: sub1.append( { 
"title" : ltv_title, "filename" : release,"language_name" : lang1, "ID" : 
download_id, "sync" : False, "rating" : ltv_rating, "language_flag": 
"flags/"+ltv_flag1+".gif" } )
                                if ltv_lang == ltv_flag2: sub2.append( { 
"title" : ltv_title, "filename" : release,"language_name" : lang2, "ID" : 
download_id, "sync" : False, "rating" : ltv_rating, "language_flag": 
"flags/"+ltv_flag2+".gif" } )
                                if ltv_lang == ltv_flag3: sub3.append( { 
"title" : ltv_title, "filename" : release,"language_name" : lang3, "ID" : 
download_id, "sync" : False, "rating" : ltv_rating, "language_flag": 
"flags/"+ltv_flag3+".gif" } )
-                               log( __name__ ,u"%s Matched!\nTitle[%s], 
Original Title[%s]\nLTV Title[%s], LTV Original Title[%s]\nID[%s], Release[%s], 
Language[%s], Rating[%s]" % (debug_pretext, title, original_title, ltv_title, 
ltv_original_title, download_id, release, ltv_lang, ltv_rating))
-                       else: log( __name__ ,u"%s Discarted.\nTitle[%s], 
Original Title[%s]\nLTV Title[%s], LTV Original Title[%s]\nID[%s], Release[%s], 
Language[%s], Rating[%s]" % (debug_pretext, title, original_title, ltv_title, 
ltv_original_title, download_id, release, ltv_lang, ltv_rating))
+                               log( __name__ ,u" Matched!\nTitle[%s], Original 
Title[%s]\nLTV Title[%s], LTV Original Title[%s]\nID[%s], Release[%s], 
Language[%s], Rating[%s]" % (title, original_title, ltv_title, 
ltv_original_title, download_id, release, ltv_lang, ltv_rating))
+                       else:log( __name__ ,u" Mismatched.\nTitle[%s], Original 
Title[%s]\nLTV Title[%s], LTV Original Title[%s]\nID[%s], Release[%s], 
Language[%s], Rating[%s]" % (title, original_title, ltv_title, 
ltv_original_title, download_id, release, ltv_lang, ltv_rating))
 
        # Append all three language sequences.
        subtitles.extend(sub1)
@@ -255,17 +257,17 @@ def LegendasTVSeries(tvshow, year, season, episode, 
lang1, lang2, lang3 ):
        # Initiating variables and languages.
        lang1, ltv_flag1, langid1, lang2, ltv_flag2, langid2, lang3, ltv_flag3, 
langid3 = LegendasLanguage(lang1,lang2,lang3)
        tipo = "1"
-       idioma = "1"
-       subtitles = []
-       sub1 = []
-       sub2 = []
-       sub3 = []
+       subtitles, sub1, sub2, sub3, PartialSubtitles = [], [], [], [], []
        
        # Searching XBMC Database for TheTVDb id of the tvshow and retreaving 
the original tvshow title from TheTVDB.
        # This tries to avoid mismatches when using translated tvshow names.
-       tvshow_id = 
re.sub("</?[^>]*>","",xbmc.executehttpapi("QueryVideoDatabase(select c12 from 
tvshow where c00 = '"+xbmc.getInfoLabel("VideoPlayer.TVshowtitle")+"')"))
-       if tvshow_id: original_tvshow = 
Uconvert(BeautifulStoneSoup(urllib2.urlopen("http://www.thetvdb.com/data/series/"+tvshow_id+"/";).read()).data.series.seriesname.string)
-       else: original_tvshow = 0
+       
+       try:
+               xbmcTVShow = xbmc.getInfoLabel("VideoPlayer.TVshowtitle")
+               tvshow_id = 
int(re.sub("</?[^>]*>","",xbmc.executehttpapi("QueryVideoDatabase(select c12 
from tvshow where c00 = \""+xbmcTVShow+"\")")))
+               if tvshow_id: original_tvshow = 
Uconvert(BeautifulStoneSoup(urllib2.urlopen("http://www.thetvdb.com/data/series/"+str(tvshow_id)+"/").read()).data.series.seriesname.string)
+               else: original_tvshow = tvshow
+       except: original_tvshow = tvshow
        log( __name__ , original_tvshow )
 
        # Formating the season to double digit format
@@ -276,10 +278,11 @@ def LegendasTVSeries(tvshow, year, season, episode, 
lang1, lang2, lang3 ):
 
        # Setting up the search string; the original tvshow name is preferable.
        # If the tvshow name lenght is less than 3 characters, append the year 
to the search.
-       if original_tvshow: search_string = chomp(original_tvshow) + " " 
+"S"+ss+"E"+ee
-       else: search_string = chomp(tvshow) + " " +"S"+ss+"E"+ee
+       
+       search_string = chomp(original_tvshow) + " " +"S"+ss+"E"+ee
        if len(search_string) < 3: search_string = search_string +" "+ year
        log( __name__ , "Searching "+search_string )
+       
        # Doing the search and parsing the results to BeautifulSoup
        search_dict = 
{'txtLegenda':search_string,'selTipo':tipo,'int_idioma':'99'}
        search_data = urllib.urlencode(search_dict)
@@ -298,15 +301,25 @@ def LegendasTVSeries(tvshow, year, season, episode, 
lang1, lang2, lang3 ):
                # Translated and original titles from LTV, the LTV season 
number and the
                # scene release name of the subtitle. If a movie is retrieved, 
the re.findall
                # will raise an exception and will continue to the next loop.
-               try:
-                       ltv_title = re.findall("(.*) - 
[0-9]*",Uconvert(td.contents[2]))[0]
-                       ltv_original_title, ltv_season = re.findall("(.*) - 
([0-9]*)",Uconvert(td.contents[0].contents[0]))[0]
-                       release = 
td.parent.parent.find('span',{'class':'brls'}).contents[0]
-                       if not ltv_season: continue
-               except:
-                       continue
+               reResult = re.findall("(.*) - 
[0-9]*",CleanLTVTitle(td.contents[2]))
+               if reResult: ltv_title = reResult[0]
+               else:
+                       ltv_title = CleanLTVTitle(td.contents[2])
                
-               # Retrieves the rating of the subtitle, and set it to '0' id 
not available.
+               reResult = re.findall("(.*) - 
([0-9]*)",CleanLTVTitle(td.contents[0].contents[0]))
+               if reResult: ltv_original_title, ltv_season = reResult[0]
+               else:
+                       ltv_original_title = 
CleanLTVTitle(td.contents[0].contents[0])
+                       ltv_season = 0
+
+               release = 
td.parent.parent.find('span',{'class':'brls'}).contents[0]
+               if not ltv_season:
+                       reResult = re.findall("[Ss]([0-9]+)[Ee][0-9]+",release)
+                       if reResult: ltv_season = re.sub("^0","",reResult[0])
+                       
+               if not ltv_season: continue
+
+               # Retrieves the rating of the subtitle, and set it to '0' if 
not available.
                ltv_rating = td.contents[10]
                ltv_rating = chomp(ltv_rating.split("/")[0])
                if ltv_rating == "N": ltv_rating = "0"
@@ -324,36 +337,45 @@ def LegendasTVSeries(tvshow, year, season, episode, 
lang1, lang2, lang3 ):
                # Compares the parsed and the LTV season number, then compares 
the retrieved titles from LTV
                # to those parsed or snatched by this service.
                # Each language is appended to a unique sequence.
+               tvshow = CleanLTVTitle(tvshow)
+               original_tvshow = CleanLTVTitle(original_tvshow)
                if int(ltv_season) == int(season): 
-                       if re.findall('^%s' % (tvshow),ltv_original_title) or 
comparetitle(ltv_title,tvshow) or 
comparetitle(ltv_original_title,original_tvshow):
-                               if ltv_lang == ltv_flag1: sub1.append( { 
"title" : ltv_original_title, "filename" : release,"language_name" : lang1, 
"ID" : download_id, "sync" : False, "rating" : ltv_rating, "language_flag": 
"flags/"+ltv_flag1+".gif" } )
-                               if ltv_lang == ltv_flag2: sub2.append( { 
"title" : ltv_original_title, "filename" : release,"language_name" : lang2, 
"ID" : download_id, "sync" : False, "rating" : ltv_rating, "language_flag": 
"flags/"+ltv_flag2+".gif" } )
-                               if ltv_lang == ltv_flag3: sub3.append( { 
"title" : ltv_original_title, "filename" : release,"language_name" : lang3, 
"ID" : download_id, "sync" : False, "rating" : ltv_rating, "language_flag": 
"flags/"+ltv_flag3+".gif" } )
-                               log( __name__ ,u"%s Matched!\nTVShow[%s], 
Original TVShow[%s]\nLTV TVShow[%s], LTV Original TVShow[%s]\nRelease[%s], 
Season[%s], ID[%s], Language[%s], Rating[%s]" % (debug_pretext, tvshow, 
original_tvshow, ltv_title, ltv_original_title, release, ltv_season, 
download_id, ltv_lang, ltv_rating))
-                       else: log( __name__ ,u"%s Discarted.\nTVShow[%s], 
Original TVShow[%s]\nLTV TVShow[%s], LTV Original TVShow[%s]\nRelease[%s], 
Season[%s], ID[%s], Language[%s], Rating[%s]" % (debug_pretext, tvshow, 
original_tvshow, ltv_title, ltv_original_title, release, ltv_season, 
download_id, ltv_lang, ltv_rating))
-               else: log( __name__ ,u"%s Season do not match. Season[%s], LTV 
Season[%s]." % (debug_pretext))
+                       SubtitleResult = { "title" : ltv_original_title, 
"filename" : release,"language_name" : lang1, "ID" : download_id, "sync" : 
False, "rating" : ltv_rating, "language_flag": "flags/"+ltv_lang+".gif" } 
+                       if re.findall("^%s" % (tvshow),ltv_original_title) or 
comparetitle(ltv_title,tvshow) or 
comparetitle(ltv_original_title,original_tvshow):
+                               if ltv_lang == ltv_flag1: sub1.append( 
SubtitleResult )
+                               if ltv_lang == ltv_flag2: sub2.append( 
SubtitleResult )
+                               if ltv_lang == ltv_flag3: sub3.append( 
SubtitleResult )
+                               log( __name__ ,u" Matched!\nTVShow[%s], 
Original TVShow[%s]\nLTV TVShow[%s], LTV Original TVShow[%s]\nRelease[%s], 
Season[%s], ID[%s], Language[%s], Rating[%s]" % (tvshow, original_tvshow, 
ltv_title, ltv_original_title, release, ltv_season, download_id, ltv_lang, 
ltv_rating))
+                       else:
+                               reResult = 
re.findall("[Ss][0-9]+[Ee]([0-9]+)",release)
+                               if reResult: LTVEpisode = 
re.sub("^0","",reResult[0])
+                               else: LTVEpisode = 0
+                               if int(LTVEpisode) == int(episode):
+                                       PartialSubtitles.append( SubtitleResult 
)
+                               log( __name__ ,u" Mismatched.\nTVShow[%s], 
Original TVShow[%s]\nLTV TVShow[%s], LTV Original TVShow[%s]\nRelease[%s], 
Season[%s], ID[%s], Language[%s], Rating[%s]" % (tvshow, original_tvshow, 
ltv_title, ltv_original_title, release, ltv_season, download_id, ltv_lang, 
ltv_rating))
+               else: log( __name__ ,u" Seasons mismatched. Season[%s], LTV 
Season[%s]." % (season, ltv_season))
                
        # Append all three language sequences.
        subtitles.extend(sub1)
        subtitles.extend(sub2)
        subtitles.extend(sub3)
+       if not len(subtitles): subtitles.extend(PartialSubtitles)
        return subtitles
 
 def chomp(s):
-       a = re.compile("(\r|\n|^ | $|\'|\"|,|;)")
-       b = re.compile("(\t|-|:|[(]|[)]|\/)")
-       s = a.sub("",s)
+       s = re.sub("[ ]{2,20}"," ",s)
+       a = re.compile("(\r|\n|^ | $|\'|\"|,|;|[(]|[)])")
+       b = re.compile("(\t|-|:|\/)")
        s = b.sub(" ",s)
        s = re.sub("[ ]{2,20}"," ",s)
+       s = a.sub("",s)
        return s
        
 def CleanLTVTitle(s):
-       a = re.compile("(\r|\n|^ | $|\'|\"|,|;)")
-       b = re.compile("(\t|-|:|[(]|[)]|\/)")
+       s = Uconvert(s)
        s = re.sub("[(]?[0-9]{4}[)]?$","",s)
-       s = a.sub("",s)
-       s = b.sub(" ",s)
-       s = re.sub("[ ]{2,20}"," ",s)
+       s = chomp(s)
+       s = s.title()
        return s
 
        
@@ -392,12 +414,12 @@ def compareyear(a, b):
                return 0
 
 def comparetitle(a, b):
-       a = CleanLTVTitle(a.title())
-       b = CleanLTVTitle(b.title())
        if (a == b) or (noarticle(a) == noarticle(b)) or (a == noarticle(b)) or 
(noarticle(a) == b) or (a == shiftarticle(b)) or (shiftarticle(a) == b):
                return 1
        else:
+#              print "[%s] != [%s]" % (a,b)
                return 0
+               
 
 def to_unicode_or_bust(
          obj, encoding='iso-8859-1'):
diff --git a/script.xbmc.subtitles/resources/lib/utilities.py 
b/script.xbmc.subtitles/resources/lib/utilities.py
index 2b9969b..d3ca73f 100644
--- a/script.xbmc.subtitles/resources/lib/utilities.py
+++ b/script.xbmc.subtitles/resources/lib/utilities.py
@@ -160,15 +160,15 @@ def toOpenSubtitles_two( id ):
     "Urdu"                       : "ur",
     "Vietnamese"                 : "vi",
     "English (US)"               : "en",
-    "English (UK)"              : "en",
-    "Portuguese (Brazilian)"    : "pt-br",
-    "Español (Latinoamérica)" : "es",
-    "Español (España)"        : "es",
-    "Spanish (Latin America)"   : "es",
-    "Español"                  : "es",
-    "Spanish (Spain)"           : "es",
-    "Chinese (Traditional)"     : "zh",
-    "Chinese (Simplified)"      : "zh",
+    "English (UK)"               : "en",
+    "Portuguese (Brazilian)"     : "pt-br",
+    "Español (Latinoamérica)"  : "es",
+    "Español (España)"         : "es",
+    "Spanish (Latin America)"    : "es",
+    "Español"                   : "es",
+    "Spanish (Spain)"            : "es",
+    "Chinese (Traditional)"      : "zh",
+    "Chinese (Simplified)"       : "zh",
     "All"                        : "all"
   }
   return languages[ id ]
@@ -476,6 +476,17 @@ def twotofull(id):
     "es"                  :  "Spanish",
     "sv"                  :  "Swedish",
     "tr"                  :  "Turkish",
+    "pb"                  :  "PortugueseBrazil",
+    "hy"                  :  "Belarusian",
+    "bs"                  :  "Bosnian",
+    "ca"                  :  "Catalan",
+    "is"                  :  "Icelandic",
+    "kk"                  :  "Kazakh",
+    "th"                  :  "Thai",
+    "uk"                  :  "Ukrainian",
+    "vi"                  :  "Vietnamese",
+    "fa"                  :  "Persian",
+
 
   }
   return languages[ id ]  

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

Summary of changes:
 script.xbmc.subtitles/addon.xml                    |    6 +-
 script.xbmc.subtitles/changelog.txt                |    7 +
 .../resources/language/Bulgarian/strings.xml       |   99 +++++++++++++++
 .../resources/language/Croatian/strings.xml        |    2 +-
 .../language/Portuguese (Brazil)/strings.xml       |  109 +++++++++---------
 script.xbmc.subtitles/resources/lib/gui.py         |   13 +-
 .../resources/lib/services/LegendasTV/service.py   |  126 ++++++++++++--------
 script.xbmc.subtitles/resources/lib/utilities.py   |   29 +++--
 8 files changed, 267 insertions(+), 124 deletions(-)
 create mode 100644 
script.xbmc.subtitles/resources/language/Bulgarian/strings.xml


hooks/post-receive
-- 
Scripts

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to