Prevent malicious users from supplying directories containing ".." etc. for path...
[recordtv.git] / src / recordtv
blob8d191df9b44f48ac5800675205080b3311c5a896
1 #!/usr/bin/python
3 from optparse import OptionParser
4 import rtv_download, rtv_schedule, rtv_tvguide, rtv_delete, rtv_convert
5 from rtv_config import GTVGConfig
7 def main():
8 parser = OptionParser()
10 parser.add_option( "-d", "--download-listings", action="store_true",
11 dest="download", default = False,
12 help="download listings using XMLTV" )
14 parser.add_option("-s", "--schedule-recordings", action="store_true",
15 dest="schedule", default=False,
16 help="schedule today's recordings")
18 parser.add_option("-e", "--delete-old", action="store_true",
19 dest="delete", default=False,
20 help="delete recordings marked as deleted in web interface")
22 parser.add_option("-c", "--convert", action="store_true",
23 dest="convert", default=False,
24 help="convert recorded programmes to a different format")
26 parser.add_option("-r", "--rename", action="store_true",
27 dest="rename", default=False,
28 help="renamed converted programmes to the current naming scheme")
30 parser.add_option("-i", "--interactive", action="store_true",
31 dest="interactive", default=False,
32 help="ask the user if input is needed")
34 parser.add_option("-n", "--install-dir", dest="install_dir",
35 help="supply the install directory", metavar="INSTDIR" )
37 parser.add_option("-g", "--generate-html-guide", action="store_true",
38 dest="generate_html", default=False,
39 help="generate a TV guide in HTML form")
41 parser.set_defaults( install_dir=".." )
43 ( options, args ) = parser.parse_args()
45 config = GTVGConfig( options, args )
47 if options.download:
48 rtv_download.download( config )
50 if options.schedule:
51 rtv_schedule.schedule( config )
53 if options.delete:
54 rtv_delete.delete( config )
56 if options.convert:
57 rtv_convert.convert( config )
59 if options.rename:
60 rtv_convert.rename( config )
62 if options.generate_html:
63 rtv_tvguide.generate( config )
65 if __name__ == "__main__":
66 main()