Added index page that jumps to today, and made the last box disappear when you click...
[recordtv.git] / src / gtvg_download.py
blob42a02403cc6acebaf2b98ec0ab54ae57f7e1bd82
1 #!/usr/bin/python
3 import os, time
4 import gtvg_utils
6 def delete_old_xmltv_files( config ):
8 for fn in os.listdir( config.xmltv_files_dir ):
9 if fn[-6:] == ".xmltv":
11 full_fn = os.path.join( config.xmltv_files_dir, fn )
13 print "Deleting file '%s'" % full_fn
15 os.unlink( full_fn )
17 def download( config ):
18 gtvg_utils.ensure_dir_exists( config.xmltv_configs_dir )
19 gtvg_utils.ensure_dir_exists( config.xmltv_files_dir )
21 # NOTE: alternatively we could move them to a different dir?
22 delete_old_xmltv_files( config )
24 if not os.path.isfile( config.xmltv_config_file ):
26 if config.options.interactive:
27 gtvg_utils.run_command( config.xmltv_config_command )
29 if not os.path.isfile( config.xmltv_config_file ):
30 raise Exception( "Tried to configure XMLTV, but the "
31 + "config file '" + config.xmltv_config_file
32 + "' still does not exist." )
33 else:
34 raise Exception( "The XMLTV config file '%s' does not exist!"
35 % config.xmltv_config_file )
37 date_filename = time.strftime( "tv-%Y-%m-%d.xmltv", time.localtime() )
38 gtvg_utils.run_command_write_output( config.xmltv_download_command,
39 os.path.join( config.xmltv_files_dir, date_filename ) )