Kodi Community Forum
[Closed] TvTunes Addon - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Program Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=151)
+---- Thread: [Closed] TvTunes Addon (/showthread.php?tid=83925)



- ppic - 2011-05-02

well, not a bad id, the script is not called each time a directory, it's a thread running in background, then check the path on conditions, so it's really triggering for theme when folder path changed.


- anarchintosh - 2011-05-03

Hi ppic:

w00t w00t
i implemented the hack and it works 100% perfectly Smile

all i did was add a hack to check for VIDEO_TS in the path, if so go up a couple of directories to check for theme.mp3
PS. it still works fine for all my non-dvdr tv shows.

here is the patched tvtunes_backend.py:
PHP Code:
# -*- coding: utf-8 -*-
#Modules General
import threading
from traceback import print_exc
import time
import os
import re
#Modules XBMC
import xbmc
import xbmcgui
import sys

try:
    
# parse sys.argv for params
    
print sys.argv]
    try:
params dictarg.split"=" ) for arg in sys.argv].split"&" ) )
    
except:
        
print_exc()
        
params =  dictsys.argv].split"=" ))
except:
    
# no params passed
    
print_exc()
    
params = {} 
class 
mythreadthreading.Thread ):
    
def __init__self ):
        
threading.Thread.__init__self )
        
self._stop False
        
print "### starting TvTunes Backend ###"
        
self.newpath ""
        
self.oldpath ""
        
self.playpath ""
        
self.loud False
        self
.base_volume self.get_volume()
        
        
    
def runself ):        
        try:             
            while 
not self._stop:           # le code                
                
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 
not self.newpath == self.oldpath and not self.newpath == "" and not self.newpath == "videodb://2/2/":
                        print 
"### old path: %s" self.oldpath
                        
print "### new path: %s" self.newpath
                        self
.oldpath self.newpath
                        
if not xbmc.Player().isPlaying() : self.start_playing()
                        else: print 
"### player already playing"
                        
                
if xbmc.getInfoLabel"Window(10025).Property(TvTunesIsAlive)" ) == "true" and not xbmc.Player().isPlaying():
                    print 
"### playing ends"
                    
if self.loudself.raise_volume()
                    
xbmcgui.Window10025 ).clearProperty('TvTunesIsAlive')
                    
                if 
xbmc.getCondVisibility"Container.Content(tvshows)" ) and self.playpath and not xbmc.getCondVisibility"Window.IsVisible(12003)" ):
                    print 
"### reinit condition"
                    
self.newpath ""
                    
self.oldpath ""
                    
self.playpath ""
                    
print "### stop playing"
                    
xbmc.Player().stop()
                    if 
self.loudself.raise_volume()
                    
xbmcgui.Window10025 ).clearProperty('TvTunesIsAlive')
                    
                
time.sleep.5 )
        
except:
            
print_exc()
            
self.stop()
            
    
def get_volumeself ):
        try: 
volume int(xbmc.getInfoLabel('player.volume').split(".")[0])
        
exceptvolume int(xbmc.getInfoLabel('player.volume').split(",")[0])
        print 
"### current volume: %s%%" % (( 60 volume )*(100/60.0))
        return 
volume
        
    def lower_volume
self ):
        try:
            
self.base_volume self.get_volume()
            
self.loud True
            vol 
= ((60+self.base_volume-intparams.get("downvolume")) )*(100/60.0))
            if 
vol vol 0
            
print "### volume goal: %s%% " vol
            xbmc
.executebuiltin('XBMC.SetVolume(%d)' vol)
            print 
"### down volume to %d%%" vol
        except
:
            
print_exc()
            
    
def raise_volumeself ):
        
self.base_volume self.get_volume()
        
vol = ((60+self.base_volume+intparams.get("downvolume")) )*(100/60.0))
        print 
"### volume goal : %s%% " vol
        
print "### raise volume to %d%% " vol
        xbmc
.executebuiltin'XBMC.SetVolume(%d)' vol )  
        
self.loud False
        
    def start_playing
self ):     
        if 
params.get("smb""false" ) == "true" and self.newpath.startswith("smb://") : 
            print 
"### Try authentification share"
            
self.newpath self.newpath.replace("smb://""smb://%s:%s@" % (params.get("user""guest" ) , params.get("password""guest" )) )
            print 
"### %s" self.newpath

        
#######hack for TV shows stored as ripped disc folders
        
if re.search('VIDEO_TS',str(self.newpath)):
            print 
"### FOUND VIDEO_TS IN PATH: Correcting the path for DVDR tv shows"
            
uppedpath self._updirself.newpath)
            if 
os.path.existsos.path.join uppedpath "theme.mp3" )):
                
self.playpath os.path.join uppedpath "theme.mp3" )
            else:
                
self.playpath os.path.join self._updir(uppedpath,1) , "theme.mp3" )
        
#######end hack
                
        
elif os.path.existsos.path.join self.newpath "theme.mp3" ) ):
            
self.playpath os.path.join self.newpath "theme.mp3" )
        
elif os.path.exists(os.path.join(os.path.dirnameos.path.dirnameself.newpath ) ) , "theme.mp3")):                                
            
self.playpath = (os.path.join(os.path.dirnameos.path.dirnameself.newpath ) ) , "theme.mp3"))
        else: 
self.playpath False

        
if self.playpath:
            if 
not self.loudself.lower_volume()
            
xbmcgui.Window10025 ).setProperty"TvTunesIsAlive""true" )
            print 
"### start playing %s" self.playpath
            xbmc
.Player().play(self.playpath)
            if 
params.get("loop""false" ) == "true" xbmc.executebuiltin('XBMC.PlayerControl(Repeat)')
            else: 
xbmc.executebuiltin('XBMC.PlayerControl(RepeatOff)')             

        else: print 
"### no theme found for %s or %s" % ( os.path.joinself.newpath "theme.mp3" ) , os.path.join os.path.dirnameos.path.dirname self.newpath ) ) , "theme.mp3" ) )

    
def _updir(selfthepathx):
        
# move up x directories on thepath
        
while 0:
            
-= 1
            thepath 
= (os.path.split(thepath))[0]
        return 
thepath
        
    def stop
self ):
        if 
xbmc.getInfoLabel"Window(10025).Property(TvTunesIsAlive)" ) == "true" and not xbmc.Player().isPlayingVideo(): 
            print 
"### stop playing"
            
xbmc.Player().stop()
        
xbmcgui.Window10025 ).clearProperty('TvTunesIsRunning')
        
xbmcgui.Window10025 ).clearProperty('TvTunesIsAlive')
        
        if 
self.loudself.raise_volume()
        print 
"### Stopping TvTunes Backend ###"
        
self._stop True

      
xbmcgui
.Window10025 ).setProperty"TvTunesIsRunning""true" )
thread mythread()
# start thread
thread.start() 



- ppic - 2011-05-03

ok good,

instead of using re, to test if string is in a string, you can also do that:

Code:
if 'VIDEO_TS' in str(self.newpath):

i don't remember if i used re in background, it will save to load re lib.

i'll see to update the script with your hack, thanks for your work.


- anarchintosh - 2011-05-03

yeah you didn't use import re, i added the import for that.
tnx for the string hint.

cool, will be nice to have this in mainline.

not sure if my way for moving up directories is very pretty, but it works (and is very fast):

PHP Code:
def _updir(selfthepathx):
        
# move up x directories on thepath
        
while 0:
            
-= 1
            thepath 
= (os.path.split(thepath))[0]
        return 
thepath 

so then if a have a path that i want to move up 3 directories on, i do this:
thepath = self._updir(thepath, 3)

...there might be a better way to do this.


- ppic - 2011-05-03

in script, you can have a lot of way to achieve the same thing, the important thing at this point is to make it work, improvement come later while your coding skill grow.


- ppic - 2011-05-03

ho yes ! i forgot, there's always a better way to do, that's why it's fun !!! Big Grin


- anarchintosh - 2011-05-03

ppic Wrote:in script, you can have a lot of way to achieve the same thing, the important thing at this point is to make it work, improvement come later while your coding skill grow.
wise words Nerd


- primetime34 - 2011-05-07

Still not working in smart playlists...here's the log

http://pastebin.com/3auTyQQH


- ppic - 2011-05-07

tvtunes is not launched in you log, and i confirm that it's working well in smartplaylist.


TVTUNES script not working - help please - sgant - 2011-05-08

hiya

using latest version of XBMC and transparency

cant get the tvtunes script to play anything

in the debug log the script loads on startup, but does not play the theme

the error i get from the debug log is

11:04:52 T:6560 M:1687908352 WARNING: Skin has invalid include: TvTunes
11:04:52 T:6560 M:1685164032 WARNING: Previous line repeats 1 times.

can someone help, thanks


- ppic - 2011-05-08

ask in transparency sub forum for this one or submit a full debug log.


- ppic - 2011-05-08

i've just pushed on off repo Wink
Quote:changelog:
v0.9.0:
- added support for dvd iso folders (thanks to anarchintosh)



- anarchintosh - 2011-05-08

sgant Wrote:11:04:52 T:6560 M:1687908352 WARNING: Skin has invalid include: TvTunes
11:04:52 T:6560 M:1685164032 WARNING: Previous line repeats 1 times.
i got this.

for me, it seems it was because TV Tunes is hosted on two different repos (passion & xbmc.org?) and one of them contains the old non-updated version 'script.TvTunes' (as opposed to 'script.tvtunes'). the old version fails with skins that have updated their support for it. and vice versa, it new version fails with skins that have not updated. in your case it is the latter.

as ppic said, you'll need to ask for transparency to be updated.


- rogerthis - 2011-05-09

Does TVTunes work with Confluence skin?

Or is there a list of Skins that it automatically work with?


- primetime34 - 2011-05-09

I'm wondering if anybody is having the same issue I'm having:

I run this on Aeon MQ2. I put some smart playlists on my main menu (Children's TV Shows, Mom and Dad's TV Shows, etc). So I still have the main "TV Shows" on the main menu, but I rarely use it. When I do go to the main "TV Shows" tvtunes works just fine. When I go to one of the smart playlists on the main menu (say Children's TV), it doesn't work. It is turned on for the skin, but it just isn't working. Does anybody have a similar setup and have it working? Thanks.