The branch, gotham has been updated
       via  065e95636c22282f72d4009dffb2125f2ddefc22 (commit)
      from  d343e895fc198ff708719de99bd1f4310c2d4c44 (commit)

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

commit 065e95636c22282f72d4009dffb2125f2ddefc22
Author: Martijn Kaijser <[email protected]>
Date:   Sat Feb 1 14:25:41 2014 +0100

    [service.subtitles.subscenter] 3.0.0

diff --git a/service.subtitles.subscenter/addon.xml 
b/service.subtitles.subscenter/addon.xml
index 8774db6..1ca2ed4 100644
--- a/service.subtitles.subscenter/addon.xml
+++ b/service.subtitles.subscenter/addon.xml
@@ -1,17 +1,18 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <addon id="service.subtitles.subscenter"
-       name="SubsCenter.org"
-       version="1.5.0"
-       provider-name="sagiben">
+       name="Subscenter.org"
+       version="3.0.0"
+       provider-name="CaTz">
   <requires>
     <import addon="xbmc.python" version="2.1.0"/>
+    <import addon="xbmc.json" version="6.0.0"/>
   </requires>
   <extension point="xbmc.subtitle.module"
              library="service.py" />
   <extension point="xbmc.addon.metadata">
-    <summary lang="en">SubsCenter.org</summary>
-    <description lang="en">SubsCenter Subtitle Service 
http://www.subscenter.org </description>
-    <source>https://github.com/sagiben/service.subtitles.subscenter</source>
+    <summary lang="en">Subscenter.org</summary>
+    <description lang="en">Search and Download subtitles from subscenter.org. 
Contributors: rabak, Ori Varon, sagiben</description>
+    <source>https://github.com/CaTzil/service.subtitles.subscenter</source>
     <email></email>
     <license>GNU GENERAL PUBLIC LICENSE. Version 2, June 1991</license>
   </extension>
diff --git a/service.subtitles.subscenter/changelog.txt 
b/service.subtitles.subscenter/changelog.txt
index 57044d8..cb00a65 100644
--- a/service.subtitles.subscenter/changelog.txt
+++ b/service.subtitles.subscenter/changelog.txt
@@ -1,3 +1,13 @@
+3.0
+- Migration to Gotham standards
+- Threshold of 2 pages in search result
+- Using native JSON parser
+- Sort the subtitle list by rating in context of full list, (so if there was 
any movie that is not related, 
+       but still exists in the search results, the full list will have the 
most relevant subtitles at the top) 
+
+2.5 
+- support for Subscenter new website + workaround (10x to CaTz)
+
 1.5.0
 - Porting service to Gotham's format, 
   code is based on Ori Varon's addon from previous versions
diff --git a/service.subtitles.subscenter/icon.png 
b/service.subtitles.subscenter/icon.png
index ea6b8c7..db3f154 100644
Binary files a/service.subtitles.subscenter/icon.png and 
b/service.subtitles.subscenter/icon.png differ
diff --git a/service.subtitles.subscenter/service.py 
b/service.subtitles.subscenter/service.py
index f69af76..df1b119 100644
--- a/service.subtitles.subscenter/service.py
+++ b/service.subtitles.subscenter/service.py
@@ -1,10 +1,12 @@
-# -*- coding: utf-8 -*- 
+# -*- coding: utf-8 -*-
 
 import os
 import re
 import sys
-import xbmc
 import urllib
+import urllib2
+import json
+import xbmc
 import xbmcvfs
 import xbmcaddon
 import xbmcgui
@@ -13,283 +15,322 @@ import shutil
 import unicodedata
 
 __addon__ = xbmcaddon.Addon()
-__author__     = __addon__.getAddonInfo('author')
-__scriptid__   = __addon__.getAddonInfo('id')
+__author__ = __addon__.getAddonInfo('author')
+__scriptid__ = __addon__.getAddonInfo('id')
 __scriptname__ = __addon__.getAddonInfo('name')
-__version__    = __addon__.getAddonInfo('version')
-__language__   = __addon__.getLocalizedString
-
-__cwd__        = xbmc.translatePath( __addon__.getAddonInfo('path') 
).decode("utf-8")
-__profile__    = xbmc.translatePath( __addon__.getAddonInfo('profile') 
).decode("utf-8")
-__resource__   = xbmc.translatePath( os.path.join( __cwd__, 'resources', 'lib' 
) ).decode("utf-8")
-__temp__       = xbmc.translatePath( os.path.join( __profile__, 'temp') 
).decode("utf-8")
+__version__ = __addon__.getAddonInfo('version')
+__language__ = __addon__.getLocalizedString
 
-sys.path.append (__resource__)
+__cwd__ = xbmc.translatePath(__addon__.getAddonInfo('path')).decode("utf-8")
+__profile__ = 
xbmc.translatePath(__addon__.getAddonInfo('profile')).decode("utf-8")
+__resource__ = xbmc.translatePath(os.path.join(__cwd__, 'resources', 
'lib')).decode("utf-8")
+__temp__ = xbmc.translatePath(os.path.join(__profile__, 
'temp')).decode("utf-8")
 
+sys.path.append(__resource__)
 
 BASE_URL = "http://www.subscenter.org";
-
+releases_types = ['2011', '2009', '2012', '2010', '2013', '2014', 'web-dl', 
'webrip', '480p', '720p', '1080p', 'h264',
+                  'x264', 'xvid', 'ac3', 'aac', 'hdtv', 'dvdscr', 'dvdrip', 
'ac3', 'brrip', 'bluray', 'dd51', 'divx',
+                  'proper', 'repack', 'pdtv', 'rerip', 'dts']
 
#===============================================================================
 # Regular expression patterns
 
#===============================================================================
 MULTI_RESULTS_PAGE_PATTERN = u"עמוד (?P<curr_page>\d*) \( סך הכל: 
(?P<total_pages>\d*) \)"
-SEARCH_RESULTS_PATTERN = "<div class=\"generalWindowRight\">.*?<a 
href=\"(?P<sid>.*?)\">"
+MOVIES_SEARCH_RESULTS_PATTERN = '<div class="generalWindowRight">.*?<a 
href="[^"]+(/he/subtitle/movie/.*?)">.*?<div class="generalWindowBottom">'
+TV_SEARCH_RESULTS_PATTERN = '<div class="generalWindowRight">.*?<a 
href="[^"]+(/he/subtitle/series/.*?)">.*?<div class="generalWindowBottom">'
 
 
#===============================================================================
 # Private utility functions
 
#===============================================================================
 def normalizeString(str):
-  return unicodedata.normalize(
-         'NFKD', unicode(unicode(str, 'utf-8'))
-         ).encode('ascii','ignore')
+    return unicodedata.normalize(
+        'NFKD', unicode(unicode(str, 'utf-8'))
+    ).encode('ascii', 'ignore')
+
 
 def log(module, msg):
-    xbmc.log((u"### [%s] - %s" % 
(module,msg,)).encode('utf-8'),level=xbmc.LOGDEBUG ) 
+    xbmc.log((u"### [%s] - %s" % (module, msg,)).encode('utf-8'), 
level=xbmc.LOGDEBUG)
 
 # Returns the content of the given URL. Used for both html and subtitle files.
 # Based on Titlovi's service.py
 def getURL(url):
     # Fix URLs with spaces in them
-    url = url.replace(" ","%20")
+    url = url.replace(" ", "%20")
     content = None
-    log( __name__ ,"Getting url: %s" % (url))
+    log(__scriptname__, "Getting url: %s" % (url))
     try:
-        response = urllib.urlopen(url)
-        content = response.read()
+        req = urllib2.Request(url)
+        req.add_header('User-Agent',
+                       'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) 
Gecko/20100101 Firefox/26.0')
+        response = urllib2.urlopen(req)
+        content = None if response.code != 200 else response.read()
+        response.close()
     except Exception as e:
-        log( __name__ ,"Failed to get url: %s\n%s" % (url, e))
-    # Second parameter is the filename
+        log(__scriptname__, "Failed to get url: %s\n%s" % (url, e))
+        # Second parameter is the filename
     return content
 
-def getURLfilename(url):
+
+def get_url_filename(url):
     # Fix URLs with spaces in them
-    url = url.replace(" ","%20")
+    url = url.replace(" ", "%20")
     filename = None
-    log( __name__ ,"Getting url: %s" % (url))
+    log(__scriptname__, "Getting url: %s" % (url))
     try:
+        seperator = "filename="
         response = urllib.urlopen(url)
         filename = response.headers['Content-Disposition']
-        filename = filename[filename.index("filename="):]
+        filename = filename[filename.index(seperator) + len(seperator):]
     except Exception as e:
-        log( __name__ ,"Failed to get url: %s\n%s" % (url, e))
-    # Second parameter is the filename
+        log(__scriptname__, "Failed to get url: %s\n%s" % (url, e))
+        # Second parameter is the filename
     return filename
 
+
+def get_rating(subsfile, videofile):
+    x = 0
+    rating = 0
+    log(__scriptname__, "# Comparing Releases:\n %s [subtitle-rls] \n %s 
[filename-rls]" % (subsfile, videofile))
+    videofile = "".join(videofile.split('.')[:-1]).lower()
+    subsfile = subsfile.lower().replace('.', '')
+    videofile = videofile.replace('.', '')
+    for release_type in releases_types:
+        if release_type in videofile:
+            x += 1
+            if (release_type in subsfile): rating += 1
+    if x: rating = (rating / float(x)) * 4
+    # Compare group name
+    if videofile.split('-')[-1] == subsfile.split('-')[-1]:
+        rating += 1
+    # Group name didn't match
+    # try to see if group name is in the beginning (less info on file less 
weight)
+    elif videofile.split('-')[0] == subsfile.split('-')[-1]:
+        rating += 0.5
+    if rating > 0:
+        rating *= 2
+    log(__scriptname__, "# Result is: %f" % rating)
+    return round(rating)
+
 # The function receives a subtitles page id number, a list of user selected
 # languages and the current subtitles list and adds all found subtitles 
matching
 # the language selection to the subtitles list.
-def getAllSubtitles(subtitlePageID,languageList):
-
-    subtitlesList = []
+def prepare_subtitle_list(subtitle_page_uri, language_list, file_name):
+    subtitles_list = []
     # Retrieve the subtitles page (html)
     try:
-        subtitlePage = getURL(BASE_URL + subtitlePageID)
+        subtitlePage = getURL(BASE_URL + subtitle_page_uri)
     except:
         # Didn't find the page - no such episode?
         return
+
     # Didn't find the page - no such episode?
-    if (not subtitlePage):
+    if not subtitlePage:
+        return
+
+    log(__scriptname__, "data=%s" % (subtitlePage))
+    found_subtitles = json.loads(subtitlePage, encoding="utf-8")
+
+    for language in found_subtitles.keys():
+        if xbmc.convertLanguage(language, xbmc.ISO_639_2) in language_list:
+            for translator in found_subtitles[language]:
+                for quality in found_subtitles[language][translator]:
+                    for rating in 
found_subtitles[language][translator][quality]:
+                        current = 
found_subtitles[language][translator][quality][rating]
+                        title = current["subtitle_version"]
+                        subtitle_rate = get_rating(title, file_name)
+                        subtitles_list.append(
+                            {'lang_index': 
language_list.index(xbmc.convertLanguage(language, xbmc.ISO_639_2)),
+                             'filename': title,
+                             'link': current["key"],
+                             'language_name': xbmc.convertLanguage(language, 
xbmc.ENGLISH_NAME),
+                             'language_flag': language,
+                             'ID': current["id"],
+                             'rating': str(subtitle_rate),
+                             'sync': subtitle_rate >= 8,
+                             'hearing_imp': current["hearing_impaired"] > 0
+                            })
+    return subtitles_list
+
+
+def search(item):
+    if item['tvshow']:
+        searchString = item['tvshow'].replace(" ", "+")
+    else:
+        searchString = item['title'].replace(" ", "+")
+    log(__scriptname__, "Search string = %s" % (searchString.lower()))
+
+    # Retrieve the search results (html)
+    searchResults = getURL(BASE_URL + "/he/subtitle/search/?q=" + 
searchString.lower())
+    # Search most likely timed out, no results
+    if not searchResults:
         return
-    # Find subtitles dictionary declaration on page
-    tempStart = subtitlePage.index("subtitles_groups = ")
-    # Look for the following line break
-    tempEnd = subtitlePage.index("\n",subtitlePage.index("subtitles_groups = 
"))
-    toExec = "foundSubtitles = "+subtitlePage[tempStart+len("subtitles_groups 
= "):tempEnd]
-    # Remove junk at the end of the line
-    toExec = toExec[:toExec.rfind("}")+1]
-    # Replace "null" with "None"
-    toExec = toExec.replace("null","None")
-    exec(toExec)
-    for language in foundSubtitles.keys():
-      if (xbmc.convertLanguage(language,xbmc.ISO_639_2) in languageList): 
-          for translator in foundSubtitles[language]:
-              for quality in foundSubtitles[language][translator]:
-                  for rating in foundSubtitles[language][translator][quality]:
-                    subtitlesList.append({'lang_index' : 
languageList.index(xbmc.convertLanguage(language,xbmc.ISO_639_2)),
-                                          'filename' : 
foundSubtitles[language][translator][quality][rating]["subtitle_version"],
-                                          'link' : 
foundSubtitles[language][translator][quality][rating]["key"],
-                                          'language_name' : 
xbmc.convertLanguage(language,xbmc.ENGLISH_NAME),
-                                          'language_flag' : language,
-                                          'ID': 
foundSubtitles[language][translator][quality][rating]["id"],
-                                          'rating' : rating,
-                                          'sync' : 
foundSubtitles[language][translator][quality][rating]["is_sync"],
-                                          'hearing_imp' : 
foundSubtitles[language][translator][quality][rating]["hearing_impaired"],
-                                          })
-    return subtitlesList
-
-
-def Search(item):
-
-  if item['tvshow']:
-    searchString = item['tvshow'].replace(" ","+")
-  else:
-    searchString = item['title'].replace(" ","+")
-  log( __name__ ,"Search string = %s" % (searchString.lower()))
-  
-  # Retrieve the search results (html)
-  searchResults = getURL(BASE_URL + "/he/subtitle/search/?q=" + 
searchString.lower())
-  # Search most likely timed out, no results
-  if (not searchResults):
-      return
-
-  # Look for subtitles page links
-  subtitleIDs = re.findall(SEARCH_RESULTS_PATTERN,searchResults,re.DOTALL)
-  # Look for more subtitle pages
-  pages = re.search(MULTI_RESULTS_PAGE_PATTERN,unicode(searchResults,"utf-8"))
-  # If we found them look inside for subtitles page links
-  if (pages):
-      while (not (int(pages.group("curr_page"))) == 
int(pages.group("total_pages"))):
-          searchResults = getURL(BASE_URL + 
"/he/subtitle/search/?q="+searchString.lower()+"&page="+str(int(pages.group("curr_page"))+1))
-          tempSIDs = re.findall(SEARCH_RESULTS_PATTERN,searchResults,re.DOTALL)
-          for sid in tempSIDs:
-              subtitleIDs.append(sid)
-          pages = 
re.search(MULTI_RESULTS_PAGE_PATTERN,unicode(searchResults,"utf-8"))
-  # Uniqify the list
-  subtitleIDs=list(set(subtitleIDs))
-  # If looking for tvshos try to append season and episode to url
-  if item['tvshow']:
-      for i in range(len(subtitleIDs)):
-          if (subtitleIDs[i].find("series") > 0):
-              subtitleIDs[i] += "/"+season+"/"+episode+"/"
-
-  for sid in subtitleIDs:
-      subtitles_list = getAllSubtitles(sid, item['3let_language'])
-      if subtitles_list:
+
+    # Look for subtitles page links
+    if item['tvshow']:
+        subtitleIDs = re.findall(TV_SEARCH_RESULTS_PATTERN, searchResults, 
re.DOTALL)
+    else:
+        subtitleIDs = re.findall(MOVIES_SEARCH_RESULTS_PATTERN, searchResults, 
re.DOTALL)
+        # Look for more subtitle pages
+
+    pages = re.search(MULTI_RESULTS_PAGE_PATTERN, unicode(searchResults, 
"utf-8"))
+    # If we found them look inside for subtitles page links
+    if (pages):
+        # Limit to only 2 pages
+        while (int(pages.group("curr_page")) <= 2):
+            searchResults = getURL(BASE_URL + "/he/subtitle/search/?q=" + 
searchString.lower() + "&page=" + str(
+                int(pages.group("curr_page")) + 1))
+
+            if item['tvshow']:
+                tempSIDs = re.findall(TV_SEARCH_RESULTS_PATTERN, 
searchResults, re.DOTALL)
+            else:
+                tempSIDs = re.findall(MOVIES_SEARCH_RESULTS_PATTERN, 
searchResults, re.DOTALL)
+
+            for sid in tempSIDs:
+                subtitleIDs.append(sid)
+            pages = re.search(MULTI_RESULTS_PAGE_PATTERN, 
unicode(searchResults, "utf-8"))
+
+    # Uniqify the list
+    subtitleIDs = list(set(subtitleIDs))
+    # If looking for tvshows try to append season and episode to url
+    for i in range(len(subtitleIDs)):
+        subtitleIDs[i] = subtitleIDs[i].replace("/subtitle/", 
"/cinemast/data/")
+        if item['tvshow']:
+            subtitleIDs[i] = subtitleIDs[i].replace("/series/", "/series/sb/")
+            subtitleIDs[i] += item["season"] + "/" + item["episode"] + "/"
+        else:
+            subtitleIDs[i] = subtitleIDs[i].replace("/movie/", "/movie/sb/")
+
+    file_name = os.path.basename(item['file_original_path']);
+    subtitles_list = []
+    for sid in subtitleIDs:
+        subtitles_list += prepare_subtitle_list(sid, item['3let_language'], 
file_name)
+
+    if subtitles_list:
+        # Sort the subtitles
+        subtitles_list = sorted(subtitles_list, key=lambda x: 
int(float(x['rating'])), reverse=True)
         for it in subtitles_list:
-          listitem = xbmcgui.ListItem(label=it["language_name"],
-                                      label2=it["filename"],
-                                      iconImage=it["rating"],
-                                      thumbnailImage=it["language_flag"]
-                                      )
-          if it["sync"]:
-            listitem.setProperty( "sync", "true" )
-          else:
-            listitem.setProperty( "sync", "false" )
-            
-          if it.get("hearing_imp", False):
-            listitem.setProperty( "hearing_imp", "true" )
-          else:
-            listitem.setProperty( "hearing_imp", "false" )
-      
-        url = "plugin://%s/?action=download&link=%s&ID=%s&filename=%s" % 
(__scriptid__, it["link"], it["ID"],it["filename"])      
-        
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=listitem,isFolder=False)
-   
-
-
-def Download(id,key,filename, stack=False):
-  subtitle_list = []
-  ## Cleanup temp dir, we recomend you download/unzip your subs in temp folder 
and
-  ## pass that to XBMC to copy and activate
-  if xbmcvfs.exists(__temp__):
-    shutil.rmtree(__temp__)
-  xbmcvfs.mkdirs(__temp__)
-
-  url = BASE_URL + "/subtitle/download/he/" + 
str(id)+"/?v="+filename+"&key="+key
-  log( __name__ ,"Fetching subtitles using url %s" % (url))
-  # Get the intended filename (don't know if it's zip or rar)
-  archive_name = getURLfilename(url)
-  # Get the file content using geturl()
-  content = getURL(url)
-  subs_file = ""
-  if content:
-    local_tmp_file = os.path.join(__temp__, archive_name)
-    log( __name__ ,"Saving subtitles to '%s'" % (local_tmp_file))
-    try:
-      local_file_handle = open(local_tmp_file, "wb")
-      local_file_handle.write(content)
-      local_file_handle.close()
-      xbmc.sleep(500)
-    except:
-      log( __name__ ,"Failed to save subtitles to '%s'" % (local_tmp_file))
-
-  # Extract the zip file and find the new sub/srt file
-  xbmc.executebuiltin(('XBMC.Extract("%s","%s")' % 
(local_tmp_file,__temp__,)).encode('utf-8'), True)
-  for file in xbmcvfs.listdir(__temp__)[1]:
-    full_path = os.path.join(__temp__, file)
-    if (os.path.splitext(full_path)[1] in ['.srt','.sub']):
-      subtitle_list.append(full_path)
-  
-  return subtitle_list
- 
+            listitem = xbmcgui.ListItem(label=it["language_name"],
+                                        label2=it["filename"],
+                                        iconImage=it["rating"],
+                                        thumbnailImage=it["language_flag"]
+            )
+            if it["sync"]:
+                listitem.setProperty("sync", "true")
+            else:
+                listitem.setProperty("sync", "false")
+
+            if it.get("hearing_imp", False):
+                listitem.setProperty("hearing_imp", "true")
+            else:
+                listitem.setProperty("hearing_imp", "false")
+
+            url = "plugin://%s/?action=download&link=%s&ID=%s&filename=%s" % (
+                __scriptid__, it["link"], it["ID"], it["filename"])
+            xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, 
listitem=listitem, isFolder=False)
+
+
+def download(id, key, filename, stack=False):
+    subtitle_list = []
+    exts = [".srt", ".sub"]
+
+    ## Cleanup temp dir, we recomend you download/unzip your subs in temp 
folder and
+    ## pass that to XBMC to copy and activate
+    if xbmcvfs.exists(__temp__):
+        shutil.rmtree(__temp__)
+    xbmcvfs.mkdirs(__temp__)
+
+    zip = os.path.join(__temp__, "subs.zip")
+    url = BASE_URL + "/subtitle/download/he/" + str(id) + "/?v=" + filename + 
"&key=" + key
+    log(__scriptname__, "Fetching subtitles using url %s" % url)
+    f = urllib.urlopen(url)
+    with open(zip, "wb") as subFile:
+        subFile.write(f.read())
+    subFile.close()
+    xbmc.sleep(500)
+    xbmc.executebuiltin(('XBMC.Extract("%s","%s")' % (zip, 
__temp__,)).encode('utf-8'), True)
+
+    for file in xbmcvfs.listdir(__temp__)[1]:
+        full_path = os.path.join(__temp__, file)
+        if os.path.splitext(full_path)[1] in exts:
+            subtitle_list.append(full_path)
+
+    return subtitle_list
+
+
 def get_params(string=""):
-  param=[]
-  if string == "":
-    paramstring=sys.argv[2]
-  else:
-    paramstring=string 
-  if len(paramstring)>=2:
-    params=paramstring
-    cleanedparams=params.replace('?','')
-    if (params[len(params)-1]=='/'):
-      params=params[0:len(params)-2]
-    pairsofparams=cleanedparams.split('&')
-    param={}
-    for i in range(len(pairsofparams)):
-      splitparams={}
-      splitparams=pairsofparams[i].split('=')
-      if (len(splitparams))==2:
-        param[splitparams[0]]=splitparams[1]
-                                
-  return param
+    param = []
+    if string == "":
+        paramstring = sys.argv[2]
+    else:
+        paramstring = string
+    if len(paramstring) >= 2:
+        params = paramstring
+        cleanedparams = params.replace('?', '')
+        if (params[len(params) - 1] == '/'):
+            params = params[0:len(params) - 2]
+        pairsofparams = cleanedparams.split('&')
+        param = {}
+        for i in range(len(pairsofparams)):
+            splitparams = {}
+            splitparams = pairsofparams[i].split('=')
+            if (len(splitparams)) == 2:
+                param[splitparams[0]] = splitparams[1]
+
+    return param
+
 
 params = get_params()
 
-log( __name__ ,"params: %s" % (params))
-
-if params['action'] == 'search':
-  log( __name__, "action 'search' called")
-  item = {}
-  item['temp']               = False
-  item['rar']                = False
-  item['year']               = xbmc.getInfoLabel("VideoPlayer.Year")           
                # Year
-  item['season']             = str(xbmc.getInfoLabel("VideoPlayer.Season"))    
                # Season
-  item['episode']            = str(xbmc.getInfoLabel("VideoPlayer.Episode"))   
                # Episode
-  item['tvshow']             = 
normalizeString(xbmc.getInfoLabel("VideoPlayer.TVshowtitle"))   # Show
-  item['title']              = 
normalizeString(xbmc.getInfoLabel("VideoPlayer.OriginalTitle")) # try to get 
original title
-  item['file_original_path'] = 
urllib.unquote(xbmc.Player().getPlayingFile().decode('utf-8'))  # Full path of 
a playing file
-  item['3let_language']      = []
-  
-  for lang in urllib.unquote(params['languages']).decode('utf-8').split(","):
-    item['3let_language'].append(xbmc.convertLanguage(lang,xbmc.ISO_639_2))
-  
-  if item['title'] == "":
-    log( __name__, "VideoPlayer.OriginalTitle not found")
-    item['title']  = normalizeString(xbmc.getInfoLabel("VideoPlayer.Title"))   
   # no original title, get just Title
-    
-  if item['episode'].lower().find("s") > -1:                                   
   # Check if season is "Special"
-    item['season'] = "0"                                                       
   #
-    item['episode'] = item['episode'][-1:]
-  
-  if ( item['file_original_path'].find("http") > -1 ):
-    item['temp'] = True
-
-  elif ( item['file_original_path'].find("rar://") > -1 ):
-    item['rar']  = True
-    item['file_original_path'] = 
os.path.dirname(item['file_original_path'][6:])
-
-  elif ( item['file_original_path'].find("stack://") > -1 ):
-    stackPath = item['file_original_path'].split(" , ")
-    item['file_original_path'] = stackPath[0][8:]
-    
-  Search(item)  
+log(__scriptname__, "params: %s" % (params))
+
+if params['action'] in ['search', 'manualsearch']:
+    log(__scriptname__, "action '%s' called" % (params['action']))
+    item = {}
+    item['temp'] = False
+    item['rar'] = False
+    item['year'] = xbmc.getInfoLabel("VideoPlayer.Year")                       
    # Year
+    item['season'] = str(xbmc.getInfoLabel("VideoPlayer.Season"))              
      # Season
+    item['episode'] = str(xbmc.getInfoLabel("VideoPlayer.Episode"))            
       # Episode
+    item['tvshow'] = params['searchstring'] if params['action'] == 
'manualsearch' \
+        else normalizeString(xbmc.getInfoLabel("VideoPlayer.TVshowtitle"))   # 
Show
+    item['title'] = params['searchstring'] if params['action'] == 
'manualsearch' \
+        else normalizeString(xbmc.getInfoLabel("VideoPlayer.OriginalTitle")) # 
try to get original title
+    item['file_original_path'] = urllib.unquote(
+        xbmc.Player().getPlayingFile().decode('utf-8'))  # Full path of a 
playing file
+    item['3let_language'] = []
+
+    for lang in urllib.unquote(params['languages']).decode('utf-8').split(","):
+        item['3let_language'].append(xbmc.convertLanguage(lang, 
xbmc.ISO_639_2))
+
+    if item['title'] == "":
+        log(__scriptname__, "VideoPlayer.OriginalTitle not found")
+        item['title'] = params['searchstring'] if params['action'] == 
'manualsearch' \
+            else normalizeString(xbmc.getInfoLabel("VideoPlayer.Title"))      
# no original title, get just Title
+
+    if item['episode'].lower().find("s") > -1:                                
# Check if season is "Special"
+        item['season'] = "0"
+        item['episode'] = item['episode'][-1:]
+
+    if ( item['file_original_path'].find("http") > -1 ):
+        item['temp'] = True
+
+    elif ( item['file_original_path'].find("rar://") > -1 ):
+        item['rar'] = True
+        item['file_original_path'] = 
os.path.dirname(item['file_original_path'][6:])
+
+    elif ( item['file_original_path'].find("stack://") > -1 ):
+        stackPath = item['file_original_path'].split(" , ")
+        item['file_original_path'] = stackPath[0][8:]
+
+    search(item)
+
 
 elif params['action'] == 'download':
-  ## we pickup all our arguments sent from def Search()
-  subs = Download(params["ID"],params["link"],params["filename"])
-  ## we can return more than one subtitle for multi CD versions, for now we 
are still working out how to handle that in XBMC core
-  for sub in subs:
-    listitem = xbmcgui.ListItem(label=sub)
-    
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=sub,listitem=listitem,isFolder=False)
-  
-  
-xbmcplugin.endOfDirectory(int(sys.argv[1])) ## send end of directory to XBMC
-  
-  
-  
-  
-  
-  
-  
-  
-  
-    
+    ## we pickup all our arguments sent from def search()
+    subs = download(params["ID"], params["link"], params["filename"])
+    ## we can return more than one subtitle for multi CD versions, for now we 
are still working out how to handle that in XBMC core
+    for sub in subs:
+        listitem = xbmcgui.ListItem(label=sub)
+        xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=sub, 
listitem=listitem, isFolder=False)
+
+xbmcplugin.endOfDirectory(int(sys.argv[1])) ## send end of directory to XBMC
\ No newline at end of file

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

Summary of changes:
 service.subtitles.subscenter/addon.xml     |   13 +-
 service.subtitles.subscenter/changelog.txt |   10 +
 service.subtitles.subscenter/icon.png      |  Bin 23292 -> 18035 bytes
 service.subtitles.subscenter/service.py    |  503 +++++++++++++++-------------
 4 files changed, 289 insertions(+), 237 deletions(-)


hooks/post-receive
-- 
Scripts

------------------------------------------------------------------------------
WatchGuard Dimension instantly turns raw network data into actionable 
security intelligence. It gives you real-time visual feedback on key
security issues and trends.  Skip the complicated setup - simply import
a virtual appliance and go from zero to informed in seconds.
http://pubads.g.doubleclick.net/gampad/clk?id=123612991&iu=/4140/ostg.clktrk
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to