This adds file tags to display along with the title, including album/artist etc. for music, and series etc. for some videos. The list of tags to display is identical to the tags printed to the terminal and is controlled by the --display-tags option. To filter out overlength tags (such as long comments and lyrics) and files with too many tags, add file_tag_max_length and file_tag_max_count options so that tags longer than this length are not displayed, and only the first few tags are displayed. Also makes tags show on page 5 only.
Showing the changes to player/lua/stats.lua (1 of 3 files). Show all
Unified · Split
| @@ -31,6 +31,8 @@ local o = { · 30 unmodified lines | ||
| 31 | 31 | ass_formatting = true, |
| 32 | 32 | persistent_overlay = false, -- whether the stats can be overwritten by other output |
| 33 | 33 | filter_params_max_length = 100, -- show one filter per line if list exceeds this length |
| 34 | + file_tag_max_length = 128, -- only show file tags shorter than this length in bytes | |
| 35 | + file_tag_max_count = 16, -- only show the first x file tags | |
| 34 | 36 | show_frame_info = false, -- whether to show the current frame info |
| 35 | 37 | term_width_limit = -1, -- overwrites the terminal width |
| 36 | 38 | term_height_limit = -1, -- overwrites the terminal height |
| @@ -641,13 +643,26 @@ local function add_header(s) · 604 unmodified lines | ||
| 641 | 643 | end |
| 642 | 644 | |
| 643 | 645 | |
| 644 | −local function add_file(s, print_cache) | |
| 646 | +local function add_file(s, print_cache, print_tags) | |
| 645 | 647 | append(s, "", {prefix="File:", nl="", indent=""}) |
| 646 | 648 | append_property(s, "filename", {prefix_sep="", nl="", indent=""}) |
| 647 | 649 | if mp.get_property_osd("filename") ~= mp.get_property_osd("media-title") then |
| 648 | 650 | append_property(s, "media-title", {prefix="Title:"}) |
| 649 | 651 | end |
| 650 | 652 | |
| 653 | + if print_tags then | |
| 654 | + local tags = mp.get_property_native("display-tags") | |
| 655 | + local tags_displayed = 0 | |
| 656 | + for _, tag in ipairs(tags) do | |
| 657 | + local value = mp.get_property("metadata/by-key/" .. tag) | |
| 658 | + if tag ~= "Title" and tags_displayed < o.file_tag_max_count | |
| 659 | + and value and value:len() < o.file_tag_max_length then | |
| 660 | + append(s, value, {prefix=string.gsub(tag, "_", " ") .. ":"}) | |
| 661 | + tags_displayed = tags_displayed + 1 | |
| 662 | + end | |
| 663 | + end | |
| 664 | + end | |
| 665 | + | |
| 651 | 666 | local editions = mp.get_property_number("editions") |
| 652 | 667 | local edition = mp.get_property_number("current-edition") |
| 653 | 668 | local ed_cond = (edition and editions > 1) |
| @@ -1140,7 +1155,7 @@ local function default_stats() · 486 unmodified lines | ||
| 1140 | 1155 | local stats = {} |
| 1141 | 1156 | eval_ass_formatting() |
| 1142 | 1157 | add_header(stats) |
| 1143 | − add_file(stats, true) | |
| 1158 | + add_file(stats, true, false) | |
| 1144 | 1159 | add_video_out(stats) |
| 1145 | 1160 | add_video(stats) |
| 1146 | 1161 | add_audio(stats) |
| @@ -1287,7 +1302,7 @@ local function track_info() · 140 unmodified lines | ||
| 1287 | 1302 | append(h, "", {prefix=format("%s:%s", desc, scroll_hint()), nl="", indent=""}) |
| 1288 | 1303 | h = {table.concat(h)} |
| 1289 | 1304 | table.insert(c, o.nl .. o.nl) |
| 1290 | − add_file(c) | |
| 1305 | + add_file(c, false, true) | |
| 1291 | 1306 | for i, track in ipairs(mp.get_property_native("track-list")) do |
| 1292 | 1307 | if track['selected'] then |
| 1293 | 1308 | add_track(c, track, i - 1) |