diff --git a/memo.conf b/memo.conf index 9abcab6..982776b 100644 --- a/memo.conf +++ b/memo.conf @@ -19,7 +19,9 @@ hide_same_dir=no # Date format https://www.lua.org/pil/22.1.html timestamp_format=%Y-%m-%d %H:%M:%S -# Display titles instead of filenames when available +# Display titles instead of filenames when available. +# Can be "yes", "no", or "web". +# "yes" uses titles for all, "no" uses filenames/URLs, "web" uses titles for web entries only (eg. youtube videos). use_titles=yes # Truncate titles to n characters, 0 to disable @@ -49,4 +51,4 @@ close_binding=LEFT ESC # Opening the file "/data/TV Shows/Comedy/Curb Your Enthusiasm/S4/E06.mkv" will # lead to "Curb Your Enthusiasm" to be shown in the directory menu. Opening # of that entry will then open that file again. -path_prefixes=pattern:.* \ No newline at end of file +path_prefixes=pattern:.* diff --git a/memo.lua b/memo.lua index 9eebda7..7cd3d75 100644 --- a/memo.lua +++ b/memo.lua @@ -25,7 +25,7 @@ local options = { timestamp_format = "%Y-%m-%d %H:%M:%S", -- Display titles instead of filenames when available - use_titles = true, + use_titles = "yes", -- Truncate titles to n characters, 0 to disable truncate_titles = 60, @@ -187,6 +187,13 @@ local device_protocols = { dvdnav = true } +local web_protocols = { + http = true, + https = true, + ytdl = true, + dvb = true +} + function utf8_char_bytes(str, i) local char_byte = str:byte(i) local max_bytes = #str - i + 1 @@ -949,7 +956,11 @@ function show_history(entries, next_page, prev_page, update, return_items) return end - if search_words and not options.use_titles then + local is_web = effective_protocol and web_protocols[effective_protocol] + --for this specific entry + local use_titles_effective = options.use_titles == "yes" or options.use_titles == "web" and is_web + + if search_words and not use_titles_effective then for _, word in ipairs(search_words) do if unaccent(display_path):lower():find(word, 1, true) == nil then return @@ -985,7 +996,7 @@ function show_history(entries, next_page, prev_page, update, return_items) end end - if options.hide_deleted and not (search_words and options.use_titles) then + if options.hide_deleted and not (search_words and use_titles_effective) then if state.known_files[cache_key] and not state.existing_files[cache_key] then return end @@ -1013,9 +1024,10 @@ function show_history(entries, next_page, prev_page, update, return_items) end local title = file_info:sub(1, title_length) - if not options.use_titles then - title = "" - end + + if not use_titles_effective then + title = "" + end if dir_menu then title = basename @@ -1039,7 +1051,7 @@ function show_history(entries, next_page, prev_page, update, return_items) title = title:gsub("\n", " ") - if search_words and options.use_titles then + if search_words and use_titles_effective then for _, word in ipairs(search_words) do if unaccent(title):lower():find(word, 1, true) == nil then return @@ -1047,7 +1059,7 @@ function show_history(entries, next_page, prev_page, update, return_items) end end - if options.hide_deleted and (search_words and options.use_titles) then + if options.hide_deleted and (search_words and use_titles_effective) then if state.known_files[cache_key] and not state.existing_files[cache_key] then return end