2323import os
2424import os .path
2525import typing as ty
26+ from copy import deepcopy
2627
2728import click
2829
@@ -350,6 +351,13 @@ def scenedetect(
350351 )
351352
352353
354+ def add_hidden_alias (command : click .Command , alias : str ):
355+ """Adds a copy of `command` that can be invoked under the name `alias`."""
356+ hidden_command = deepcopy (command )
357+ hidden_command .hidden = True
358+ scenedetect .add_command (hidden_command , alias )
359+
360+
353361@click .command ("help" , cls = Command )
354362@click .argument (
355363 "command_name" ,
@@ -359,6 +367,7 @@ def scenedetect(
359367@click .pass_context
360368def help_command (ctx : click .Context , command_name : str ):
361369 """Print full help reference."""
370+ # TODO: Other commands still seem to run if this is specified.
362371 assert isinstance (ctx .parent .command , click .MultiCommand )
363372 parent_command = ctx .parent .command
364373 all_commands = set (parent_command .list_commands (ctx ))
@@ -973,45 +982,45 @@ def load_scenes_command(
973982 )
974983
975984
976- EXPORT_HTML_HELP = """Export scene list to HTML file.
985+ SAVE_HTML_HELP = """Save scene list to HTML file.
977986
978- To customize image generation, specify the `save-images` command before `export -html`. This command always uses the result of the preceeding `save-images` command, or runs it with the default config values unless `--no-images` is set.
987+ To customize image generation, specify the `save-images` command before `save -html`. This command always uses the result of the preceeding `save-images` command, or runs it with the default config values unless `--no-images` is set.
979988"""
980989
981990
982- @click .command ("export -html" , cls = Command , help = EXPORT_HTML_HELP )
991+ @click .command ("save -html" , cls = Command , help = SAVE_HTML_HELP )
983992@click .option (
984993 "--filename" ,
985994 "-f" ,
986995 metavar = "NAME" ,
987996 default = "$VIDEO_NAME-Scenes.html" ,
988997 type = click .STRING ,
989998 help = "Filename format to use for the scene list HTML file. You can use the $VIDEO_NAME macro in the file name. Note that you may have to wrap the format name using single quotes.%s"
990- % (USER_CONFIG .get_help_string ("export -html" , "filename" )),
999+ % (USER_CONFIG .get_help_string ("save -html" , "filename" )),
9911000)
9921001@click .option (
9931002 "--no-images" ,
9941003 "-n" ,
9951004 is_flag = True ,
9961005 flag_value = True ,
9971006 help = "Do not include images with the result.%s"
998- % (USER_CONFIG .get_help_string ("export -html" , "no-images" )),
1007+ % (USER_CONFIG .get_help_string ("save -html" , "no-images" )),
9991008)
10001009@click .option (
10011010 "--image-width" ,
10021011 "-w" ,
10031012 metavar = "pixels" ,
10041013 type = click .INT ,
10051014 help = "Width in pixels of the images in the resulting HTML table.%s"
1006- % (USER_CONFIG .get_help_string ("export -html" , "image-width" , show_default = False )),
1015+ % (USER_CONFIG .get_help_string ("save -html" , "image-width" , show_default = False )),
10071016)
10081017@click .option (
10091018 "--image-height" ,
10101019 "-h" ,
10111020 metavar = "pixels" ,
10121021 type = click .INT ,
10131022 help = "Height in pixels of the images in the resulting HTML table.%s"
1014- % (USER_CONFIG .get_help_string ("export -html" , "image-height" , show_default = False )),
1023+ % (USER_CONFIG .get_help_string ("save -html" , "image-height" , show_default = False )),
10151024)
10161025@click .option (
10171026 "--show" ,
@@ -1020,34 +1029,33 @@ def load_scenes_command(
10201029 flag_value = True ,
10211030 default = None ,
10221031 help = "Automatically open resulting HTML when processing is complete.%s"
1023- % (USER_CONFIG .get_help_string ("export -html" , "show" )),
1032+ % (USER_CONFIG .get_help_string ("save -html" , "show" )),
10241033)
10251034@click .pass_context
1026- def export_html_command (
1035+ def save_html_command (
10271036 ctx : click .Context ,
10281037 filename : ty .Optional [ty .AnyStr ],
10291038 no_images : bool ,
10301039 image_width : ty .Optional [int ],
10311040 image_height : ty .Optional [int ],
10321041 show : bool ,
10331042):
1034- # TODO: Rename this command to save-html to align with other export commands. This will require
1035- # that we allow `export-html` as an alias on the CLI and via the config file for a few versions
1036- # as to not break existing workflows.
1043+ if ctx .command .name == "save-html" :
1044+ logger .warning ("WARNING: export-html is deprecated, use save-html instead." )
10371045 ctx = ctx .obj
10381046 assert isinstance (ctx , CliContext )
1039- include_images = not ctx .config .get_value ("export -html" , "no-images" , no_images )
1047+ include_images = not ctx .config .get_value ("save -html" , "no-images" , no_images )
10401048 # Make sure a save-images command is in the pipeline for us to use the results from.
10411049 if include_images and not ctx .save_images :
10421050 save_images_command .callback ()
1043- export_html_args = {
1044- "html_name_format" : ctx .config .get_value ("export -html" , "filename" , filename ),
1045- "image_width" : ctx .config .get_value ("export -html" , "image-width" , image_width ),
1046- "image_height" : ctx .config .get_value ("export -html" , "image-height" , image_height ),
1051+ save_html_args = {
1052+ "html_name_format" : ctx .config .get_value ("save -html" , "filename" , filename ),
1053+ "image_width" : ctx .config .get_value ("save -html" , "image-width" , image_width ),
1054+ "image_height" : ctx .config .get_value ("save -html" , "image-height" , image_height ),
10471055 "include_images" : include_images ,
1048- "show" : ctx .config .get_value ("export -html" , "show" , show ),
1056+ "show" : ctx .config .get_value ("save -html" , "show" , show ),
10491057 }
1050- ctx .add_command (cli_commands .export_html , export_html_args )
1058+ ctx .add_command (cli_commands .save_html , save_html_args )
10511059
10521060
10531061LIST_SCENES_HELP = """Create scene list CSV file (will be named $VIDEO_NAME-Scenes.csv by default).
@@ -1509,7 +1517,7 @@ def save_images_command(
15091517 }
15101518 ctx .add_command (cli_commands .save_images , save_images_args )
15111519
1512- # Record that we added a save-images command to the pipeline so we can allow export -html
1520+ # Record that we added a save-images command to the pipeline so we can allow save -html
15131521 # to run afterwards (it is dependent on the output).
15141522 ctx .save_images = True
15151523
@@ -1585,8 +1593,11 @@ def save_qp_command(
15851593scenedetect .add_command (detect_threshold_command )
15861594
15871595# Output
1588- scenedetect .add_command (export_html_command )
1596+ scenedetect .add_command (save_html_command )
15891597scenedetect .add_command (save_qp_command )
15901598scenedetect .add_command (list_scenes_command )
15911599scenedetect .add_command (save_images_command )
15921600scenedetect .add_command (split_video_command )
1601+
1602+ # Deprecated Commands (Hidden From Help Output)
1603+ add_hidden_alias (save_html_command , "export-html" ) # Deprecated in v0.6.6, replaced with save-html
0 commit comments