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
17 def download( config
):
18 rtv_utils
.ensure_dir_exists( config
.xmltv_configs_dir
)
19 rtv_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 rtv_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." )
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 rtv_utils
.run_command_write_output( config
.xmltv_download_command
,
39 os
.path
.join( config
.xmltv_files_dir
, date_filename
) )