Update of /cvsroot/freevo/freevo/WIP/RobShortt/helpers
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30909
Added Files:
instant_record.py test_url_record.py tv_grab_add_dvb.py
url_record.py v4l2-test.py
Log Message:
Some of these don't have much purpose other than testing but I wanted to
get them in here.
--- NEW FILE: v4l2-test.py ---
import time, string
import tv.v4l2, config, tv.ivtv
if __name__ == '__main__':
# TV_SETTINGS = 'NORM INPUT CHANLIST DEVICE'
(v_norm, v_input, v_clist, v_dev) = config.TV_SETTINGS.split()
# v = v4l2.Videodev(v_dev)
v = tv.ivtv.IVTV(v_dev)
v.init_settings()
print "Setting Channel to 17"
v.setchannel("17")
v.print_settings()
#now = time.time()
#stop = now + 10
#v_in = open('/dev/video0', 'r')
#v_out = open('/tmp/vtest.mpeg', 'w')
#while time.time() < stop:
# buf = v_in.read(65536)
# v_out.write(buf)
#v_in.close()
#v_out.close()
# print 'Calling MSP_SET_MATRIX'
# v.mspSetMatrix()
v.close()
--- NEW FILE: instant_record.py ---
import time, string, signal
import config, tv.ivtv
class Capture:
def __init__(self):
self.stop_flag = 0
def capture(self):
# TV_SETTINGS = 'NORM INPUT CHANLIST DEVICE'
(v_norm, v_input, v_clist, v_dev) = config.TV_SETTINGS.split()
v = tv.ivtv.IVTV(v_dev)
v.init_settings()
v.setinput(4)
v.print_settings()
now = time.time()
stop = now + 10
v_in = open('/dev/video0', 'r')
v_out = open('/var/media/Video/Recorded/test.mpeg', 'w')
while time.time() < stop:
buf = v_in.read(65536)
v_out.write(buf)
if self.stop_flag:
print 'Stop flag found, stopping capture.'
break
v_in.close()
v_out.close()
v.close()
def signal_handler(sig, frame):
global C
if sig in (signal.SIGTERM, signal.SIGINT):
print 'Setting stop flag!'
C.stop_flag = 1
C = Capture()
signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGINT, signal_handler)
C.capture()
--- NEW FILE: test_url_record.py ---
import urllib, time, sys
import config
DEBUG = config.DEBUG
CHUNKSIZE = 1024 * 128
SAVE_FILE = '/tmp/test_url_record.mpeg'
if __name__ == '__main__':
if len(sys.argv) < 3:
print 'Usage: url_record <channel> <seconds to record>'
sys.exit(0)
URL = 'http://localhost:3080/PS/%s' % sys.argv[1]
LENGTH = int(sys.argv[2])
data = urllib.urlopen(URL)
save_file = open(SAVE_FILE, 'w')
print 'Saving to file: %s' % SAVE_FILE
now = time.time()
stop = now + LENGTH
while time.time() < stop:
buf = data.read(CHUNKSIZE)
if DEBUG: print 'Got %d bytes' % CHUNKSIZE
save_file.write(buf)
print 'Finished.'
data.close()
save_file.close()
--- NEW FILE: url_record.py ---
import urllib, time, sys
import config
DEBUG = config.DEBUG
CHUNKSIZE = 1024 * 128
if __name__ == '__main__':
if len(sys.argv) < 4:
print 'Usage: url_record <URL> <save file> <seconds to record>'
sys.exit(0)
URL = sys.argv[1]
SAVE_FILE = sys.argv[2]
LENGTH = sys.argv[3]
data = urllib.urlopen(URL)
save_file = open(SAVE_FILE, 'w')
print 'Saving to file: %s' % SAVE_FILE
now = time.time()
stop = now + int(LENGTH)
while time.time() < stop:
buf = data.read(CHUNKSIZE)
if DEBUG: print 'Got %d bytes' % CHUNKSIZE
save_file.write(buf)
print 'Finished.'
data.close()
save_file.close()
--- NEW FILE: tv_grab_add_dvb.py ---
#!/usr/bin/env python
#if 0 /*
# -----------------------------------------------------------------------
# .py -
# -----------------------------------------------------------------------
# $Id: tv_grab_add_dvb.py,v 1.1 2004/07/24 00:49:11 rshortt Exp $
#
# Notes:
#
# Todo:
#
# -----------------------------------------------------------------------
# $Log: tv_grab_add_dvb.py,v $
# Revision 1.1 2004/07/24 00:49:11 rshortt
# Some of these don't have much purpose other than testing but I wanted to
# get them in here.
#
#
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2002 Krister Lagerstrom, et al.
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# ----------------------------------------------------------------------- */
#endif
import sys, os, shutil, urllib, time
import config
XMLTV_CAT = '/usr/local/bin/tv_cat'
DVB_XML = '/tmp/TV.xml-dvb'
DVB_GRAB = '/media/bin/tv_grab_dvb -f /media/vdr/channels.conf > %s' % DVB_XML
EPG_URL = 'http://localhost:3080/PS/20442'
def usage():
print 'A simple helper to get DVB EPG info and add it to your XMLTV_FILE.'
sys.exit(0)
def grab():
xmltv_old = '/tmp/TV.xml-orig'
xmltv_tmp = '/tmp/TV.xml.1'
print 'Tuning to EPG transponder.'
# Get streamdev-server to tune to a channel on the same tp as our guide.
data = urllib.urlopen(EPG_URL)
chunks = 1024*128
mustread = 1024*1024
read = 0
while read < mustread:
buf = data.read(chunks)
read += chunks
print 'RLS: read a chunk.'
data.close()
time.sleep(2)
shutil.copyfile(config.XMLTV_FILE, xmltv_old)
print 'Grabbing DVB listings.'
os.system(DVB_GRAB)
time.sleep(1)
print 'Combining listings.'
os.system('%s --output %s %s %s' % ( XMLTV_CAT,
xmltv_tmp,
xmltv_old,
DVB_XML ))
if os.path.exists(xmltv_tmp):
print 'Caching data, this may take a while'
import tv.epg_xmltv
tv.epg_xmltv.get_guide(XMLTV_FILE=xmltv_tmp)
if __name__ == '__main__':
if len(sys.argv)>1 and sys.argv[1] == '--help':
usage()
grab()
import tv.record_client as rc
print 'Scheduling favorites for recording: '
(result, response) = rc.updateFavoritesSchedule()
print ' %s' % response
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog