zaytiri / handbrake-recursive-folder-video-converter

An automatic video converter using HandBrake CLI to batch convert all files found in recursive mode. All videos found on folders will be converted on original location while original file will be transfered to another folder for easy removal.
https://pypi.org/project/havc/
MIT License
10 stars 1 forks source link

Loss of path during recursion #1

Closed Technetium1 closed 1 year ago

Technetium1 commented 1 year ago

Command that works when only going one dir deep: havc --root "C:\ProgramData\chocolatey\bin" --convert "D:\Comedy" --extensions avi m4v mkv mov mp2 mpeg mpg vob wmv --target mp4 --delete-folder "D:\_CONVERTED" --custom-command "--preset='H.265 NVENC 1080p' --all-subtitles --optimize -i {of} -o {cf}"

Expected valid path: "D:\Comedy\Andrew Santino - Cheeseburger (2023)\Andrew Santino - Cheeseburger (2023).mkv" Invalid path after losing the parent dir: "D:\Comedy\Andrew Santino - Cheeseburger (2023).mkv"

LOG:

All files found with the a .avi or .mkv or .mov or .mp2 or .mpeg or .mpg or .vob or .wmv extension are going to be converted to .mp4 extension and be kept in the "D:\_CONVERTED" folder.
"D:\Comedy" is going to be modified permanently.

Are you sure you want to continue?
 [Y/n]
['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Andrew Santino - Cheeseburger (2023).mkv -o D:\Comedy\Andrew Santino - Cheeseburger (2023).mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Bert.Kreisher.The.Machine.2016.mkv -o D:\Comedy\Bert.Kreisher.The.Machine.2016.mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Dave Chapelle - Killing Them Softly (stand up comedy) 2000.avi -o D:\Comedy\Dave Chapelle - Killing Them Softly (stand up comedy) 2000.mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Dave Chapelle - Sticks and Stones (2019).mkv -o D:\Comedy\Dave Chapelle - Sticks and Stones (2019).mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Dave Chappelle's Block Party (2005).mkv -o D:\Comedy\Dave Chappelle's Block Party (2005).mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Dave Chappelle - Deep in the Heart of Texas (2017).mkv -o D:\Comedy\Dave Chappelle - Deep in the Heart of Texas (2017).mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Dave Chappelle Equanimity (2017) (1080p NF WEB-DL x265 10bit t3nzin).mkv -o D:\Comedy\Dave Chappelle Equanimity (2017) (1080p NF WEB-DL x265 10bit t3nzin).mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Dave.Chappelle.The.Age.of.Spin.2017.mkv -o D:\Comedy\Dave.Chappelle.The.Age.of.Spin.2017.mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Dave Chappelle The Bird Revelation (2017) (1080p NF WEB-DL x265 10bit t3nzin).mkv -o D:\Comedy\Dave Chappelle The Bird Revelation (2017) (1080p NF WEB-DL x265 10bit t3nzin).mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Jim Jefferies Bare 2014.mkv -o D:\Comedy\Jim Jefferies Bare 2014.mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\John Mulaney - Kid Gorgeous at Radio City (2018).mkv -o D:\Comedy\John Mulaney - Kid Gorgeous at Radio City (2018).mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Louis CK - Chewed Up (2008).avi -o D:\Comedy\Louis CK - Chewed Up (2008).mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\HBO.Comedy.One.Night.Stand.Louis.CK.2005.mkv -o D:\Comedy\HBO.Comedy.One.Night.Stand.Louis.CK.2005.mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Louis.CK.Live.At.The.Comedy.Store.2015.avi -o D:\Comedy\Louis.CK.Live.At.The.Comedy.Store.2015.mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Sorry.Louis.CK.2021.mkv -o D:\Comedy\Sorry.Louis.CK.2021.mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Ricky.Gervais.Humanity.2018.mkv -o D:\Comedy\Ricky.Gervais.Humanity.2018.mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Ricky Gervais Live IV - Science (2010) (1080p BluRay x265 Bandi).mkv -o D:\Comedy\Ricky Gervais Live IV - Science (2010) (1080p BluRay x265 Bandi).mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Meet Karl Pilkington II.mkv -o D:\Comedy\Meet Karl Pilkington II.mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Ricky in New York.mkv -o D:\Comedy\Ricky in New York.mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\When Karl Met Warwick.mkv -o D:\Comedy\When Karl Met Warwick.mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Taylor Tomlinson - Look at You (2022) (1080p NF WEB-DL x265 10bit t3nzin).mkv -o D:\Comedy\Taylor Tomlinson - Look at You (2022) (1080p NF WEB-DL x265 10bit t3nzin).mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Taylor Tomlinson - Quarter-Life Crisis (2020).mkv -o D:\Comedy\Taylor Tomlinson - Quarter-Life Crisis (2020).mp4

libdvdread: Encrypted DVD support unavailable.

['--preset=H.265 NVENC 1080p', '--all-subtitles', '--optimize', '-i', '{of}', '-o', '{cf}']
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --all-subtitles --optimize -i D:\Comedy\Tom.Segura.Ball.Hog.2020.1080p.WEB.X264-AMRAP[EtHD].mkv -o D:\Comedy\Tom.Segura.Ball.Hog.2020.1080p.WEB.X264-AMRAP[EtHD].mp4

libdvdread: Encrypted DVD support unavailable.

'}"' is not recognized as an internal or external command,
operable program or batch file.

Thanks for creating this!

zaytiri commented 1 year ago

Hello, it should be fixed now with the new commits and the new package version 1.1.2 on PyPi.

Please test it out and let me know. If it works please close this issue.

Thank you for contributing!

Technetium1 commented 1 year ago

Hi, I'll test this!

Technetium1 commented 1 year ago

Seems to be working fine in terms of folder recursion. Thanks for the fast fix! I have a new error though. There's no way to skip when it hits a duplicate file:

Muxing: this may take awhile...(741.28 fps, avg 706.33 fps, ETA 00h00m00s)

Encoding successfully done!

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\User\AppData\Roaming\Python\Python311\Scripts\havc.exe\__main__.py", line 7, in <module>
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\havc\app.py", line 36, in main
    videos.search()
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\havc\search.py", line 48, in search
    current_video_file.copy_to(sub_delete_folder)
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\havc\entities\video_file.py", line 51, in copy_to
    shutil.copyfile(original, target)
  File "C:\Program Files\Python311\Lib\shutil.py", line 236, in copyfile
    raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
shutil.SameFileError: 'D:\\Comedy\\Andrew Santino - Cheeseburger (2023)\\Andrew Santino - Cheeseburger (2023).mkv' and 'D:\\\\Comedy\\Andrew Santino - Cheeseburger (2023)\\Andrew Santino - Cheeseburger (2023).mkv' are the same file

Should I open a second issue?

zaytiri commented 1 year ago

Great!

Yes, please open another issue, I will take a look at it.

Thanks!

Technetium1 commented 1 year ago

Seems this is not actually fixed:

All files found with the a .avi or .m4v or .mkv or .mov or .mp2 or .mpeg or .mpg or .vob or .wmv extension are going to be converted to .mp4 extension and be kept in the "D:\_CONVERTED" folder.
"D:\Comedy\Taylor Tomlinson - Look at You (2022)" is going to be modified permanently.

Are you sure you want to continue?
 [Y/n]
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --subtitle-lang-list eng --optimize -i D:\Comedy\Taylor Tomlinson - Look at You (2022)\Taylor Tomlinson - Look at You (2022) (1080p NF WEB-DL x265 10bit t3nzin).mkv -o D:\Comedy\Taylor Tomlinson - Look at You (2022)\Taylor Tomlinson - Look at You (2022) (1080p NF WEB-DL x265 10bit t3nzin).mp4

libdvdread: Encrypted DVD support unavailable.
libdvdread: Can't open file VIDEO_TS.IFO.
Muxing: this may take awhile...(150.16 fps, avg 210.90 fps, ETA 00h00m00s)
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\User\AppData\Roaming\Python\Python311\Scripts\havc.exe\__main__.py", line 7, in <module>
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\havc\app.py", line 36, in main
    videos.search()
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\havc\search.py", line 44, in search
    sub_delete_folder = self.create_delete_folder_structure(root, new_main_delete_folder)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\havc\search.py", line 81, in create_delete_folder_structure
    return new_deleted_folder_directory.create_folder(to_delete_folder)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\havc\services\directory.py", line 26, in create_folder
    os.mkdir(new_directory)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'D:\\Comedy\\_CONVERTED\\Taylor Tomlinson - Look at You (2022)'
'{cf}"' is not recognized as an internal or external command,
operable program or batch file.

as well as:

All files found with the a .avi or .m4v or .mkv or .mov or .mp2 or .mpeg or .mpg or .vob or .wmv extension are going to be converted to .mp4 extension and be kept in the "D:\_CONVERTED" folder.
"D:\Comedy\Taylor Tomlinson - Quarter-Life Crisis (2020)" is going to be modified permanently.

Are you sure you want to continue?
 [Y/n]
Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --subtitle-lang-list eng --optimize -i D:\Comedy\Taylor Tomlinson - Quarter-Life Crisis (2020)\Taylor Tomlinson - Quarter-Life Crisis (2020).mkv -o D:\Comedy\Taylor Tomlinson - Quarter-Life Crisis (2020)\Taylor Tomlinson - Quarter-Life Crisis (2020).mp4

libdvdread: Encrypted DVD support unavailable.
libdvdread: Can't open file VIDEO_TS.IFO.
Muxing: this may take awhile... (332.02 fps, avg 200.52 fps, ETA 00h00m00s)
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\User\AppData\Roaming\Python\Python311\Scripts\havc.exe\__main__.py", line 7, in <module>
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\havc\app.py", line 36, in main
    videos.search()
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\havc\search.py", line 44, in search
    sub_delete_folder = self.create_delete_folder_structure(root, new_main_delete_folder)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\havc\search.py", line 81, in create_delete_folder_structure
    return new_deleted_folder_directory.create_folder(to_delete_folder)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\havc\services\directory.py", line 26, in create_folder
    os.mkdir(new_directory)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'D:\\Comedy\\_CONVERTED\\Taylor Tomlinson - Quarter-Life Crisis (2020)'
zaytiri commented 1 year ago

Hello, please update your version to the new one: 1.2.0

I changed some things regarding the code in those errors in the new version, please update the version and let me know if it fixed those too.

Thanks!

Technetium1 commented 1 year ago

Still have an issue, but it's skipping properly now:

All files found with the a .avi or .m4v or .mkv or .mov or .mp2 or .mpeg or .mpg or .vob or .wmv extension are going to be converted to .mp4 extension and be kept in the "D:\_CONVERTED" folder.
"D:\Comedy" is going to be modified permanently.

Are you sure you want to continue?
 [Y/n]
D:\Comedy\Andrew Santino - Cheeseburger (2023)\Andrew Santino - Cheeseburger (2023).mkv was skipped because file with same name already exists!

Current Command: C:\ProgramData\chocolatey\bin\HandBrakeCLI.exe --preset=H.265 NVENC 1080p --subtitle-lang-list eng --optimize -i D:\Comedy\Bert Kreisher - The Machine (2016)\Bert.Kreisher.The.Machine.2016.mkv -o D:\Comedy\Bert Kreisher - The Machine (2016)\Bert.Kreisher.The.Machine.2016.mp4

libdvdread: Encrypted DVD support unavailable.
libdvdread: Can't open file VIDEO_TS.IFO.
Muxing: this may take awhile... (681.27 fps, avg 655.24 fps, ETA 00h00m00s)

Encoding successfully done!

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\User\AppData\Roaming\Python\Python311\Scripts\havc.exe\__main__.py", line 7, in <module>
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\havc\app.py", line 37, in main
    videos.search()
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\havc\search.py", line 48, in search
    sub_delete_folder = self.create_delete_sub_folder(root, delete_folder)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\havc\search.py", line 80, in create_delete_sub_folder
    return delete_folder.create_folder(delete_folder_path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Roaming\Python\Python311\site-packages\havc\services\directory.py", line 26, in create_folder
    os.mkdir(new_directory)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'D:\\_CONVERTED\\Comedy\\Bert Kreisher - The Machine (2016)'
zaytiri commented 1 year ago

Hello, please update once again to version 1.2.1.

Let me know if it worked!

Thank you for your patience by the way 👍

Technetium1 commented 1 year ago

Everything looks good so far, I'll let the batch run and see how it goes! Thanks for the fast response times :smiley:

Technetium1 commented 1 year ago

Here's a log, valid for 29 days. Thanks once again! I'll include the BAT file for anyone else to use as a template if they want. I know it's ugly :upside_down_face:

@echo off
TITLE HAVC CONVERTER

pip install --user -U havc
cls
ECHO INSTALLED HAVC!

ECHO ENTERING D:
cd /d "D:\"

ECHO CONVERTING EVERYTHING TO MP4!
ECHO !!!!!! NOTICE !!!!!!
ECHO IF AN MP4 FAILS TO CONVERT
ECHO CHANGE EXTENSION TO .M4V
ECHO THEN RERUN!

havc --root "C:\ProgramData\chocolatey\bin" --convert "D:\TargetFolderName" --extensions avi m4v mkv mov mp2 mpeg mpg vob wmv --target mp4 --delete-folder "D:\_CONVERTED" --custom-command "--preset='H.265 NVENC 1080p' --subtitle-lang-list eng --optimize -i {of} -o {cf}"

ECHO DONE!
pause