zenyd / mpv-scripts

Scripts for the mpv media player
GNU General Public License v3.0
171 stars 29 forks source link

[`delete_file.lua` Bug report] `MoveToFolder` not working unless `DeletedFilesPath` is specified and `DeletedFilesPath` is in the same dir as the videos #44

Open kohane27 opened 2 years ago

kohane27 commented 2 years ago

TL;DR:

  1. Videos aren't moved unless DeletedFilesPath is specified and DeletedFilesPath is in the same dir as the videos
  2. I can't move videos from different directories, i.e., I can move videos from ~/Videos but not /run/media/username/MX500/

Description

Hello there. Hope you're doing well.

Thank you for creating this handy tool. I finally don't have to use a file manager to find the video and then delete it. However, I've encountered a bug:

Scenario 1 (fail)

delete_file.conf:

MoveToFolder=yes

Then:

❯ mpv "test-delete.webm"
   cplayer:  (+) Video --vid=1 (*) (vp9 1920x1080 23.976fps)
   cplayer:  (+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
Cannot load libcuda.so.1
   cplayer: Saving state.
   cplayer:
   cplayer: Exiting... (Quit)
delete_file: moving: /home/username/Videos/test-delete.webm

I can see the dir ~/delete_file is created, but test-delete.webm isn't moved there.

Scenario 2 (success)

delete_file.conf:

MoveToFolder=yes
DeletedFilesPath=/home/username/Videos/delete_file
❯ mpv "test-delete.webm"
   cplayer:  (+) Video --vid=1 (*) (vp9 1920x1080 23.976fps)
   cplayer:  (+) Audio --aid=1 --alang=eng (*) (opus 2ch 48000Hz)
Cannot load libcuda.so.1
   cplayer: Saving state.
   cplayer:
   cplayer: Exiting... (Quit)
delete_file: moving: /home/username/Videos/test-delete.webm

The dir /home/username/Videos/delete_file is created and test-delete.webm is moved there.

Scenario 3 (fail)

delete_file.conf:

MoveToFolder=yes
DeletedFilesPath=/home/username/Videos/delete_file

Note: this test-delete.webm is in /run/media/username/MX500, so different than ~/Videos above.

❯ mpv "test-delete.webm"
   cplayer:  (+) Video --vid=1 (*) (h264 1920x1080 30.000fps)
   cplayer:  (+) Audio --aid=1 (*) (aac 2ch 24000Hz)
Cannot load libcuda.so.1
progressbar: Playing: "test-delete.webm"
   cplayer: Saving state.
   cplayer:
   cplayer: Exiting... (Quit)
delete_file: moving: /run/media/username/MX500/test-delete.webm

The video test-delete.webm is not moved anywhere.

Scenario 4 (fail)

delete_file.conf:

MoveToFolder=yes

Note: this test-delete.webm is again, in /run/media/username/MX500.

❯ mpv "test-delete.webm"
   cplayer:  (+) Video --vid=1 (*) (h264 1920x1080 30.000fps)
   cplayer:  (+) Audio --aid=1 (*) (aac 2ch 24000Hz)
Cannot load libcuda.so.1
   cplayer: Saving state.
   cplayer:
   cplayer: Exiting... (Quit)
delete_file: moving: /run/media/username/MX500/test-delete.webm

The video test-delete.webm is not moved anywhere as well.

Scenario 5 (success)

delete_file.conf:

MoveToFolder=yes
DeletedFilesPath=/run/media/username/MX500/delete_file/

Note: this test-delete.webm is in /run/media/username/MX500, so different than ~/Videos above.

❯ mpv "test-delete.webm"
   cplayer:  (+) Video --vid=1 (*) (h264 1920x1080 30.000fps)
   cplayer:  (+) Audio --aid=1 (*) (aac 2ch 24000Hz)
Cannot load libcuda.so.1
   cplayer: Saving state.
   cplayer:
   cplayer: Exiting... (Quit)
delete_file: moving: /run/media/username/MX500/test-delete.webm

The video test-delete.webm is indeed moved to /run/media/username/MX500/delete_file

Conclusion

However, if I specify MoveToFolder=no, then videos are deleted across all mount points. But this is not what I want: I want to move videos to a directory across all mount points. I suspect this is a permission to move files issue? Because given Scenario 1, the video can't be moved to ~/delete_file even it's the same mount point (/home/username).

Config:

❯ mpv --version
mpv 0.34.1-dirty Copyright © 2000-2021 mpv/MPlayer/mplayer2 projects
FFmpeg version: n5.0.1

❯ uname
Linux

Any input is much appreciated. Thank you:)

zenyd commented 10 months ago

I haven't tested these scenarios, but noticed that the player is saving state so it can resume where left of? Is this right? If this is enabled by default maybe try disabling this.

m040601 commented 4 months ago

Any solution to this issue ? I'm having exactly the same problem described by the OP, and have not found solution.

Let me recap and resume:

What is it that i want to do ?

I dont want to "immediately" delete files. I want to first move the files to a "safe destination" folder. I want to choose and specify the name and exact absolute location of that folder, for example "/some/place/to_be_deleted_mpv_files" I want that folder to be ANYWHERE I want. It could be for example in a different disk, or a different mount in my file system. That is the "to_be_deleted_mpv_files" ARE NOT necessarely on the same file system or disk where the files I am playing in mpv are.

After I quit mpv, I go to that folder, review, and manually delete those files with my file system tools.

What am I doing ? What am I using.

I am on linux. I am creating a file ~/.config/mpv/script-opts/delete_file.conf containing,

MoveToFolder=yes

[delete_file] script-opts/delete_file.conf:1 unknown key 'MoveToFolder ', ignoring [delete_file] script-opts/delete_file.conf:2 unknown key 'DeletedFilesPath ', ignoring

The script can be configured to move files instead of deleting them. The
default folder for the moved files is `C:\Users\<me>\delete_file`. To change
the defaults create a `delete_file.conf` inside of the `script-opts` folder
with contents:

MoveToFolder=yes