Eisa01 / mpv-scripts

This repository contain scripts I have made for mpv media player...
BSD 2-Clause "Simplified" License
507 stars 35 forks source link

Save log to user profile directory #38

Closed escapezn closed 2 years ago

escapezn commented 2 years ago

The config file of SimpleHistory.lua currently didn't offer a variable of user profile directory to save log, making it inconvenient to use absolute path instead.

It would be very helpful if such variable exists, please consider adding it in the future. Thanks!

Eisa01 commented 2 years ago

I have placed two variables, one for MPV portable config directory and one to place it in the directory of scripts. You can also specify any other directory you want, but..

if there is another directory you want me to add it as a variable, let me know and I'll hopefully do it.

Give me an example of the final path so I can see whether it's possible or not

escapezn commented 2 years ago

Sorry I didn't describe it clear enough. I mean user profile directory on windows, according to mpv's manual is %APPDATA%/mpv. It's not a problem if not use portable config, as mpv use %APPDATA%/mpv by default and thus the log will be saved there. But if mpv is in portable mode while I still want the log to be saved in APPDATA, that's the case of my issue.

Eisa01 commented 2 years ago

Alright, I'll add the variable in next minor update

Eisa01 commented 2 years ago

This is done now, you should be able to define any variable in the configuration file. by using /:var then variable name, example: log_path=/:var%APPDATA%\\mpv or in .conf log_path=/:var%APPDATA%\mpv

However, because this a big update your old .log file will not be compatible, remove the old mpvHistory.log file to use the new version. Or to migrate the log to support the new version, (make sure you backup your old .log file, just in case) open the log and usually press ctrl+h to replace the following:

replace all | time= to | length=0 | time=

escapezn commented 2 years ago

Thanks for your update. But seems it is unable to write to a nonexistent directory (create a directory automatically), maybe mpv's fault?

Eisa01 commented 2 years ago

It is the default behavior, I can look into creating directories but I don't think it is something worth handling. Is there a usual use-case you need it for?

escapezn commented 2 years ago

It doesn't matter. Just because portable mpv didn't have %APPDATA%/mpv created before, not a big problem.