The branch, gotham has been updated
via f03ff0347b54639f0b46b8814f565afc96b79a4a (commit)
from 5519ef7bf9f0d7ff7c61a6f5227a0caad792628d (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=f03ff0347b54639f0b46b8814f565afc96b79a4a
commit f03ff0347b54639f0b46b8814f565afc96b79a4a
Author: Martijn Kaijser <[email protected]>
Date: Mon Apr 21 18:58:54 2014 +0200
[service.subtitles.supersubtitles] 0.0.11
diff --git a/service.subtitles.supersubtitles/addon.xml
b/service.subtitles.supersubtitles/addon.xml
index a9a2a89..3eca5ef 100644
--- a/service.subtitles.supersubtitles/addon.xml
+++ b/service.subtitles.supersubtitles/addon.xml
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.subtitles.supersubtitles"
name="Super Subtitles"
- version="0.0.10"
+ version="0.0.11"
provider-name="fape">
<requires>
<import addon="xbmc.python" version="2.14.0"/>
<import addon="xbmc.addon" version="12.0.0"/>
- <import addon="script.module.requests2" version="2.2.1"/>
</requires>
<extension point="xbmc.subtitle.module"
library="service.py" />
diff --git a/service.subtitles.supersubtitles/changelog.txt
b/service.subtitles.supersubtitles/changelog.txt
index 37c13ff..082e683 100644
--- a/service.subtitles.supersubtitles/changelog.txt
+++ b/service.subtitles.supersubtitles/changelog.txt
@@ -1,3 +1,7 @@
+0.0.11
+- improve load time
+- remove heavy dependency: requests
+
0.0.10
- improve tv show title, season and episode detection
diff --git a/service.subtitles.supersubtitles/service.py
b/service.subtitles.supersubtitles/service.py
index a68de8a..51357b0 100644
--- a/service.subtitles.supersubtitles/service.py
+++ b/service.subtitles.supersubtitles/service.py
@@ -1,23 +1,29 @@
# -*- coding: utf-8 -*-
+import time
+
+start = time.time()
+
import os
import sys
-import urllib
import shutil
import unicodedata
import os.path
import re
-import requests2 as _requests
import xbmc
import xbmcvfs
import xbmcaddon
import xbmcgui
import xbmcplugin
+import json
+
+import urllib
+import urllib2
__addon__ = xbmcaddon.Addon()
-__author__ = __addon__.getAddonInfo('author')
+#__author__ = __addon__.getAddonInfo('author')
__scriptid__ = __addon__.getAddonInfo('id')
__scriptname__ = __addon__.getAddonInfo('name')
__version__ = __addon__.getAddonInfo('version')
@@ -32,22 +38,22 @@ __temp__ = xbmc.translatePath(os.path.join(__profile__,
'temp')).decode("utf-8")
BASE_URL = 'http://www.feliratok.info/index.php'
-TAGS = {
+TAGS = [
'WEB\-DL',
'PROPER',
'REPACK'
-}
+]
-QUALITIES = {
+QUALITIES = [
'HDTV',
'720p',
'1080p',
'DVDRip',
'BRRip',
'BDRip'
-}
+]
-RELEASERS = {
+RELEASERS = [
'2HD',
'AFG',
'ASAP',
@@ -62,15 +68,16 @@ RELEASERS = {
'REMARKABLE',
'ORENJI',
'TLA'
-}
+]
+
HEADERS = {'User-Agent': 'xbmc subtitle plugin'}
-ARCHIVE_EXTENSIONS = {
+ARCHIVE_EXTENSIONS = [
'.zip',
'.cbz',
'.rar',
'.cbr'
-}
+]
LANGUAGES = {
"albán": "Albanian",
@@ -141,16 +148,30 @@ def debuglog(msg):
#log(msg, xbmc.LOGNOTICE)
-def query_data(params):
- r = _requests.get(BASE_URL, params=params, headers=HEADERS)
- debuglog(r.url)
+def send_request(params):
+ url = "%s?%s" % (BASE_URL, urllib.urlencode(params))
try:
- return r.json()
- except ValueError as e:
- errorlog(e.message)
+ debuglog(url)
+ request = urllib2.Request(url, headers=HEADERS)
+ return urllib2.urlopen(request)
+ except urllib2.HTTPError as e:
+ errorlog("HTTP Error: %s, %s" % (e.code, url))
+ return None
+ except urllib2.URLError as e:
+ errorlog("URL Error %s, %s" % (e.reason, url))
return None
+def query_data(params):
+ response = send_request(params)
+ if response:
+ try:
+ return json.load(response, 'utf-8')
+ except json.JSONDecodeError as e:
+ errorlog(e.message)
+ return None
+
+
def notification(id):
xbmc.executebuiltin(u'Notification(%s,%s,%s,%s)' % (
__scriptname__,
@@ -213,6 +234,7 @@ def remove_duplications(items):
ret[item['id']] = new_item
return ret.values()
+
def search_subtitles(item):
if not item['season'] and not item['episode']:
debuglog("No season or episode info found for %s" % item['tvshow'])
@@ -269,7 +291,8 @@ def search(item):
listitem.setProperty('sync', ('false', 'true')[it['sync']])
listitem.setProperty('hearing_imp', ('false',
'true')[it.get('hearing', False)])
- qparams = {'action': 'download', 'actionsortorder':
str(index).zfill(2), 'id': it['id'], 'filename': it['filename']}
+ qparams = {'action': 'download', 'actionsortorder':
str(index).zfill(2), 'id': it['id'],
+ 'filename': it['filename']}
url = "plugin://%s/?%s" % (__scriptid__, urllib.urlencode(qparams))
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url,
listitem=listitem, isFolder=False)
@@ -293,15 +316,16 @@ def extract(archive):
def download_file(item):
localfile = os.path.join(__temp__, item['filename'].decode("utf-8"))
qparams = {'action': 'letolt', 'felirat': item['id']}
- r = _requests.get(BASE_URL, params=qparams, headers=HEADERS, stream=True)
- debuglog(r.url)
- with open(localfile, 'wb') as fd:
- for chunk in r.iter_content(chunk_size=1024):
- fd.write(chunk)
- fd.flush()
+ response = send_request(qparams)
+
+ if response:
+ with open(localfile, 'wb') as fd:
+ shutil.copyfileobj(response, fd)
+
+ return localfile
- return localfile
+ return None
def is_match(item, filename):
@@ -411,13 +435,14 @@ def get_params(string=""):
return param
+
+infolog("%s - %s" % (__scriptname__, __version__))
+debuglog("start time %s" % (time.time() - start))
+
recreate_dir(__temp__)
params = get_params()
-
-debuglog("%s - %s" % (__scriptname__ , __version__))
debuglog(params)
-
if params['action'] == 'search':
debuglog("action 'search' called")
item = {'temp': False, 'rar': False, 'stack': False, 'year':
xbmc.getInfoLabel("VideoPlayer.Year"),
@@ -427,8 +452,7 @@ if params['action'] == 'search':
for lang in urllib.unquote(params['languages']).decode('utf-8').split(","):
item['languages'].append(lang)
- if item['title'] == "":
- debuglog("VideoPlayer.OriginalTitle not found")
+ if not item['title']:
item['title'] =
normalize_string(xbmc.getInfoLabel("VideoPlayer.Title"))
setup_path(item)
item['filename'] = os.path.basename(item['file_original_path'])
@@ -449,4 +473,6 @@ elif params['action'] == 'download':
elif params['action'] == 'manualsearch':
notification(32502)
+debuglog("full time %s" % (time.time() - start))
+
xbmcplugin.endOfDirectory(int(sys.argv[1]))
-----------------------------------------------------------------------
Summary of changes:
service.subtitles.supersubtitles/addon.xml | 3 +-
service.subtitles.supersubtitles/changelog.txt | 4 +
service.subtitles.supersubtitles/service.py | 86 +++++++++++++++--------
3 files changed, 61 insertions(+), 32 deletions(-)
hooks/post-receive
--
Scripts
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons