The branch, gotham has been updated
       via  2455e77372c4e02331b0f9233b293a425bca6d87 (commit)
      from  9fb019d6dba899d017f9b4d5e9bb3e1253402d9f (commit)

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

commit 2455e77372c4e02331b0f9233b293a425bca6d87
Author: Martijn Kaijser <mcm.kaij...@gmail.com>
Date:   Tue Jun 3 18:11:58 2014 +0200

    [service.subtitles.subtitles.gr] 1.1.0

diff --git a/service.subtitles.subtitles.gr/README.md 
b/service.subtitles.subtitles.gr/README.md
index e996d56..585baef 100644
--- a/service.subtitles.subtitles.gr/README.md
+++ b/service.subtitles.subtitles.gr/README.md
@@ -4,7 +4,7 @@ Subtitles.gr XBMC Addon
 
 About
 -----
-Search and download subtitles from subtitles.gr
+Search and download subtitles from subtitles.gr, xsubs.tv and subz.blog-spot.gr
 
 
 License
diff --git a/service.subtitles.subtitles.gr/addon.xml 
b/service.subtitles.subtitles.gr/addon.xml
index bfb01e0..b206c5a 100644
--- a/service.subtitles.subtitles.gr/addon.xml
+++ b/service.subtitles.subtitles.gr/addon.xml
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="service.subtitles.subtitles.gr" name="Subtitles.gr" version="1.0.0" 
provider-name="lambda">
+<addon id="service.subtitles.subtitles.gr" name="Subtitles.gr" version="1.1.0" 
provider-name="lambda">
        <requires>
                <import addon="xbmc.python" version="2.14.0"/>
-               <import addon="script.common.plugin.cache" version="0.9.1"/>
+               <import addon="script.module.parsedom" version="0.9.1"/>
                <import addon="script.module.metahandler"/>
                <import addon="script.module.urlresolver"/>
        </requires>
@@ -10,9 +10,9 @@
        </extension>
        <extension point="xbmc.addon.metadata">
                <summary lang="en">Subtitles.gr</summary>
-               <description lang="en">Search and download subtitles from 
subtitles.gr</description>
+               <description lang="en">Search and download subtitles from 
subtitles.gr, xsubs.tv and subz.blog-spot.gr</description>
                <disclaimer lang="en">This service is only for Greek 
subtitles</disclaimer>
-               <description lang="el">Εύρεση και λήψη υ
ποτίτλων από το subtitles.gr</description>
+               <description lang="el">Εύρεση και λήψη υ
ποτίτλων από τα subtitles.gr, xsubs.tv και 
subz.blog-spot.gr</description>
                <disclaimer lang="el">Υπηρεσία μόνο 
ελληνικών υποτίτλων</disclaimer>
                <license>GNU GENERAL PUBLIC LICENSE. Version 3, 29 June 
2007</license>
                
<source>https://github.com/lambda81/service.subtitles.subtitles.gr</source>
diff --git a/service.subtitles.subtitles.gr/changelog.txt 
b/service.subtitles.subtitles.gr/changelog.txt
index f236ffa..1b8f953 100644
--- a/service.subtitles.subtitles.gr/changelog.txt
+++ b/service.subtitles.subtitles.gr/changelog.txt
@@ -1,4 +1,12 @@
 ------------------------
+Subtitles.gr v1.1.0 (3-Jun-14)
+------------------------
+
+- Added support for subz.blog-spot.gr.
+- Added support for xsubs.tv.
+
+
+------------------------
 Subtitles.gr v1.0.0 (12-Mar-14)
 ------------------------
 
diff --git a/service.subtitles.subtitles.gr/service.py 
b/service.subtitles.subtitles.gr/service.py
index 2811af0..0cc0741 100644
--- a/service.subtitles.subtitles.gr/service.py
+++ b/service.subtitles.subtitles.gr/service.py
@@ -18,7 +18,7 @@
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 '''
 
-import urllib,urllib2,re,os,zipfile,StringIO,shutil,unicodedata,time
+import urllib,urllib2,re,os,threading,zipfile,StringIO,shutil,unicodedata,time
 import xbmc,xbmcplugin,xbmcgui,xbmcaddon,xbmcvfs
 try:    import CommonFunctions
 except: import commonfunctionsdummy as CommonFunctions
@@ -65,31 +65,29 @@ class getUrl(object):
             response.close()
         self.result = result
 
+class Thread(threading.Thread):
+    def __init__(self, target, *args):
+        self._target = target
+        self._args = args
+        threading.Thread.__init__(self)
+    def run(self):
+        self._target(*self._args)
+
 class getRating(object):
     def __init__(self, downloads):
         try: rating = int(downloads)
         except: rating = 0
 
-        if (rating < 50):
+        if (rating < 100):
             rating = 1
-        elif (rating >= 50 and rating < 100):
+        elif (rating >= 100 and rating < 200):
             rating = 2
-        elif (rating >= 100 and rating < 150):
+        elif (rating >= 200 and rating < 300):
             rating = 3
-        elif (rating >= 150 and rating < 200):
+        elif (rating >= 300 and rating < 400):
             rating = 4
-        elif (rating >= 200 and rating < 250):
+        elif (rating >= 400):
             rating = 5
-        elif (rating >= 250 and rating < 300):
-            rating = 6
-        elif (rating >= 300 and rating < 350):
-            rating = 7
-        elif (rating >= 350 and rating < 400):
-            rating = 8
-        elif (rating >= 400 and rating < 450):
-            rating = 9
-        elif (rating >= 450):
-            rating = 10
 
         self.result = rating
 
@@ -109,10 +107,12 @@ class main:
         except:     return
         try:        langs = urllib.unquote_plus(params["languages"])
         except:     langs = None
-        try:        name = urllib.unquote_plus(params["name"])
-        except:     name = None
         try:        url = urllib.unquote_plus(params["url"])
         except:     url = None
+        try:        source = urllib.unquote_plus(params["source"])
+        except:     source = None
+        try:        name = urllib.unquote_plus(params["name"])
+        except:     name = None
         try:        query = urllib.unquote_plus(params["searchstring"])
         except:     query = None
 
@@ -124,7 +124,7 @@ class main:
 
         if action == 'search':                    actions().search()
         elif action == 'manualsearch':            actions().search(query)
-        elif action == 'download':                actions().download(url, name)
+        elif action == 'download':                actions().download(url, 
source, name)
 
         xbmcplugin.endOfDirectory(int(sys.argv[1]))
         return
@@ -158,8 +158,8 @@ class actions:
 
         for i in subtitleList:
             try:
-                name, url, rating = i['name'], i['url'], i['rating']
-                u = '%s?action=download&url=%s&name=%s' % (sys.argv[0], url, 
name)
+                name, url, source, rating = i['name'], i['url'], i['source'], 
i['rating']
+                u = '%s?action=download&url=%s&source=%s&name=%s' % 
(sys.argv[0], urllib.quote_plus(url), urllib.quote_plus(source), 
urllib.quote_plus(name))
                 item = xbmcgui.ListItem(label='Greek', label2=name, 
iconImage=str(rating), thumbnailImage='el')
                 item.setProperty("sync",  'false')
                 item.setProperty("hearing_imp", 'false')
@@ -167,8 +167,8 @@ class actions:
             except:
                 pass
 
-    def download(self, url, name):
-        subtitle = subtitles().download(url, name)
+    def download(self, url, source, name):
+        subtitle = download().run(url, source, name)
         if subtitle == None: return
         item = xbmcgui.ListItem(label=subtitle)
         
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=subtitle,listitem=item,isFolder=False)
@@ -178,8 +178,106 @@ class subtitles:
         self.list = []
 
     def get(self, query):
+        self.query = query
+
+        threads = []
+        threads.append(Thread(self.xsubstv))
+        threads.append(Thread(self.subztv))
+        threads.append(Thread(self.subtitlesgr))
+        [i.start() for i in threads]
+        [i.join() for i in threads]
+
+        filter = []
+        filter += [i for i in self.list if i['source'] == 'xsubstv']
+        filter += [i for i in self.list if i['source'] == 'subztv']
+        filter += [i for i in self.list if i['source'] == 'subtitlesgr']
+        self.list = filter
+
+        return self.list
+
+    def xsubstv(self):
         try:
+            url = 'http://www.xsubs.tv/series/all.xml'
+            q = re.compile(r"(.*) S(\d+)E(\d+)", 
re.IGNORECASE).findall(self.query)[0]
+
+            result = getUrl(url).result
+            url = re.compile('(<series .+?</series>)').findall(result)
+            url = [i for i in url if 
re.sub('\n|(A|a|The|the)\s|\s(|[(])(UK|US|AU|A|a|The|the)(|[)])$|([[]|[(])\d{4}([]]|[)])|\s(vs|v[.])\s|(:|;|-|"|,|\'|\.|\?)|\s',
 '', common.parseDOM(i, "series")[0]).lower() == 
re.sub('\n|(A|a|The|the)\s|\s(|[(])(UK|US|AU|A|a|The|the)(|[)])$|([[]|[(])\d{4}([]]|[)])|\s(vs|v[.])\s|(:|;|-|"|,|\'|\.|\?)|\s',
 '', q[0]).lower()][0]
+            show = common.parseDOM(url, "series")[0]
+            srsid = common.parseDOM(url, "series", ret="srsid")[0]
+            url = 'http://www.xsubs.tv/series/%s/main.xml' % srsid
+
+            result = getUrl(url).result
+            ssnid = common.parseDOM(result, "series_group", ret="ssnid", attrs 
= { "ssnnum": '%01d' % int(q[1]) })[0]
+            url = 'http://www.xsubs.tv/series/%s/%s.xml' % (srsid, ssnid)
+
+            result = getUrl(url).result
+            result = re.compile('(.+?)<etitle number="%02d"' % 
int(q[2])).findall(result)[0]
+            result = result.split('</etitle>')[-1]
+            subtitles = re.compile('(<sr .+?</sr>)').findall(result)
+        except:
+            return
+
+        for subtitle in subtitles:
+            try:
+                p = common.parseDOM(subtitle, "sr", ret="published_on")[0]
+                if p == '': raise Exception()
+
+                name = common.parseDOM(subtitle, "sr")[0]
+                name = name.rsplit('<hits>', 1)[0]
+                name = re.sub('</.+?><.+?>|<.+?>', ' ', name).strip()
+                name = '[xsubs.tv] %s S%02dE%02d %s' % (show, int(q[1]), 
int(q[2]), name)
+                name = common.replaceHTMLCodes(name)
+                name = name.encode('utf-8')
+
+                url = common.parseDOM(subtitle, "sr", ret="rlsid")[0]
+                url = 'http://www.xsubs.tv/xthru/getsub/%s' % url
+                url = common.replaceHTMLCodes(url)
+                url = url.encode('utf-8')
+
+                self.list.append({'name': name, 'url': url, 'source': 
'xsubstv', 'rating': 5})
+            except:
+                pass
+
+    def subztv(self):
+        try:
+            q = re.compile(r"(.*) S(\d+)E(\d+)", 
re.IGNORECASE).findall(self.query)[0]
+            query = q[0] + ' Season ' + '%02d' % int(q[1]) + ' Episode ' + 
'%02d' % int(q[2])
+
             query = ' '.join(urllib.unquote_plus(re.sub('%\w\w', ' ', 
urllib.quote_plus(query))).split())
+            url = 'http://subz.blog-spot.gr/?wpdmtask=get_downloads&search=%s' 
% urllib.quote_plus(query)
+
+            result = getUrl(url).result
+            url = common.parseDOM(result, "a", ret="href")
+            url = [i for i in url if '-season-%02d-' % int(q[1]) in i 
and'-episode-%02d-' % int(q[2]) in i][0]
+
+            result = getUrl(url).result
+            result = common.parseDOM(result, "table", attrs = { "class": 
"wpdm-filelist.+?" })[0]
+            subtitles = common.parseDOM(result, "tr")
+        except:
+            return
+
+        for subtitle in subtitles:
+            try:
+                name = common.parseDOM(subtitle, "td")[0]
+                if name == 'English' or name.endswith('.rar'): raise 
Exception()
+                elif name.endswith('.srt'): name = name.rsplit('.srt', 1)[0]
+                elif name.endswith('.zip'): name = name.rsplit('.zip', 1)[0]
+                name = '[subz.tv] %s' % name
+                name = common.replaceHTMLCodes(name)
+                name = name.encode('utf-8')
+
+                url = common.parseDOM(subtitle, "a", ret="href")[0]
+                url = common.replaceHTMLCodes(url)
+                url = url.encode('utf-8')
+
+                self.list.append({'name': name, 'url': url, 'source': 
'subztv', 'rating': 5})
+            except:
+                pass
+
+    def subtitlesgr(self):
+        try:
+            query = ' '.join(urllib.unquote_plus(re.sub('%\w\w', ' ', 
urllib.quote_plus(self.query))).split())
             url = 
'http://www.subtitles.gr/search.php?name=%s&sort=downloads+desc' % 
urllib.quote_plus(query)
 
             result = getUrl(url).result
@@ -192,7 +290,7 @@ class subtitles:
             try:
                 try: uploader = common.parseDOM(subtitle, "a", attrs = { 
"class": "link_from" })[0]
                 except: uploader = 'other'
-                if (uploader == 'ÅñãáóôÞñé Õðïôßôëùí' or uploader == 
'subs4series'): raise Exception()
+                if (uploader == 'ÅñãáóôÞñé Õðïôßôëùí'.decode('iso-8859-7') or 
uploader == 'subs4series'): raise Exception()
                 elif uploader == 'movieplace': uploader = 'GreekSubtitles'
                 elif uploader == '': uploader = 'other'
 
@@ -207,24 +305,88 @@ class subtitles:
                 name = name.encode('utf-8')
 
                 url = common.parseDOM(subtitle, "a", ret="href", attrs = { 
"onclick": "runme.+?" })[0]
+                url = url.split('"')[0]
                 url = common.replaceHTMLCodes(url)
                 url = url.encode('utf-8')
 
                 rating = getRating(downloads).result
 
-                self.list.append({'name': name, 'url': url, 'rating': rating})
+                self.list.append({'name': name, 'url': url, 'source': 
'subtitlesgr', 'rating': rating})
             except:
                 pass
 
-        return self.list
+class download:
+    def run(self, url, source, name):
+        try: shutil.rmtree(tempData)
+        except: pass
+        try: os.makedirs(tempData)
+        except: pass
+
+        if source == 'xsubstv':
+            subtitle = self.xsubstv(url)
+        elif source == 'subztv':
+            subtitle = self.subztv(url)
+        elif source == 'subtitlesgr':
+            subtitle = self.subtitlesgr(url)
 
-    def download(self, url, name):
+        if not subtitle == None:
+            return subtitle
+
+    def xsubstv(self, url):
         try:
+            request = urllib2.Request(url)
+            request.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; 
WOW64; rv:6.0) Gecko/20100101 Firefox/6.0')
+            response = urllib2.urlopen(request, timeout=10)
+            read = response.read()
+            response.close()
+
+            subtitle = response.info()["Content-Disposition"]
+            subtitle = re.compile('"(.+?)"').findall(subtitle)[0]
+
+            if subtitle.endswith('.srt'):
+                subtitle = os.path.join(tempData, subtitle)
+                file = open(subtitle, 'wb')
+                file.write(read)
+                file.close()
+                return subtitle
+        except:
             try: shutil.rmtree(tempData)
             except: pass
-            try: os.makedirs(tempData)
+
+    def subztv(self, url):
+        try:
+            request = urllib2.Request(url)
+            request.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; 
WOW64; rv:6.0) Gecko/20100101 Firefox/6.0')
+            response = urllib2.urlopen(request, timeout=10)
+            read = response.read()
+            response.close()
+
+            subtitle = response.info()["Content-Disposition"]
+            subtitle = re.compile('"(.+?)"').findall(subtitle)[0]
+
+            if subtitle.endswith('.srt'):
+                subtitle = os.path.join(tempData, subtitle)
+                file = open(subtitle, 'wb')
+                file.write(read)
+                file.close()
+                return subtitle
+
+            elif subtitle.endswith('.zip'):
+                zip = zipfile.ZipFile(StringIO.StringIO(read))
+                files = zip.namelist()
+                srt = [i for i in files if any(i.endswith(x) for x in ['.srt', 
'.sub'])]
+                subtitle = os.path.join(tempData,os.path.basename(srt[0]))
+                read = zip.open(srt[0]).read()
+                file = open(subtitle, 'wb')
+                file.write(read)
+                file.close()
+                return subtitle
+        except:
+            try: shutil.rmtree(tempData)
             except: pass
 
+    def subtitlesgr(self, url):
+        try:
             url = re.findall('/(\d+)/', url + '/', re.I)[-1]
             url = 'http://www.findsubtitles.eu/getp.php?id=%s' % url
             url = getUrl(url, output='geturl').result
@@ -255,7 +417,6 @@ class subtitles:
                 subtitle = [i for i in files if any(i.endswith(x) for x in 
['.srt', '.sub'])][0]
                 subtitle = os.path.join(tempData,subtitle)
                 return subtitle
-
         except:
             try: shutil.rmtree(tempData)
             except: pass

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

Summary of changes:
 service.subtitles.subtitles.gr/README.md     |    2 +-
 service.subtitles.subtitles.gr/addon.xml     |    8 +-
 service.subtitles.subtitles.gr/changelog.txt |    8 +
 service.subtitles.subtitles.gr/service.py    |  219 ++++++++++++++++++++++----
 4 files changed, 203 insertions(+), 34 deletions(-)


hooks/post-receive
-- 
Scripts

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their 
applications. Written by three acclaimed leaders in the field, 
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/NeoTech
_______________________________________________
Xbmc-addons mailing list
Xbmc-addons@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to