TiVo Community
TiVo Community
TiVo Community
Go Back   TiVo Community > Underground Playground > Developers Corner
TiVo Community
Reply
Forum Jump
 
Thread Tools
Old 04-21-2010, 03:55 AM   #121
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,117
I've started a GitHub page for HME for Python, so that, finally, you can download it without registering here.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
wmcbrine is offline   Reply With Quote
Old 12-24-2010, 09:01 PM   #122
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,117
Version 0.19

Direct text keyboard input support.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
wmcbrine is offline   Reply With Quote
Old 12-31-2010, 09:14 AM   #123
jtseltmann
Registered User
 
Join Date: May 2005
Posts: 147
I'm very new to mac programming and python...well mac in general. How do I go about getting this great code installed and running? I downloaded the zip file...but I don't see how to get it running? Is there install directions for dummies? i'm coming from windows programming background so...be patient!
Thanks
J
__________________
1 TiVo HD w/1TB int drive (1 M Card)
2 TiVo HD (4 CCards)
Wired Ethernet
Samsung LN52A650 - 52" LCD 120Hz
Samsung PN50B550 - 50" Plasma
Samsung LNS2641D -26" LCD
Harmony One
Harmony 659
jtseltmann is offline   Reply With Quote
Old 12-31-2010, 04:06 PM   #124
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,117
I already put my best instructions in the README, so unless you have a more specific question, I can't help you. I can tell you that there's no need to "install" it, though. Just unzip it.

BTW, how do you know it's great code if you haven't got it working yet?
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
wmcbrine is offline   Reply With Quote
Old 02-01-2011, 12:18 PM   #125
ttocsmi
Registered User
 
Join Date: Jan 2007
Posts: 19
Quote:
Originally Posted by wmcbrine View Post
I already put my best instructions in the README, so unless you have a more specific question, I can't help you. I can tell you that there's no need to "install" it, though. Just unzip it.

BTW, how do you know it's great code if you haven't got it working yet?
i'm intrigued by this program - it seems like it's quite handy and i can tell you (and others here) have put a lot of time and effort into its development.

i downloaded both the zeroconf.py and remote.pwy files, and can view each in IDLE. i also installed python 2.7 on my XP laptop. when i attempt to run each, a shell window briefly appears, disappears, and nothing else happens. if i try to run each file using F5 from within Idle, a "there's an error in your program: invalid syntax" box appears and nothing else happens.

any ideas as to what i'm doing wrong? thank you very much.

scott
__________________
"Engineering: where the noble, semi-skilled laborers execute the vision of those who think and dream. Hello, Oompa Loompas of science!"
ttocsmi is offline   Reply With Quote
Old 02-01-2011, 02:41 PM   #126
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,117
Well, remote.pyw is over in the other thread... anyway, don't run it from IDLE. You don't need IDLE, and Tk-based apps like remote.pyw won't work from within IDLE. For remote.pyw, just double-click on it from the desktop. Alternatively, you can start it by typing "python remote.pyw" at the command line.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
wmcbrine is offline   Reply With Quote
Old 02-03-2011, 08:07 PM   #127
ttocsmi
Registered User
 
Join Date: Jan 2007
Posts: 19
thanks again for your assistance. i tried double-clicking it again from my desktop - nothing.

i also tried launching from the command prompt and got the message:

file"remote.pyw", line 6
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
SyntaxError: invalid syntax

very odd.
__________________
"Engineering: where the noble, semi-skilled laborers execute the vision of those who think and dream. Hello, Oompa Loompas of science!"
ttocsmi is offline   Reply With Quote
Old 02-03-2011, 08:21 PM   #128
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,117
Yes, that certainly is odd. You've somehow got XHTML in your remote.pyw. I guarantee, it didn't come that way.

Seeing that you said "i downloaded both the zeroconf.py and remote.pwy files" suggests your error. Download the zip file.

Anyway, please stop posting about remote.pyw in the HME for Python thread. Post in the appropriate thread, or PM me if you must.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
wmcbrine is offline   Reply With Quote
Old 02-04-2011, 06:03 PM   #129
ttocsmi
Registered User
 
Join Date: Jan 2007
Posts: 19
Ok, will do. (Got the files from https://github.com/wmcbrine/tivoremote by the way)
__________________
"Engineering: where the noble, semi-skilled laborers execute the vision of those who think and dream. Hello, Oompa Loompas of science!"
ttocsmi is offline   Reply With Quote
Old 02-21-2011, 04:22 PM   #130
carlroth
Registered User
 
Join Date: Oct 2009
Posts: 1
simulator crashes as last view is removed?

I wrote this simple HME app, and I am finding that the TiVo (or at least, the simulated TiVo) quits the application when the last (non-root) view is removed. Is this expected behavior?
Attached Files
File Type: txt __init__.py.txt (1.3 KB, 10 views)
carlroth is offline   Reply With Quote
Old 02-21-2011, 08:05 PM   #131
wmcbrine
Resistance Useless
 
wmcbrine's Avatar
 
Join Date: Aug 2003
Posts: 9,117
It doesn't happen on my real Premiere. Looks like another simulator bug.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
wmcbrine is offline   Reply With Quote
Old 03-21-2011, 10:37 AM   #132
jbernardis
Registered User
 
Join Date: Oct 2003
Location: Princeton NJ
Posts: 1,064
In another thread, I was saying that I wish that when I requested a video from one of my tivos that pytivo processed this as a push instead of a pull. Then I started thinking that I could write an HME app hased on your module here that does just this.

I started working on it this pask weekend and have gotten quite far - far enough that I'm now actually thinking about the code for the push itself. The question I have is how do I know the identity of the tivo to which to push the video. I was thinking that I only needed to know the identity of the tivo I was talking to, but then I thought it might be nice if I could push to a different tivo also. However this requires that I discover the identities of the tivos on my network.

I see that you have the zeroconf.py module as part of your start.py, although you are using it only to advertise the applications. I'm trying to think of the best way to incorporate discovery. I don't think the apps should do it since they only exist for each instantiation and I think it would be expensive to do discovery so often. Also, you already have the zeroconf code intertwined in the start code.

I guess I could modify the start code to do the discovery, but then I would need to pass this information down into the app - either through a new method that would be stubbed out in the base class but implemented in the apps where necessary, or simply through additional parameters passed into mainloop and then into the startup method.

Am I missing something here? Can you think of any other way to tackle this problem?

Thanks
__________________
2 Series 3
1 HDTivo
1 Series 1 (Lifetime)
1 Win7 HTPC with Ceton Quad Tuner


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
jbernardis is offline   Reply With Quote
Old 03-21-2011, 12:06 PM   #133
orangeboy
yes, I AM orangeboy!
 
Join Date: Apr 2004
Location: Moline, IL
Posts: 4,075
Quote:
Originally Posted by jbernardis View Post
In another thread, I was saying that I wish that when I requested a video from one of my tivos that pytivo processed this as a push instead of a pull. Then I started thinking that I could write an HME app hased on your module here that does just this.

I started working on it this pask weekend and have gotten quite far - far enough that I'm now actually thinking about the code for the push itself. The question I have is how do I know the identity of the tivo to which to push the video. I was thinking that I only needed to know the identity of the tivo I was talking to, but then I thought it might be nice if I could push to a different tivo also. However this requires that I discover the identities of the tivos on my network.

I see that you have the zeroconf.py module as part of your start.py, although you are using it only to advertise the applications. I'm trying to think of the best way to incorporate discovery. I don't think the apps should do it since they only exist for each instantiation and I think it would be expensive to do discovery so often. Also, you already have the zeroconf code intertwined in the start code.

I guess I could modify the start code to do the discovery, but then I would need to pass this information down into the app - either through a new method that would be stubbed out in the base class but implemented in the apps where necessary, or simply through additional parameters passed into mainloop and then into the startup method.

Am I missing something here? Can you think of any other way to tackle this problem?

Thanks
Here's a small chunk of python code I use in my TiVoToDo project to get the TiVos on my LAN, and to put the information into a dictionary, with the TiVo name as the key, and the TSN as the item the key refers to:

TiVoToDo.py:
Code:
import config as c
import tools as t

# Find TiVos on the LAN
b = t.Beacon()
b.start()
b.stop()
tools.py
Code:
import config as c
import Zeroconf as Z

class ZCListener:
    def __init__(self, names):
        self.names = names

    def removeService(self, server, type, name):
        if name in self.names:
            self.names.remove(name)

    def addService(self, server, type, name):
        self.names.append(name)

class ZCBroadcast:
    def __init__(self):
        self.rz = Z.Zeroconf()

    def scan(self):
        """ Look for TiVos using Zeroconf. """
        VIDS = '_tivo-videos._tcp.local.'
        names = []

        # Get the names of servers offering TiVo videos.
        browser = Z.ServiceBrowser(self.rz, VIDS, ZCListener(names))

        # Give them half a second to respond.
        time.sleep(.5)

        # Now get the addresses -- this is the slow part.
        for name in names:
            info = self.rz.getServiceInfo(VIDS, name)
            if info and 'TSN' in info.properties:
                tsn = info.properties['TSN']
                name = name.replace('.' + VIDS, '').encode('utf-8')
                if isHDtivo(tsn):
                    c.tivos[name] = tsn

    def shutdown(self):
        self.rz.close()
        time.sleep(.5)

class Beacon:
    UDPSock = socket(AF_INET, SOCK_DGRAM)
    UDPSock.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
    services = []

    def __init__(self):
        self.log = logging.getLogger("TiVoToDo.tools.Beacon")
        self.log.info('Scanning for TiVos...')
        self.bd = ZCBroadcast()
        self.bd.scan()

    def format_services(self):
        return ';'.join(self.services)

    def format_beacon(self, conntype, services=True):
        beacon = ['tivoconnect=1',
                  'swversion=1',
                  'method=%s' % conntype,
                  'identity=%s' % c.getGUID(),
                  'machine=%s' % gethostname(),
                  'platform=pc']

        if services:
            beacon.append('services=' + self.format_services())
        else:
            beacon.append('services=TiVoMediaServer:0/http')

        return '\n'.join(beacon)

    def send_beacon(self):
        beacon_ip = c.get_broadcast()
        if not beacon_ip:
            beacon_ip = '255.255.255.255'
        try:
            self.UDPSock.sendto(self.format_beacon('broadcast'),
                                    (beacon_ip, 2190))
        except error, e:
            log.debug(e)

    def start(self):
        self.send_beacon()
        self.timer = Timer(60, self.start)
        self.timer.start()

    def stop(self):
        self.timer.cancel()
        if self.bd:
            self.bd.shutdown()
This was code modified from pyTivo. Only a couple of lines were changed to get the functionality I needed.

HTH!

Edit: You may not need or want the HD model test: "if isHDtivo(tsn):", so you could delete that line and re-indent "c.tivos[name] = tsn" appropriately.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
orangeboy is offline   Reply With Quote
Old 03-21-2011, 01:31 PM   #134
jbernardis
Registered User
 
Join Date: Oct 2003
Location: Princeton NJ
Posts: 1,064
Thanks Orangeboy. I was looking through the code, and it seems to me that I could do it simply with zeroconf:
Code:
zc = ZeroConf()
zc.addServiceListener(type, Listener)
...wait a few seconds...
zc.removeServiceListener(Listener)
zc.close()
and the listener will have recorded the tivo names.

The problem is that I don't think I can do this in the app because the main logic already has a listener thread going and I think the two threads would be competing for the same port number (or maybe I don't fully understand this zeroconf stuff - very possible).

I think instead I will have to adapt the main logic. Right now, it registers the apps inside the Broadcast constructor - but this is also where the Zeroconf constructor is called.

I was thinking of doing the following:
1) split the Broadcast constructor into the constructor and a separate method for registering the apps.
2) adding a method for the above discovery logic (much like the scan method in pytivo)
3) changing the mainline logic to construct the Broadcast object and to invoke the discovery method before the loop that imports the apps, and then calling the new register method after this loop.

That would give me the list of Tivos which I would have to pass into the Server constructor so that it could then get passed down into the apps themselves.
__________________
2 Series 3
1 HDTivo
1 Series 1 (Lifetime)
1 Win7 HTPC with Ceton Quad Tuner


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
jbernardis is offline   Reply With Quote
Old 03-21-2011, 10:51 PM   #135
jbernardis
Registered User
 
Join Date: Oct 2003
Location: Princeton NJ
Posts: 1,064
The code I ended up adding to start.py is the following:
Code:
class ZCListener:
	def __init__(self, names):
		self.names = names
	
	def removeService(self, server, type, name):
		if name in self.names:
			self.names.remove(name)

	def addService(self, server, type, name):
		self.names.append(name)

def doDiscovery(config):
	""" Look for TiVos using Zeroconf. """
	VIDS = '_tivo-videos._tcp.local.'
	names = []

	rz = Zeroconf.Zeroconf()
	print "Attempting discovery..."
	# Get the names of servers offering TiVo videos
	browser = Zeroconf.ServiceBrowser(rz, VIDS, ZCListener(names))
	
	config.remove_section(DT_SECTION)
	
	tivoCount = 0
	
	time.sleep(5)
	
	
	# Now get the addresses -- this is the slow part
	for name in names:
		info = rz.getServiceInfo(VIDS, name)
		if info and 'TSN' in info.properties:
			tsn = info.properties['TSN']
			address = socket.inet_ntoa(info.getAddress())
			name = name.replace('.' + VIDS, '')
			print "Discovered tivo: " + name + ' ' + address + ' ' + tsn
			if tivoCount == 0:
				config.add_section(DT_SECTION)
			tivoCount = tivoCount + 1
			config.set(DT_SECTION, 'tivo'+str(tivoCount)+'.name', name)
			config.set(DT_SECTION, 'tivo'+str(tivoCount)+'.tsn', tsn)
			config.set(DT_SECTION, 'tivo'+str(tivoCount)+'.address', address)

	browser.cancel()
	rz.close()
This was added right before the "main" routine. And then later in the code, I added:

Code:
	if have_zc:
		doDiscovery(config)
This was added immediately after determining if we have zeroconf available.

Two things to note here: 1) This does not work reliably on windows. It works fine after a reboot, but after that, it only works intermittently. I suspect that windows is not cleaning up the outstanding threads after the process is killed. It works flawlessly on linux. 2) Note that I decided to place the discovery information into the config. This was already available to the application logic, so it was an already-existing way to pass it through.
__________________
2 Series 3
1 HDTivo
1 Series 1 (Lifetime)
1 Win7 HTPC with Ceton Quad Tuner


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
jbernardis is offline   Reply With Quote
Old 03-23-2011, 11:46 AM   #136
orangeboy
yes, I AM orangeboy!
 
Join Date: Apr 2004
Location: Moline, IL
Posts: 4,075
Quote:
Originally Posted by jbernardis View Post
The code I ended up adding to start.py is the following:
Code:
class ZCListener:
	def __init__(self, names):
		self.names = names
	
	def removeService(self, server, type, name):
		if name in self.names:
			self.names.remove(name)

	def addService(self, server, type, name):
		self.names.append(name)

def doDiscovery(config):
	""" Look for TiVos using Zeroconf. """
	VIDS = '_tivo-videos._tcp.local.'
	names = []

	rz = Zeroconf.Zeroconf()
	print "Attempting discovery..."
	# Get the names of servers offering TiVo videos
	browser = Zeroconf.ServiceBrowser(rz, VIDS, ZCListener(names))
	
	config.remove_section(DT_SECTION)
	
	tivoCount = 0
	
	time.sleep(5)
	
	
	# Now get the addresses -- this is the slow part
	for name in names:
		info = rz.getServiceInfo(VIDS, name)
		if info and 'TSN' in info.properties:
			tsn = info.properties['TSN']
			address = socket.inet_ntoa(info.getAddress())
			name = name.replace('.' + VIDS, '')
			print "Discovered tivo: " + name + ' ' + address + ' ' + tsn
			if tivoCount == 0:
				config.add_section(DT_SECTION)
			tivoCount = tivoCount + 1
			config.set(DT_SECTION, 'tivo'+str(tivoCount)+'.name', name)
			config.set(DT_SECTION, 'tivo'+str(tivoCount)+'.tsn', tsn)
			config.set(DT_SECTION, 'tivo'+str(tivoCount)+'.address', address)

	browser.cancel()
	rz.close()
This was added right before the "main" routine. And then later in the code, I added:

Code:
	if have_zc:
		doDiscovery(config)
This was added immediately after determining if we have zeroconf available.

Two things to note here: 1) This does not work reliably on windows. It works fine after a reboot, but after that, it only works intermittently. I suspect that windows is not cleaning up the outstanding threads after the process is killed. It works flawlessly on linux. 2) Note that I decided to place the discovery information into the config. This was already available to the application logic, so it was an already-existing way to pass it through.
How's this project coming along? I'd be interested in such an app, and wondering if you'll make it available through google code, or some other means?
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
orangeboy is offline   Reply With Quote
Old 03-23-2011, 05:54 PM   #137
jbernardis
Registered User
 
Join Date: Oct 2003
Location: Princeton NJ
Posts: 1,064
Sure - I'll make it available, but I'm not quite done yet. Also, I'm not crazy about the idea of providing support for the code, so it would most likely be on an as-provided basis.

I am just about through the user interface - up to the point where I can make the actual push request, but I have also recently decided to add the ability to delete a video file, so I still have to do that too.

I'm also re-thinking my "need" to do discovery. I need to study the push code in pytivo, but I think the only thing I need is the TSN - not the IP address. If so, I might just statically enter the values in the config file since the TSN isn't ever likely to change.
__________________
2 Series 3
1 HDTivo
1 Series 1 (Lifetime)
1 Win7 HTPC with Ceton Quad Tuner


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
jbernardis is offline   Reply With Quote
Old 03-23-2011, 07:59 PM   #138
orangeboy
yes, I AM orangeboy!
 
Join Date: Apr 2004
Location: Moline, IL
Posts: 4,075
Quote:
Originally Posted by jbernardis View Post
Sure - I'll make it available, but I'm not quite done yet. Also, I'm not crazy about the idea of providing support for the code, so it would most likely be on an as-provided basis.
Great! I look forward to seeing the finished product!
As far as it being "as-is", putting it in google code or some other type of distribution will give the chance for other developers to offer support, and also to make branches/plugins/whatever, as well.

Quote:
Originally Posted by jbernardis View Post
I am just about through the user interface - up to the point where I can make the actual push request, but I have also recently decided to add the ability to delete a video file, so I still have to do that too.
The delete feature may indeed come in handy.

Quote:
Originally Posted by jbernardis View Post
I'm also re-thinking my "need" to do discovery. I need to study the push code in pytivo, but I think the only thing I need is the TSN - not the IP address. If so, I might just statically enter the values in the config file since the TSN isn't ever likely to change.
Early versions of my TiVoToDo code had the TSNs "hard-coded" in the config file. But yes, I believe only the TSN is required for the TiVo DVRs, but an IP address (or DNS name) and port would still be required for the pyTiVo server.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
orangeboy is offline   Reply With Quote
Old 03-27-2011, 04:59 PM   #139
jbernardis
Registered User
 
Join Date: Oct 2003
Location: Princeton NJ
Posts: 1,064
ok - so as of now, the entire user interface is working and the file deletion function is working. All that remains is the actual push. The user can select files to push, and select the tivo to push to, but all I do with the information right now is print it.

I might need some help here. I had originally thought that I could just send the push request to mind, and pytivo would actually take care of the transfer, and I'm still not certain that won't work. I am having some difficulties right now though.


I took the mind.py file from pytivo and adapted it for my purposes. Right now, I am able to log in to mind, but I get a 302 back which I think indicates a redirection. The login routine is line for line extracted from the pytivo file, so I don't know if this is an issue or not. Certainly pytivo does nothing with thie return code and just proceeds.

Next my routine calls pcBodySearch and seems to get back a legitimatebody_id. So the next message sent to mind is via bodyOfferModify. This routine fails though. It tries to invoke the offer_id's replace method, but I get a message that there is no such method. I think the offer_id is getting the value of "None" but I haven't had time to analyze it yet.

I'll keep going on this, but progress has definitely slowed down.
__________________
2 Series 3
1 HDTivo
1 Series 1 (Lifetime)
1 Win7 HTPC with Ceton Quad Tuner


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
jbernardis is offline   Reply With Quote
Old 03-27-2011, 11:07 PM   #140
orangeboy
yes, I AM orangeboy!
 
Join Date: Apr 2004
Location: Moline, IL
Posts: 4,075
Quote:
Originally Posted by jbernardis View Post
ok - so as of now, the entire user interface is working and the file deletion function is working. All that remains is the actual push. The user can select files to push, and select the tivo to push to, but all I do with the information right now is print it.

I might need some help here. I had originally thought that I could just send the push request to mind, and pytivo would actually take care of the transfer, and I'm still not certain that won't work. I am having some difficulties right now though.


I took the mind.py file from pytivo and adapted it for my purposes. Right now, I am able to log in to mind, but I get a 302 back which I think indicates a redirection. The login routine is line for line extracted from the pytivo file, so I don't know if this is an issue or not. Certainly pytivo does nothing with thie return code and just proceeds.

Next my routine calls pcBodySearch and seems to get back a legitimatebody_id. So the next message sent to mind is via bodyOfferModify. This routine fails though. It tries to invoke the offer_id's replace method, but I get a message that there is no such method. I think the offer_id is getting the value of "None" but I haven't had time to analyze it yet.

I'll keep going on this, but progress has definitely slowed down.
Interesting. So pyTivo will not take any part of the push? I had mistakenly assumed that the request would be sent to pyTivo, and not directly to the mind server. This is what I'm currently doing in batch to initiate a push outside of pyTivo's web interface:

Code:
curl.exe -s -d "Command=Push&Container=%Container%&File=!File!&tsn=%tsn%" "http://DL380-Server:%port%/TivoConnect?"
%port% is a variable for me since I have two instances of pyTivo running. All other variables should be self explanatory. It sounds like you're going a bit deeper than just merely passing the request off to pyTivo though...
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
orangeboy is offline   Reply With Quote
Old 03-28-2011, 01:30 PM   #141
jbernardis
Registered User
 
Join Date: Oct 2003
Location: Princeton NJ
Posts: 1,064
Thank you - this is exactly what I wanted - I didn't want to have to go through mind - a direct request to pytivo was what I wanted - but I didn't know there was such an interface.

Now that I can do it this way, it should be complete soon.
__________________
2 Series 3
1 HDTivo
1 Series 1 (Lifetime)
1 Win7 HTPC with Ceton Quad Tuner


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
jbernardis is offline   Reply With Quote
Old 03-28-2011, 01:32 PM   #142
jbernardis
Registered User
 
Join Date: Oct 2003
Location: Princeton NJ
Posts: 1,064
What is the !File! - is that the fully qualified path to the video file? Why the bangs instead of % ?
__________________
2 Series 3
1 HDTivo
1 Series 1 (Lifetime)
1 Win7 HTPC with Ceton Quad Tuner


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
jbernardis is offline   Reply With Quote
Old 03-28-2011, 04:03 PM   #143
orangeboy
yes, I AM orangeboy!
 
Join Date: Apr 2004
Location: Moline, IL
Posts: 4,075
Quote:
Originally Posted by jbernardis View Post
Thank you - this is exactly what I wanted - I didn't want to have to go through mind - a direct request to pytivo was what I wanted - but I didn't know there was such an interface.

Now that I can do it this way, it should be complete soon.
You're welcome! Yep, pyTivo has a listening port that I use regularly.

Quote:
Originally Posted by jbernardis View Post
What is the !File! - is that the fully qualified path to the video file? Why the bangs instead of % ?
Bang is needed in Window's batch when using a FOR loop, and expands variables after the original command line is interpreted. It basically functions the same as percent.

This is my batch in it's entirety, with an explanation following:
Code:
@ECHO off
SETLOCAL ENABLEDELAYEDEXPANSION
SET tsn=%1
SHIFT

:HouseKeeping
::-----------------------------------------::
:: Clean up successfully transferred files ::
::-----------------------------------------::
FOR /f "tokens=2* delims= " %%A IN ('FINDSTR /I /L "\TV\ \Cut" "\\DL380-Server\pyTivo\transfers.txt"') DO (
   SET File=%%B
   CALL :Trim_File !File!
   IF EXIST "!File!"        (2>NUL DEL "!File!")
   IF EXIST "!File!.txt"    (2>NUL DEL "!File!.txt")
   IF EXIST "!File!.xfer"   (2>NUL DEL "!File!.xfer")
   REM IF EXIST "%%~dpnB.mkv"   (2>NUL DEL "%%~dpnB.mkv")
   IF EXIST "%%~dpB\*.nfo"  (2>NUL DEL "%%~dpB\*.nfo")
   IF EXIST "%%~dpB\*.sfv"  (2>NUL DEL "%%~dpB\*.sfv")
   IF EXIST "%%~dpB\*.srr"  (2>NUL DEL "%%~dpB\*.srr")
   IF EXIST "%%~dpB\*.srt"  (2>NUL DEL "%%~dpB\*.srt")
)

FINDSTR /I /L     "\TV\ \Cut"     "\\DL380-Server\pyTivo\transfers.txt"   >>  "\\DL380-Server\pyTivo\deleted.transfers.txt"
FINDSTR /I /L /V  "\TV\ \Cut"     "\\DL380-Server\pyTivo\transfers.txt"   >>  "\\DL380-Server\pyTivo\transfers.tmp"

TYPE NUL>   "\\DL380-Server\pyTivo\transfers.txt"
TYPE        "\\DL380-Server\pyTivo\transfers.tmp"             >>  "\\DL380-Server\pyTivo\transfers.txt"

SORT  /R    "\\DL380-Server\pyTivo\pushed.txt"                /O  "\\DL380-Server\pyTivo\pushed.txt"
SORT  /R    "\\DL380-Server\pyTivo\transfers.txt"             /O  "\\DL380-Server\pyTivo\transfers.txt"
SORT  /R    "\\DL380-Server\pyTivo\deleted.transfers.txt"     /O  "\\DL380-Server\pyTivo\deleted.transfers.txt"

DEL         "\\DL380-Server\pyTivo\transfers.tmp"

:Loop
::-----------------------------------------::
:: Process all files until arguments empty ::
::-----------------------------------------::
IF "%~1"=="" GOTO Done

:Look
::-----------------------------------------::
:: Parse conf file looking for containers  ::
::-----------------------------------------::
FOR /F "usebackq delims=[]" %%A IN (`type "\\DL380-Server\pyTivo\pytivo.conf" ^|FINDSTR "["`) DO (
	FOR /F %%B IN ('ECHO "%~1" ^|FIND /C "%%A"') DO (
		IF %%B EQU 1 SET Container=%%A
		IF DEFINED Container GOTO Found
	)
)
ECHO pyTivo container not found.
ECHO File not pushed.
GOTO End

:Found
::-----------------------------------------::
:: Container found, create variables       ::
::-----------------------------------------::
SET DisplayFile=%~1
SET File=%~1
SET File=!File:*%Container%=!
SET File=!File:\=/!
SET File=!File: =+!
SET ThisPath=%~dp1
SET ThisPath=!ThisPath:~0,-1!

:MetaData
::-----------------------------------------::
:: Create metadata if there isn't any      ::
::-----------------------------------------::
IF NOT EXIST "%~dpnx1.txt" (
	IF NOT EXIST "%~dp1\.meta\%~nx1.txt" (
		"\\DL380-Server\lan path\pyTivoMetaThis.py" -d -p "!ThisPath!"
	)
)
IF NOT EXIST "%~dpnx1.txt" (
	IF NOT EXIST "%~dp1\.meta\%~nx1.txt" (
		>"%~dpnx1.txt" ECHO episodeTitle : "%~n1"
	)
)

:Push
::-----------------------------------------::
:: Request pytivo PUSH of files using cURL ::
::-----------------------------------------::
IF /I "%tsn%" EQU "TivoS3" (
    SET port=9033
) ELSE (
    SET port=9033
)

IF EXIST "!ThisPath!\Push.Results.txt" DEL "!ThisPath!\Push.Results.txt"

ECHO Pushing: %DisplayFile%
curl.exe -s -d "Command=Push&Container=%Container%&File=!File!&tsn=%tsn%" "http://DL380-Server:%port%/TivoConnect?" >>"!ThisPath!\Push.Results.txt"

FOR /F "tokens=5,12,16 delims=^<^>" %%A IN ('FINDSTR /R "\<<.>\>" "!ThisPath!\Push.Results.txt"') DO (
	@ECHO %date:~-10% %time:~0,8% %%A >>"!ThisPath!\Push.Results.txt"
	@ECHO %date:~-10% %time:~0,8% %%B >>"!ThisPath!\Push.Results.txt"
	@ECHO %date:~-10% %time:~0,8% %%C >>"!ThisPath!\Push.Results.txt"
)

:End
::-----------------------------------------::
:: File is done, go get next one           ::
::-----------------------------------------::
SHIFT
GOTO Loop

:Done
::-----------------------------------------::
:: Files done. Go back from wence you came ::
::-----------------------------------------::
EXIT /B

:Trim_File
SET File=%*
GOTO :EOF
The batch would be called like this: Push.To.TiVo.bat <TiVo name> "<Full path to video file>"

The first part of the batch sets up the environment, and gathers the TiVo name I want to push to from "%1", and then "shifts" that first argument away.

The "Housekeeping" section reads a text file created by a pyTivo hack that lists successfully transferred files, and deletes a variety of different files within my "TV" and "Cut Programs" directories only. This is merely a disk maintenance step, and not really pertinent to the "push" functionality.


The "Loop" section is only there if I want to push more that one file.


The "Look" section parses through the pytivo.conf file, looking for pyTivo Share names (or container) that are found within the path of the file I'm trying to push. If a Share name can't be found, the batch ends since pyTiVo wouldn't know where to find the file to push.


The "Found" section manipulates the "File" variable derived from the file path, starting at the container name, making it "url" friendly by replacing spaces with pluses, and back-slashes with forward-slashes. As an example, with TV being the name of a Share or container:

File="C:\Videos\TV\Smallville\Clark Kent goes to Washington.mpg"
would turn into:
File="/Smallville/Clark+Kent+goes+to+Washington.mpg"

pyTivo already knows that the "TV" container is rooted at "C:\Videos\TV" from the conf file.


The "MetaData" section should be self explanatory.


The "Push" section starts off by selecting a port number based on TiVo name. I've had occasion where I needed two instances of pyTivo running to connect to an alternate mind server (NTTABs).

I log the results of the push in a text file, so some clean up is done to allow this.

Next, cURL is used to actually make the push request to pyTivo, with the results captured into the text file.

After variable substitution:

curl.exe -s -d "Command=Push&Container=%Container%&File=!File!&tsn=%tsn %" "http://DL380-Server:%port%/TivoConnect?"

would look like:

curl.exe -s -d "Command=Push&Container=TV&File=/Smallville/Clark+Kent+goes+to+Washington.mpg&tsn=TivoS3" "http://DL380-Server:9033/TivoConnect?"


The "End" section shifts the file name argument out, and goes to the Loop label to start all over.


The "Done" section will actually exit the batch file once all files have completed.


The "Trim_File" section merely drops trailing blanks from the file name, and only relates to the "Housekeeping" section.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by orangeboy : 03-28-2011 at 04:17 PM. Reason: Added cURL variable substitution example
orangeboy is offline   Reply With Quote
Old 03-29-2011, 07:58 PM   #144
NatasNJ
Bone marrow lover!
 
NatasNJ's Avatar
 
Join Date: Jan 2002
Location: Garden State BABY! NJ!
Posts: 10,647
Not sure if this is the right place to ask but figured it can't hurt.

I installed and had pyTivo running for months on end with no problems. Well tonight I went into my list and no longer see the WHS icon. Both my TivoHD's don't see it they BOTH however see the HP WHS EX495 Server which is where my WHS pytivo videos are housed.

So I don't think it is a connection (wifi) issue since I can see and access the EX495. I tried rebooting the TIVO. No luck.
I tried logging into the EX495 and stopping/starting the Pytivo service. No luck.
__________________
--------------------------------------------------
Xbox360 Gamertag = NatasNJ
--------------------------------------------------
NatasNJ is offline   Reply With Quote
Old 03-29-2011, 08:21 PM   #145
orangeboy
yes, I AM orangeboy!
 
Join Date: Apr 2004
Location: Moline, IL
Posts: 4,075
Quote:
Originally Posted by NatasNJ View Post
Not sure if this is the right place to ask but figured it can't hurt.

I installed and had pyTivo running for months on end with no problems. Well tonight I went into my list and no longer see the WHS icon. Both my TivoHD's don't see it they BOTH however see the HP WHS EX495 Server which is where my WHS pytivo videos are housed.

So I don't think it is a connection (wifi) issue since I can see and access the EX495. I tried rebooting the TIVO. No luck.
I tried logging into the EX495 and stopping/starting the Pytivo service. No luck.
Here would be the place to ask: http://www.tivocommunity.com/tivo-vb...d.php?t=328459
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
orangeboy is offline   Reply With Quote
Old 03-30-2011, 09:27 AM   #146
jbernardis
Registered User
 
Join Date: Oct 2003
Location: Princeton NJ
Posts: 1,064
OK - so I incorporated orangeboy's suggestion into the code, and now I can send the push request to pytivo. I even get back the response that the file is queued. However, the blue light never comes on and the push never occurs. This happened late last night and I haven't had a chance to diagnose it yet. This morning before I left for work, I logged onto my NAS, emptied the pytivo log file, fired up the HME script and requested a push. Again, I got the "queued for push" message. I wasn't able to wait to see if the push started - I had to leave for work. But I'll check this evening and report my findings. This way, the log file should contain ONLY messages dealing with my push request, so hopefully there'll be fewer messages to focus in on.

If I'm still baffled, I'll post my code, program output, and log file contents.
__________________
2 Series 3
1 HDTivo
1 Series 1 (Lifetime)
1 Win7 HTPC with Ceton Quad Tuner


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
jbernardis is offline   Reply With Quote
Old 04-03-2011, 04:05 PM   #147
jbernardis
Registered User
 
Join Date: Oct 2003
Location: Princeton NJ
Posts: 1,064
OK - I have put the first version of my HME application up on github. The installation instructions are in the included README file, but basically, this program is meant to be run under wmcbrine's python HME. WIth it, you can request that videos be pushed to your tivo. You can also delete files.

Be kind with your criticism. Although a programmer for 30+ years, OO programming has never been my strong suit. Also, this is my first use of Python, so I'm still learning the finer points of the language.

The source code can be found here.

Thanks
__________________
2 Series 3
1 HDTivo
1 Series 1 (Lifetime)
1 Win7 HTPC with Ceton Quad Tuner


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
jbernardis is offline   Reply With Quote
Old 04-03-2011, 05:04 PM   #148
orangeboy
yes, I AM orangeboy!
 
Join Date: Apr 2004
Location: Moline, IL
Posts: 4,075
Bah. I can't get ConfigParser to open config.ini. This is even in HME's "start.py". With no config.ini being available, I get "No Tivos found - exiting".

Windows XP,
python 2.6.6
python HME v0.19
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by orangeboy : 04-03-2011 at 06:15 PM.
orangeboy is offline   Reply With Quote
Old 04-03-2011, 06:13 PM   #149
jbernardis
Registered User
 
Join Date: Oct 2003
Location: Princeton NJ
Posts: 1,064
Quote:
Originally Posted by orangeboy View Post
I don't see config.merge in the zip file
My screw-up. It's there now.
__________________
2 Series 3
1 HDTivo
1 Series 1 (Lifetime)
1 Win7 HTPC with Ceton Quad Tuner


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
jbernardis is offline   Reply With Quote
Old 04-03-2011, 06:17 PM   #150
orangeboy
yes, I AM orangeboy!
 
Join Date: Apr 2004
Location: Moline, IL
Posts: 4,075
Quote:
Originally Posted by jbernardis View Post
My screw-up. It's there now.
No worries. I used the info out of the Readme. I'm just having issues with HME for Python, and not necessarily your app!
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
orangeboy is offline   Reply With Quote
Reply
Forum Jump




Thread Tools


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Advertisements

TiVo Community
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
vBulletin Skins by: Relivo Media

(C) 2013 Magenium Solutions - All Rights Reserved. No information may be posted elsewhere without written permission.
TiVoŽ is a registered trademark of TiVo Inc. This site is not owned or operated by TiVo Inc.
All times are GMT -5. The time now is 05:01 AM.
OUR NETWORK: MyOpenRouter | TechLore | SansaCommunity | RoboCommunity | MediaSmart Home | Explore3DTV | Dijit Community | DVR Playground |