Update of /cvsroot/freevo/freevo/src/helpers
In directory sc8-pr-cvs1:/tmp/cvs-serv18808/src/helpers

Modified Files:
        tv_grab.py 
Log Message:
Placed most of the work into functions and added a check for '__main__' for
the command line.  I'm planning on importing this module from recordserver 
and calling functions to grab and sort listings at a configurable time.

Alco changed '-query' to '--query' for consistency's sake.


Index: tv_grab.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/helpers/tv_grab.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** tv_grab.py  15 Oct 2003 19:26:55 -0000      1.3
--- tv_grab.py  20 Oct 2003 00:32:11 -0000      1.4
***************
*** 12,15 ****
--- 12,22 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.4  2003/10/20 00:32:11  rshortt
+ # Placed most of the work into functions and added a check for '__main__' for
+ # the command line.  I'm planning on importing this module from recordserver
+ # and calling functions to grab and sort listings at a configurable time.
+ #
+ # Alco changed '-query' to '--query' for consistency's sake.
+ #
  # Revision 1.3  2003/10/15 19:26:55  rshortt
  # The channel number portion of TV_CHANNELS entries is handled as a string,
***************
*** 49,114 ****
  import sys
  import os
  
  import config
- import util
  
  def usage():
      print 'Downloads the listing for xmltv and cache the data'
      print
!     print 'usage: freevo tv_grab [ -query ]'
      print 'options:'
!     print '  -query:  print a list of all stations. The list can be used to set 
TV_CHANNELS'
      sys.exit(0)
  
  
! if len(sys.argv)>1 and sys.argv[1] == '--help':
!     usage()
!     
! if not config.XMLTV_GRABBER:
!     print 'No program found to grab the listings. Please set XMLTV_GRABBER'
!     print 'in local.conf.py to the grabber you need'
!     print
!     usage()
  
- QUERY = 0
- if len(sys.argv)>1 and sys.argv[1] == '-query':
-     QUERY = 1
-     
- if not os.path.isfile(config.XMLTV_FILE) or not QUERY:
      print 'Grabbing listings.'
!     os.system('%s --output %s --days %s' % ( config.XMLTV_GRABBER, config.XMLTV_FILE,
                                               config.XMLTV_DAYS ))
  
! if os.path.isfile(config.XMLTV_SORT):
!     print 'Sorting listings.'
!     os.system('%s --output %s %s' % ( config.XMLTV_SORT, config.XMLTV_FILE,
!                                              config.XMLTV_FILE ))
  
- print
- print 'searching for station information'
- chanlist = config.detect_channels()
  
! if QUERY:
!     print
!     print 'Possible list of tv channels. If you want to change the station'
!     print 'id, copy the next statement into your local_conf.py and edit it.'
!     print 'You can also remove lines or resort them'
!     print
!     print 'TV_CHANNELS = ['
!     for c in chanlist[:-1]:
!         print '    ( \'%s\', \'%s\', \'%s\' ), ' % c
!     print '    ( \'%s\', \'%s\', \'%s\' ) ] ' % chanlist[-1]
!     sys.exit(0)
  
! print 'caching data, this may take a while'
  
- import tv.epg_xmltv
- tv.epg_xmltv.get_guide()
  
! import tv.record_client as rc
  
! print 'Scheduling favorites for recording:  '
  
- (result, response) = rc.updateFavoritesSchedule()
- print '    %s' % response
  
--- 56,141 ----
  import sys
  import os
+ import shutil
  
  import config
  
  def usage():
      print 'Downloads the listing for xmltv and cache the data'
      print
!     print 'usage: freevo tv_grab [ --query ]'
      print 'options:'
!     print '  --query:  print a list of all stations. The list can be used to set 
TV_CHANNELS'
      sys.exit(0)
  
  
! def grab():
!     if not config.XMLTV_GRABBER:
!         print 'No program found to grab the listings. Please set XMLTV_GRABBER'
!         print 'in local.conf.py to the grabber you need'
!         print
!         usage()
  
      print 'Grabbing listings.'
!     xmltvtmp = '/tmp/TV.xml.tmp'
!     os.system('%s --output %s --days %s' % ( config.XMLTV_GRABBER, 
!                                              xmltvtmp,
                                               config.XMLTV_DAYS ))
  
!     if os.path.exists(xmltvtmp):
!         shutil.copyfile(xmltvtmp, config.XMLTV_FILE)
!         os.unlink(xmltvtmp)
  
  
! def sort():
!     if os.path.isfile(config.XMLTV_SORT):
!         print 'Sorting listings.'
!         xmltvtmp = '/tmp/TV.xml.tmp'
!         os.system('%s --output %s %s' % ( config.XMLTV_SORT,
!                                           xmltvtmp,
!                                           config.XMLTV_FILE ))
  
!         if os.path.exists(xmltvtmp):
!             shutil.copyfile(xmltvtmp, config.XMLTV_FILE)
!             os.unlink(xmltvtmp)
!     else:
!         print 'Not configured to use tv_sort, skipping.'
  
  
! if __name__ == '__main__':
  
!     if len(sys.argv)>1 and sys.argv[1] == '--help':
!         usage()
!     
!     if len(sys.argv)>1 and sys.argv[1] == '--query':
!         print
!         print 'searching for station information'
! 
!         chanlist = config.detect_channels()
! 
!         print
!         print 'Possible list of tv channels. If you want to change the station'
!         print 'id, copy the next statement into your local_conf.py and edit it.'
!         print 'You can also remove lines or resort them'
!         print
!         print 'TV_CHANNELS = ['
!         for c in chanlist[:-1]:
!             print '    ( \'%s\', \'%s\', \'%s\' ), ' % c
!         print '    ( \'%s\', \'%s\', \'%s\' ) ] ' % chanlist[-1]
!         sys.exit(0)
! 
!     grab()
!     sort()
! 
!     print 'caching data, this may take a while'
! 
!     import tv.epg_xmltv
!     tv.epg_xmltv.get_guide()
! 
!     import tv.record_client as rc
!     
!     print 'Scheduling favorites for recording:  '
! 
!     (result, response) = rc.updateFavoritesSchedule()
!     print '    %s' % response
  
  




-------------------------------------------------------
This SF.net email sponsored by: Enterprise Linux Forum Conference & Expo
The Event For Linux Datacenter Solutions & Strategies in The Enterprise 
Linux in the Boardroom; in the Front Office; & in the Server Room 
http://www.enterpriselinuxforum.com
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to