TSReader SaveProgramme plugin for MyTV in development...
#1
There were a few posts on getting a python script to control tsreader. Take the bottom code and put it in a new py file and place it in the saveprogramme folder of mytv and that is what you will have. Change the settings as needed . Currently it'll only work when tsreader's source is dvb-s (and I have no real plans to change that). Right now this script is quite ugly. It is my first attempt at python and was written in a couple hours. If there's interest in furthering the code I'll update with peoples suggestions or another coder can take over.

Code:
from mytvLib import *
import xbmcgui,xbmc,time, re, telnetlib, time
from string import replace, split

TSREADER_CONTROL_IP = "192.168.0.2"
TSREADER_CONTROL_PORT = 22551
TSREADER_PLAYBACK_OUTPUT = "VLC2"

TSREADER_22KHZ = 0
TSREADER_DISEQC = { '91.0W' : '2',
                    '82.0W' : '1' }
TSREADER_DP = { '82.0W' : '11250',
                '91.0W' : '14350' }

class SaveProgramme:
    def __init__(self, cachePath=""):
        self.DIR_CACHE = cachePath
        self.tsrControlIP = TSREADER_CONTROL_IP
        self.tsrControlPort = TSREADER_CONTROL_PORT
        self.tsrPlaybackOutput = TSREADER_PLAYBACK_OUTPUT
        self.tsr22KHZ = TSREADER_22KHZ
        self.tsrDiseqc = TSREADER_DISEQC
        self.tsrDP = TSREADER_DP
        self.config(False)
        
    def isConfigured(self):
        return True
        
    def config(self, reset=True):
        debug("> config()")
        
        success = self.isConfigured()
            
        debug("< config() success=" + str(success))
        return success
        
    def run(self, channel, programme, confirmRequired=True):
        debug("> SaveProgramme.run() confirmRequired=" + str(confirmRequired))
        
        success = False
        if not self.isConfigured():
            messageOK("SaveProgramme Error", "Not Configured", "Unable to Tune Program")
            debug("< SaveProgramme.run() failed")
            return False
        try:
            chid = channel.getChID()
            chName = channel.getChName()
            title = programme.getTitle()
            desc = programme.getDescription()
        except:
            messageOK("SaveProgramme Error","Missing Channel or Programme.","Save cannot be done.")
            debug("< SaveProgramme.run() failed")
            return False
        
        rto = split(desc, '|')
        tuneOptions = split(rto[1], ' ')
        tuneOptions[1] = replace(tuneOptions[1], '.', '')
        if tuneOptions[2] == 'L':
            lnbf = self.tsrDP[tuneOptions[0]]
        else:
            lnbf = '11250'
            
        diseqcPort = self.tsrDiseqc[tuneOptions[0]]
                
        tuneCommand = 'TUNE ' + str(tuneOptions[1]) + ' ' + tuneOptions[2] + ' ' + tuneOptions[3] + ' ' + str(lnbf) + ' ' + str(self.tsr22KHZ) + ' ' + str(diseqcPort) + '\r'
        
        programNumber = split(chid, '-')[0]
        programCommand = 'PROGRAM ' + str(programNumber) + '\r'
        
        playCommand = 'PLAY ' + self.tsrPlaybackOutput + '\r'

        tn = telnetlib.Telnet(self.tsrControlIP, self.tsrControlPort)
        tn.read_until('200 TSReader version 2.7.44 Control Server', timeout=5)
        tn.write(str(tuneCommand))
        tn.read_until('308 Source restarted', timeout=5)
        tn.write('STALL 300\r')
        tn.read_until('311 Table decoding complete', timeout=60)
        tn.write(str(programCommand))
        tn.read_until('300 Program selected', timeout=5)
        tn.write(str(playCommand))
        tn.read_until('302 Playback starting', timeout=5)
        tn.write('QUIT\r')
        tn.close()
        
        time.sleep(3)
        
        plist = xbmc.PlayList(0)
        plist.clear()
        plist.load('g:\\VideoLAN.strm')
        xbmc.Player().play(plist)
        
    def tune(self, chid, programme):
        return True
Reply
#2
if you want to PM me wth some more details on what your trying to achieve with this, then maybe I can help with the code and include it in the next release of myTV ?
Retired from Add-on dev
Reply
#3
ok. good effort. If you dont mind, I'll tart it up (make it configurable from within myTV so we dont have to edit file for IP etc) then send it you back to try.
Retired from Add-on dev
Reply

Logout Mark Read Team Forum Stats Members Help
TSReader SaveProgramme plugin for MyTV in development...0