Last active
November 9, 2024 22:42
-
-
Save garoto/e0eb539b210ee077c980e01fb2daef4a to your computer and use it in GitHub Desktop.
Simple media logger Lua script for mpv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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) |
Great script, I modified it and intergrated it to a project that scrolls mpv title in the panel in xfce desktop environment.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
great script, I'd suggest using double quotes instead of single quotes IMHO