The branch, eden-pre has been updated
via bb71cfeae8f9c6bc72c06312b8412deca042387a (commit)
from ed157c7e9a70990beb93eda6c32c6751b1e175c6 (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=bb71cfeae8f9c6bc72c06312b8412deca042387a
commit bb71cfeae8f9c6bc72c06312b8412deca042387a
Author: ronie <[email protected]>
Date: Fri Nov 18 21:53:32 2011 +0100
[script.tvtunes] -v1.0.11
addon option to store tv tunes in a custom folder
diff --git a/script.tvtunes/addon.xml b/script.tvtunes/addon.xml
index 7be9887..dbd90af 100644
--- a/script.tvtunes/addon.xml
+++ b/script.tvtunes/addon.xml
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.tvtunes"
name="TvTunes"
- version="1.0.8"
+ version="1.0.11"
provider-name="Ppic, ronie">
<requires>
<import addon="xbmc.python" version="2.0"/>
+ <import addon="script.module.simplejson" version="2.0.10"/>
</requires>
<extension point="xbmc.python.script"
library="default.py">
- <provides>video</provides>
+ <provides>executable</provides>
</extension>
<extension point="xbmc.addon.metadata">
<platform>all</platform>
diff --git a/script.tvtunes/changelog.txt b/script.tvtunes/changelog.txt
index f718a31..bd4fe72 100644
--- a/script.tvtunes/changelog.txt
+++ b/script.tvtunes/changelog.txt
@@ -1,3 +1,13 @@
+v1.0.11
+- use simplejson
+
+v1.0.10:
+- replace illegal characters in filename
+
+v1.0.9:
+- added option for custom path
+- make it a program addon
+
v1.0.8:
- adjusted to latest json-rpc changes
@@ -34,7 +44,7 @@ v0.8.1:
v0.8.0:
- added solo mode, use this line with a button on dialogvideoinfo for tvshow:
-<onclick>XBMC.RunScript(script.tvtunes,mode=solo&tvpath=$INFO[ListItem.FilenameAndPath]&tvname=$INFO[ListItem.TVShowTitle])</onclick>
+<onclick>XBMC.RunScript(script.tvtunes,mode=solo&path=$INFO[ListItem.FilenameAndPath]&name=$INFO[ListItem.TVShowTitle])</onclick>
probably won't work on episode level.
v0.7.3
diff --git a/script.tvtunes/default.py b/script.tvtunes/default.py
index c205a00..bb1b314 100644
--- a/script.tvtunes/default.py
+++ b/script.tvtunes/default.py
@@ -22,8 +22,10 @@ log( "### version: %s" % __version__ )
try:
# parse sys.argv for params
- try:params = dict( arg.split( "=" ) for arg in sys.argv[ 1 ].split( "&" ) )
- except:params = dict( sys.argv[ 1 ].split( "=" ))
+ try:
+ params = dict( arg.split( "=" ) for arg in sys.argv[ 1 ].split( "&" ) )
+ except:
+ params = dict( sys.argv[ 1 ].split( "=" ))
except:
# no params passed
params = {}
@@ -41,9 +43,9 @@ if params.get("backend", False ):
xbmc.executebuiltin('XBMC.RunScript(%s,loop=%s&downvolume=%s&smb=%s&user=%s&password=%s)'
% (os.path.join( RESOURCES_PATH , "tvtunes_backend.py"), loop , downvolume ,
smb , username , password))
elif params.get("mode", False ) == "solo":
- log( params )
+ log( "### params %s" % params )
xbmc.executebuiltin('XBMC.RunScript(%s,mode=solo&name=%s&path=%s)' %
(os.path.join( RESOURCES_PATH , "tvtunes_scraper.py") , params.get("tvname",
False ) , params.get("tvpath", False ) ) )
else:
- log( " %s v%s" % ( __addon__.getAddonInfo("id") ,
__addon__.getAddonInfo("version") ) )
+ log( "### %s v%s" % ( __addon__.getAddonInfo("id") ,
__addon__.getAddonInfo("version") ) )
xbmc.executebuiltin('XBMC.RunScript(%s)' % os.path.join( RESOURCES_PATH ,
"tvtunes_scraper.py"))
diff --git a/script.tvtunes/resources/language/English/strings.xml
b/script.tvtunes/resources/language/English/strings.xml
index c29e63c..d34fbe9 100644
--- a/script.tvtunes/resources/language/English/strings.xml
+++ b/script.tvtunes/resources/language/English/strings.xml
@@ -22,4 +22,6 @@
<string id="45003">Use Protected SMB share</string>
<string id="45004">Username:</string>
<string id="45005">Password:</string>
+ <string id="45006">Store tunes in a custom path</string>
+ <string id="45007">Path:</string>
</strings>
diff --git a/script.tvtunes/resources/settings.xml
b/script.tvtunes/resources/settings.xml
index a9b55e0..58e2811 100644
--- a/script.tvtunes/resources/settings.xml
+++ b/script.tvtunes/resources/settings.xml
@@ -5,4 +5,6 @@
<setting id="smb_share" type="bool" label="45003" default="False"/>
<setting id="smb_login" enable="eq(-1,true)" type="text" label="45004"
default="" />
<setting id="smb_psw" enable="eq(-2,true)" type="text" option="hidden"
label="45005" default="" />
-</settings>
\ No newline at end of file
+<setting id="custom_path_enable" type="bool" label="45006" default="False"/>
+<setting id="custom_path" enable="eq(-1,true)" type="folder" label="45007"
default="" />
+</settings>
diff --git a/script.tvtunes/resources/tvtunes_backend.py
b/script.tvtunes/resources/tvtunes_backend.py
index 8be87d1..4068df3 100644
--- a/script.tvtunes/resources/tvtunes_backend.py
+++ b/script.tvtunes/resources/tvtunes_backend.py
@@ -9,6 +9,9 @@ import xbmc
import xbmcgui
import sys
import xbmcvfs
+import xbmcaddon
+
+__addon__ = xbmcaddon.Addon(id='script.tvtunes')
def log(msg):
xbmc.log( str( msg ),level=xbmc.LOGDEBUG )
@@ -33,6 +36,9 @@ class mythread( threading.Thread ):
self.oldpath = ""
self.playpath = ""
self.loud = False
+ self.enable_custom_path = __addon__.getSetting("custom_path_enable")
+ if self.enable_custom_path == "true":
+ self.custom_path = __addon__.getSetting("custom_path")
self.base_volume = self.get_volume()
@@ -42,7 +48,10 @@ class mythread( threading.Thread ):
if not xbmc.getCondVisibility( "Window.IsVisible(10025)"):
self.stop() #destroy threading
if xbmc.getCondVisibility( "Container.Content(Seasons)" ) or
xbmc.getCondVisibility( "Container.Content(Episodes)" ) and not
xbmc.Player().isPlaying() and "plugin://" not in xbmc.getInfoLabel(
"ListItem.Path" ) and not xbmc.getInfoLabel( "container.folderpath" ) ==
"videodb://5/":
- self.newpath = xbmc.getInfoLabel( "ListItem.Path" )
+ if self.enable_custom_path == "true":
+ self.newpath = self.custom_path + xbmc.getInfoLabel(
"ListItem.TVShowTitle" )
+ else:
+ self.newpath = xbmc.getInfoLabel( "ListItem.Path" )
if not self.newpath == self.oldpath and not self.newpath
== "" and not self.newpath == "videodb://2/2/":
log( "### old path: %s" % self.oldpath )
log( "### new path: %s" % self.newpath )
diff --git a/script.tvtunes/resources/tvtunes_scraper.py
b/script.tvtunes/resources/tvtunes_scraper.py
index 50c3724..441f600 100644
--- a/script.tvtunes/resources/tvtunes_scraper.py
+++ b/script.tvtunes/resources/tvtunes_scraper.py
@@ -4,6 +4,7 @@ import urllib
import os
from traceback import print_exc
import re
+import simplejson
import unicodedata
import xbmc
import xbmcaddon
@@ -20,7 +21,6 @@ def log(msg):
try:
# parse sys.argv for params
- log( sys.argv[ 1 ] )
try:params = dict( arg.split( "=" ) for arg in sys.argv[ 1 ].split( "&" ) )
except:
print_exc()
@@ -59,23 +59,34 @@ class TvTunes:
self.search_url =
"http://www.televisiontunes.com/search.php?searWords=%s&Send=Search"
self.download_url = "http://www.televisiontunes.com/download.php?f=%s"
self.theme_file = "theme.mp3"
+ self.enable_custom_path = __addon__.getSetting("custom_path_enable")
+ if self.enable_custom_path == "true":
+ self.custom_path = __addon__.getSetting("custom_path")
self.TVlist = self.listing()
self.DIALOG_PROGRESS = xbmcgui.DialogProgress()
self.ERASE =
xbmcgui.Dialog().yesno(__language__(32103),__language__(32104))
self.DIALOG_PROGRESS.create( __language__(32105) , __language__(32106)
)
- if params.get("mode", "false" ) == "solo" :
self.scan(params.get("name", "" ),params.get("path", "false" ))
- else: self.scan()
+ if params.get("mode", "false" ) == "solo":
+ if self.enable_custom_path == "true":
+ self.scan(params.get("name", "" ),self.custom_path)
+ else:
+ self.scan(params.get("name", "" ),params.get("path", "false" ))
+ else:
+ self.scan()
def scan(self , cur_name=False , cur_path=False):
count = 0
if cur_name and cur_path:
- log( "solo mode" )
+ log( "### solo mode" )
+
+ log("####################### %s" % cur_name )
+ log("####################### %s" % cur_path )
self.TVlist = [[cur_name,cur_path.encode('utf-8')]]
total = len(self.TVlist)
for show in self.TVlist:
count = count + 1
if not self.ERASE and
xbmcvfs.exists(os.path.join(show[1],"theme.mp3")):
- log( "### %s already exists, ERASE is set to %s" %
(os.path.join(show[1],"theme.mp3"), [False,True][self.ERASE] ) )
+ log( "### %s already exists, ERASE is set to %s" % (
os.path.join(show[1],"theme.mp3"), [False,True][self.ERASE] ) )
else:
self.DIALOG_PROGRESS.update( (count*100)/total ,
__language__(32107) + ' ' + show[0] , "")
if self.DIALOG_PROGRESS.iscanceled():
@@ -91,23 +102,26 @@ class TvTunes:
def download(self , theme_url , path):
log( "### download :" + theme_url )
tmpdestination = xbmc.translatePath(
'special://profile/addon_data/%s/temp/%s' % ( __addonid__ , self.theme_file ) )
- destination = os.path.join( path , self.theme_file)
+ destination = os.path.join( path , self.theme_file )
try:
def _report_hook( count, blocksize, totalsize ):
percent = int( float( count * blocksize * 100 ) / totalsize )
strProgressBar = str( percent )
self.DIALOG_PROGRESS.update( percent , __language__(32110) + '
' + theme_url , __language__(32111) + ' ' + destination )
- if xbmcvfs.exists(path):
- fp , h = urllib.urlretrieve( theme_url , tmpdestination ,
_report_hook )
- log( h )
- copy = xbmcvfs.copy(tmpdestination, destination)
- if copy:
- log( "### copy successful" )
- else:
- log( "### copy failed" )
- xbmcvfs.delete(tmpdestination)
- return True
- else : log( "problem with path: %s" % destination )
+ if not xbmcvfs.exists(path):
+ try:
+ xbmcvfs.mkdir(path)
+ except:
+ log( "problem with path: %s" % destination )
+ fp , h = urllib.urlretrieve( theme_url , tmpdestination ,
_report_hook )
+ log( h )
+ copy = xbmcvfs.copy(tmpdestination, destination)
+ if copy:
+ log( "### copy successful" )
+ else:
+ log( "### copy failed" )
+ xbmcvfs.delete(tmpdestination)
+ return True
except :
log( "### Theme download Failed !!!" )
print_exc()
@@ -150,8 +164,6 @@ class TvTunes:
def search_theme_list(self , showname):
log( "### Search for %s" % showname )
- ### on nettoie le nom des caract pas cool (type ": , ; , ...")
- showname = showname.replace(":","")
theme_list = []
next = True
url = self.search_url % urllib.quote_plus(showname)
@@ -183,19 +195,17 @@ class TvTunes:
# on recup la liste des series en biblio
# json statement for tv shows
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method":
"VideoLibrary.GetTVShows", "params": {"properties": ["file"], "sort": {
"method": "label" } }, "id": 1}')
- json_response = re.compile( "{(.*?)}", re.DOTALL ).findall(json_query)
+ json_response = simplejson.loads(json_query)
log( json_response )
TVlist = []
- for tvshowitem in json_response:
- log( tvshowitem )
- findtvshowname = re.search( '"label": ?"(.*?)",["\n]', tvshowitem )
- if findtvshowname:
- tvshowname = ( findtvshowname.group(1) )
- tvshow = unicodedata.normalize('NFKD',
unicode(unicode(tvshowname, 'utf-8'))).encode('ascii','ignore')
- findpath = re.search( '"file": ?"(.*?)",["\n]', tvshowitem )
- if findpath:
- path = (findpath.group(1))
- TVlist.append( ( tvshow , path ) )
+ if json_response['result'].has_key('tvshows'):
+ for item in json_response['result']['tvshows']:
+ tvshow = item['label'].replace(":","")
+ if self.enable_custom_path == "true":
+ path = self.custom_path + (tvshow)
+ else:
+ path = item['file']
+ TVlist.append( ( tvshow , path ) )
return TVlist
if ( __name__ == "__main__" ):
-----------------------------------------------------------------------
Summary of changes:
script.tvtunes/addon.xml | 5 +-
script.tvtunes/changelog.txt | 12 +++-
script.tvtunes/default.py | 10 ++-
.../resources/language/English/strings.xml | 2 +
script.tvtunes/resources/settings.xml | 4 +-
script.tvtunes/resources/tvtunes_backend.py | 11 +++-
script.tvtunes/resources/tvtunes_scraper.py | 70 +++++++++++--------
7 files changed, 75 insertions(+), 39 deletions(-)
hooks/post-receive
--
Scripts
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons