-
-
Save garoto/e0eb539b210ee077c980e01fb2daef4a to your computer and use it in GitHub Desktop.
| -- Not my code: originally from https://redd.it/3t6s7k (author deleted; failed to ask for permission). | |
| -- Only tested on Windows. Date is set to dd/mmm/yy and time to machine-wide format. | |
| -- Save as "mpvhistory.lua" in your mpv scripts dir. Log will be saved to mpv default config directory. | |
| -- Make sure to leave a comment if you make any improvements/changes to the script! | |
| local HISTFILE = (os.getenv('APPDATA') or os.getenv('HOME')..'/.config')..'/mpv/mpvhistory.log'; | |
| mp.register_event('file-loaded', function() | |
| local title, logfile; | |
| title = mp.get_property('media-title'); | |
| title = (title == mp.get_property('filename') and '' or ('(%s)'):format(title)); | |
| logfile = io.open(HISTFILE, 'a+'); | |
| logfile:write(('[%s] %s %s\n'):format(os.date('%d/%b/%y %X'), mp.get_property('path'), title)); | |
| logfile:close(); | |
| end) |
@jimmy-1000 Not sure what you mean, but a LF char is already inserted at the end of every line, see line #15:
logfile:write(('[%s] %s %s\n')See the "\n" there? Yeah, that's the Lua newline escaped char. Or maybe the log viewer you're using doesn't recognize a single LF as a newline delimiter, like Win7 notepad.exe perhaps?
You are right in everything you say, what a shame 🙈
No worries my dude, but in anycase, if you want to have a file that has CRLF as line endings, just add a \r before the "\n" at line #15 like I mentioned in my comment, so it'd be like: logfile:write(('[%s] %s %s\r\n')
No worries my dude, but in anycase, if you want to have a file that has CRLF as line endings, just add a
\rbefore the "\n" at line #15 like I mentioned in my comment, so it'd be like:logfile:write(('[%s] %s %s\r\n')
Thanks! This greatly improves the look with notepad.
excuse me,you mean the author has deleted the script or his website?I tried but i can't open the linking you give for details。
excuse me,you mean the author has deleted the script or his website?I tried but i can't open the linking you give for details.
The reddit user who originally concocted the script deleted his account, so I was never able to ask him for permission to share it on github. The redd.it short link shown on the script comment section works and redirects to the original thread.
excuse me,you mean the author has deleted the script or his website?I tried but i can't open the linking you give for details.
The reddit user who originally concocted the script deleted his account, so I was never able to ask him for permission to share it on github. The short link shown on the script comment section works and redirects to the original thread.
redd.it
well,that may be my problem.thanks
have u ever tried to use a script called bookmark or bookmarker-menu?they have similar function as this script.I tried both of them but it doen't work.I have to write a script by myself to open video automatically when open mpv.If u know something for this,i would appreciate it very much
@jimmy-1000 Not sure what you mean, but a LF char is already inserted at the end of every line, see line #15:
logfile:write(('[%s] %s %s\n')See the "\n" there? Yeah, that's the Lua newline escaped char. Or maybe the log viewer you're using doesn't recognize a single LF as a newline delimiter, like Win7 notepad.exe perhaps?