Eisa01 / mpv-scripts

This repository contain scripts I have made for mpv media player...

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple History can't re-open SMB file after system reboot.

HubKing opened this issue · comments

Most of my videos are on SAMBA network shared locations, and I need to resume the video after restarting the system for system updates. Simple History fails to open the file on an SMB path that was mounted by Gnome's GVFS, saying "File doesn't exist".

Probably it is quite easily possible to make GVFS automatically mount the SMB location again, because if I use dbus command I can open an SMB file path that has not been mounted. It seemed that the mounting was automatically done.

Please provide me with full path samples that are failing to open

I am using Gnome and its file manager Files (i.e., Nautilus) and if I understand it correctly, an SMB path is automatically translated into /run/user/<user's UID>/gvfs/smb-share:server=<server's name>,share=<SMB path after the protocol identifier>.

For example, if your UID is 1000 and you open smb://homer/marge/bart.mp4, the physical path that MPV gets will be, /run/user/1000/gvfs/smb-share:server=homer,share=marge/bart.mp4. Probably faster that you just try it under Gnome.

I saw the content of the mpvHistory.log file, and the file paths were correct (the mapped path /run/...) but because of the way it opens the file, Gnome does not mount the path automatically. Calling dbus file open with the SMB path (not the mapped path) automatically mounted the location, so maybe doing something like that is necessary.

open in file manager: dbus-send --session --print-reply --dest=org.freedesktop.FileManager1 --type=method_call /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItems array:string:"smb://file path" string:""

This seems quite complex, multiple variables could be resulting in the path to actualise. I need to replicate the environment and then see the feasibility of supporting it

I guess that GVFS automatically mounts the SMB directory to a local path like /run/user... when a client requests access to an SMB path (e.g., "smb://server/dir/file.mp4"), but not when the clients requests access to a mapped path like /run/user..., even though the same SMB path always results in the same local path, as long as the UID is the same.

I guess, maybe I should ask the developers of GVFS to mount the SMB directory when a local SMB path is requested. But probably they wouldn't do it. Maybe the script can detect that a path is an SMB path by matching the format (/run/user...) and then reconstruct the SMB path, and then request GVFS to mount the SMB path. The conversion scheme is fixed so conversion itself is simple, but the path maybe different on different distributions or different Gnome versions. In my case, it was Arch Linux.

Is it possible to run the file using terminal
E.g.: mpv smb://server/dir/file.mp4?

No. It can't. I think MPV does not know anything about SMB.

Actually SMB is supported by mpv. You might need to try the full path ,e.g.:
mpv smb://USER:PASSWORD@SERVER/SHARE/file.mkv

Also there is more in the following discussion:
mpv-player/mpv#1512

I believe there is an ongoing thread regarding the implementation of what you are requesting:
mpv-player/mpv#8731

I am not sure if Gnome's file manager (Nautilus) also passes the real SMB path to applications along with GVFS-mapped path, but even if it does, it probably won't pass the user name/password for obvious security reasons. Probably Gnome (or GVFS, I guess) allows applications to access an SMB file using the real SMB path, but from my experience, MPV would not support anything specific to Gnome, so I have no hope for that.

Even if MPV supports SMB path with user name/password, that means I have to open video files manually from the terminal, not by drag and drop or double-clicking from the file manager, so this option is not very feasible for me.

If you think this is too much for the purpose of the SIMPLE history, I think you can close this issue. Maybe I could add lines to the script to remount it for my own use.

Anyway, I have opened a thread on Gnome's forum: https://discourse.gnome.org/t/autmatically-remount-an-smb-path-when-an-application-tries-to-access-a-gvfs-mapped-path/17202 I don't have much hope, since Gnome developers are also famous for doing things their own way, but at least I have tried.

Did you consider the below?

I believe linux can mount smb files to an empty directory, then it is possible to access them just like a normal folder.

You can also set it to automatically mount, once it is treated like normal folder then any application will not have a challenge in opening the files.

sudo mount -t cifs //server/dir /path/emptydir/ -o username="user",password="mypassword"

If the issue still persists and the above suggestion did not work, let me know and I will re-open the issue.