VideoHelp Forum




+ Reply to Thread
Results 1 to 3 of 3
  1. I made a Python code based on command-line VideoSubFinder

    https://github.com/eritpchy/videosubfinder-cli

    This is an excerpt from the code.
    Code:
    `video_file = testvideo.mp4
    
    output_file = "C:/myprogram/output"
    
    command = [     videosubfinder_path,     "-c", "-r",     "-i", video_file,     "-o" , output_file, ]`
    All I need to do is add the this code:

    Code:
    `video_file.rsplit(".", 1)[0] + "_output" `
    in

    Code:
    output_file = "C:/myprogram/output/" (video_file.rsplit(".", 1)[0] + "_output")
    It keeps a folder file in a special folder + with the same video name.

    Code:
    C:/myprogram/output/testvideo_output
    Quote Quote  
  2. try this:
    Code:
    from pathlib import Path
    
    # make Path objects from string paths
    video_file = Path("testvideo.mp4")
    output_file = Path(r"C:/myprogram/output")
    
    # get directory path
    output_file = output_file / f"{video_file.stem}_output"
    
    # create directory if it doesn't exist
    output_file.mkdir(parents=True, exist_ok=True)
    
    # use strings for paths again instead of Path objects in command line
    # also enveloping like that in quotes you make sure there can be spaces in paths
    command = [f"{videosubfinder_path}", "-c", "-r", "-i", f"{video_file}", "-o", f"{output_file}", ]
    While working with paths it is a good idea to switch to use pathlib module. It can manipulate paths more clearly, it is more readable.
    But when using those paths again in app, it needs to be switched back to strings, most apps do not accept Path objects, just path strings.
    You can use str(path_object) or using f string formatting as used in example, because paths need to be enveloped by quotes, to be safe, if there are spaces in path strings and it is much more readable with those f strings.
    Quote Quote  
  3. Thanks for the reply. I tried to add a path but it gives me errors. I will send you the full code in a private message.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!