The branch, eden has been updated
       via  b51b1165cff2cf5e5ca4b64d628d00bb24276c70 (commit)
       via  4f86af9ab97bfcdb57b729bff1edb541263b7cd7 (commit)
      from  ff26a11158efab48183924c396290f6d87bd6bd2 (commit)

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


http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=4f86af9ab97bfcdb57b729bff1edb541263b7cd7

commit 4f86af9ab97bfcdb57b729bff1edb541263b7cd7
Author: amet <[email protected]>
Date:   Fri Mar 2 20:57:16 2012 +0400

    [script.xbmc.subtitles] -v 2.9.34
    
    - Titlovi service rewrite using their API, this is now supported by them. 
Thanks Nikola for API key and assistance
    - cosmetics

diff --git a/script.xbmc.subtitles/addon.xml b/script.xbmc.subtitles/addon.xml
index 8b78b54..47cd374 100755
--- 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.9.33"
+       version="2.9.34"
        provider-name="Amet, mr_blobby">
   <requires>
     <import addon="xbmc.python" version="2.0"/>
diff --git a/script.xbmc.subtitles/changelog.txt 
b/script.xbmc.subtitles/changelog.txt
index 0833d52..2220364 100644
--- a/script.xbmc.subtitles/changelog.txt
+++ b/script.xbmc.subtitles/changelog.txt
@@ -1,3 +1,7 @@
+2.9.34
+- Titlovi service rewrite using their API, this is now supported by them. 
Thanks Nikola for API key and assistance
+- cosmetics
+
 2.9.33
 - fix: BetaSeries service and series  with ' in it
 - fix: Itasa year bug fixed
diff --git a/script.xbmc.subtitles/resources/lib/gui.py 
b/script.xbmc.subtitles/resources/lib/gui.py
index 23fd775..68ea417 100644
--- a/script.xbmc.subtitles/resources/lib/gui.py
+++ b/script.xbmc.subtitles/resources/lib/gui.py
@@ -311,7 +311,6 @@ class GUI( xbmcgui.WindowXMLDialog ):
       # Choose the last pair in the list, second item (destination file)
       if subtitle_set:
         xbmc.Player().setSubtitles(files_list[-1][1])
-        rem_files(self.tmp_sub_dir)
         self.close()
       else:
         if gui:
diff --git a/script.xbmc.subtitles/resources/lib/services/Titlovi/service.py 
b/script.xbmc.subtitles/resources/lib/services/Titlovi/service.py
index 28ca8b8..c0c4b5a 100644
--- a/script.xbmc.subtitles/resources/lib/services/Titlovi/service.py
+++ b/script.xbmc.subtitles/resources/lib/services/Titlovi/service.py
@@ -1,156 +1,74 @@
 # -*- coding: UTF-8 -*-
 
-import os, sys, re, xbmc, xbmcgui, string, time, urllib, urllib2
+import os, sys, re, xbmc, xbmcgui, string, time, urllib, urllib2, xmlrpclib, 
base64
+from xml.dom import minidom
 from utilities import languageTranslate, log
 
-main_url = "http://titlovi.com/titlovi/titlovi.aspx?";
+KEY = "UGE4Qk0tYXNSMWEtYTJlaWZfUE9US1NFRC1WRUQtWA=="
 debug_pretext = ""
-subtitles_list = []
 
-#====================================================================================================================
-# Regular expression patterns
-#====================================================================================================================
-
-# subtitle pattern example:
-"""
-      <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 />\
-(.{200,200})"
-subinfo_pattern = "\r\n +> +(.*?)\r"
-
-# multiple results pages:
-# [ 13 ]</a> <a 
id="ctl00_ctl00_ctl00_contentholder_mainholder_subtitlesholder_hyp_14" 
href="http://titlovi.com/titlovi/titlovi.aspx?prijevod=lost&amp;jezik=&amp;stranica=14";>14</a>
-pages_pattern = "\[ \d{1,3} \]</a> <a 
id=\"ctl00_ctl00_ctl00_contentholder_mainholder_subtitlesholder_hyp_(\d{1,3})\""
-
-#====================================================================================================================
-# Functions
-#====================================================================================================================
-
-def to_titlovi_lang(language):
-    if language == "Croatian":            return "hrvatski"
-    elif language == "SerbianLatin":      return "srpski"
-    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"
-    else:                                 return None
-
-def unescape(s):
-    s = s.replace("&lt;", "<")
-    s = s.replace("&gt;", ">")
-    # this has to be last:
-    s = s.replace("&amp;", "&")
-    return s
-
-def getallsubs(content, language, search_string, season, episode):
-    i = 0
-    for matches in re.finditer(subtitle_pattern, content, re.IGNORECASE | 
re.DOTALL):
-        i = i + 1
-        title_found = unescape(string.rstrip(matches.group(2)))
-        log( __name__ , title_found )
-        log( __name__ , search_string )
-        if string.find(string.lower(title_found),string.lower(search_string)) 
> -1:
-            subtitle_id    = matches.group(1)
-            year_found     = matches.group(3)
-            season_episode_found = string.rstrip(matches.group(4))
-            filename = title_found
-            languageshort = languageTranslate(language,0,2)
-            match = re.match(subinfo_pattern, matches.group(5), re.IGNORECASE 
| re.DOTALL)
-            if match:
-                description = match.group(1)
-                filename = filename + ' ' + description
-            if len(season) > 0:
-                season_episode = 'Sezona' + season + ' Epizoda' + 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:
-                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))
-
-def getnextpage(content):
-    i = 0
-    for matches in re.finditer(pages_pattern, content, re.IGNORECASE | 
re.DOTALL):
-        i = i + 1
-    if i == 1:
-        return matches.group(1)
-    else:
-        return None
+def compare_columns(b,a):
+  return cmp( b["language_name"], a["language_name"] ) 
 
 def geturl(url):
     class MyOpener(urllib.FancyURLopener):
         version = ''
     my_urlopener = MyOpener()
-    log( __name__ ,"%s Getting url: %s" % (debug_pretext, url))
     try:
         response = my_urlopener.open(url)
         content    = response.read()
     except:
-        log( __name__ ,"%s Failed to get url:%s" % (debug_pretext, url))
         content    = None
     return content
 
-
 def search_subtitles( file_original_path, title, tvshow, year, season, 
episode, set_temp, rar, lang1, lang2, lang3, stack ): #standard input
     msg = ""
-    if len(tvshow) == 0:
-        searchstring = title
-    if len(tvshow) > 0:
-        searchstring = tvshow
-    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)
-        if content is not None:
-            getallsubs(content, lang1, searchstring, str(season), str(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)
-                getallsubs(content, lang1, searchstring, str(season), 
str(episode))
-                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)
-            content = geturl(url)
-            if content is not None:
-                getallsubs(content, lang2, searchstring, str(season), 
str(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)
-                    getallsubs(content, lang2, searchstring, str(season), 
str(episode))
-                    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)
-            content = geturl(url)
-            if content is not None:
-                getallsubs(content, lang3, searchstring, str(season), 
str(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)
-                    getallsubs(content, lang3, searchstring, str(season), 
str(episode))
-                    nextpage = getnextpage(content)
-
+    subtitles_list = []
+    search_url = 
"http://api.titlovi.com/xml_get_api.ashx?x-dev_api_id=%s&keyword=%s&uiculture=en";
+    languages = [lang1, lang2, lang3]
+
+    if len(tvshow) > 0:                                              # TvShow
+        search_string = ("%s S%.2dE%.2d" % (tvshow, int(season), 
int(episode),)).replace(" ","+")      
+    else:                                                            # Movie 
or not in Library
+        if str(year) == "":                                          # Not in 
Library
+            title, year = xbmc.getCleanMovieTitle( title )
+        else:                                                        # Movie 
in Library
+            year  = year
+            title = title
+        search_string = title.replace(" ","+")
+    log( __name__ , "Search String [ %s ]" % (search_string,))
+    subtitles = minidom.parseString(geturl(search_url % 
(base64.b64decode(KEY)[::-1], search_string))).getElementsByTagName("subtitle")
+    if subtitles:
+      url_base = 
"http://en.titlovi.com/downloads/default.ashx?type=1&mediaid=%s";
+      for subtitle in subtitles:
+        lang = subtitle.getElementsByTagName("language")[0].firstChild.data
+        if lang == "rs": lang = "sr"
+        if lang == "ba": lang = "bs"
+        if lang == "si": lang = "sl"
+        lang_full = languageTranslate(lang, 2,0)
+        if lang_full in languages:
+            sub_id = subtitle.getElementsByTagName("url")[0].firstChild.data
+            movie = 
subtitle.getElementsByTagName("safeTitle")[0].firstChild.data
+            filename = "%s - %s" % (movie, 
subtitle.getElementsByTagName("release")[0].firstChild.data)
+            rating = 
int(subtitle.getElementsByTagName("score")[0].firstChild.data)*2
+            flag_image = "flags/%s.gif" % lang
+            link = url_base % sub_id.split("-")[-1].replace("/","")            
+            subtitles_list.append({'filename'     :filename,
+                                   'link'         :link,
+                                   'language_name':lang_full,
+                                   'language_id'  :lang,
+                                   'language_flag':flag_image,
+                                   'movie'        :movie,
+                                   'rating'       :str(rating),
+                                   'sync'         :False})
+
+    subtitles_list = sorted(subtitles_list, compare_columns)
     return subtitles_list, "", msg #standard output
 
 
 def download_subtitles (subtitles_list, pos, zip_subs, tmp_sub_dir, 
sub_folder, session_id): #standard input
-    subtitle_id = subtitles_list[pos][ "subtitle_id" ]
     language = subtitles_list[pos][ "language_name" ]
-    url = "http://titlovi.com/downloads/default.ashx?type=1&mediaid="; + 
str(subtitle_id)
+    url = subtitles_list[pos][ "link" ]
     log( __name__ ,"%s Fetching subtitles using url %s" % (debug_pretext, url))
     content = geturl(url)
     if content is not None:
@@ -208,3 +126,5 @@ def download_subtitles (subtitles_list, pos, zip_subs, 
tmp_sub_dir, sub_folder,
                         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
+        
+       

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

Summary of changes:
 .../LICENSE.txt                                    |    0
 script.module.metahandler/addon.xml                |   15 +
 .../changelog.txt                                  |    0
 script.module.metahandler/lib/metahandler/TMDB.py  |  334 ++++
 .../lib/metahandler/__init__.py                    |   42 +
 .../lib/metahandler/common.py                      |   20 +-
 .../lib/metahandler/metacontainers.py              |  196 ++
 .../lib/metahandler/metahandlers.py                | 2082 ++++++++++++++++++++
 .../lib/metahandler/thetvdbapi.py                  |  386 ++++
 script.module.metahandler/resources/settings.xml   |    6 +
 script.xbmc.subtitles/addon.xml                    |    2 +-
 script.xbmc.subtitles/changelog.txt                |    4 +
 script.xbmc.subtitles/resources/lib/gui.py         |    1 -
 .../resources/lib/services/Titlovi/service.py      |  176 +--
 14 files changed, 3129 insertions(+), 135 deletions(-)
 copy {script.module.t0mm0.common => script.module.metahandler}/LICENSE.txt 
(100%)
 create mode 100644 script.module.metahandler/addon.xml
 copy {script.module.t0mm0.common => script.module.metahandler}/changelog.txt 
(100%)
 create mode 100644 script.module.metahandler/lib/metahandler/TMDB.py
 create mode 100644 script.module.metahandler/lib/metahandler/__init__.py
 copy script.module.t0mm0.common/lib/t0mm0/common/__init__.py => 
script.module.metahandler/lib/metahandler/common.py (64%)
 create mode 100644 script.module.metahandler/lib/metahandler/metacontainers.py
 create mode 100644 script.module.metahandler/lib/metahandler/metahandlers.py
 create mode 100644 script.module.metahandler/lib/metahandler/thetvdbapi.py
 create mode 100644 script.module.metahandler/resources/settings.xml


hooks/post-receive
-- 
Scripts

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to