Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- cache for alredy resolved titles and titles that could not be resolved (filenames)
- -- filename => title
- local title_cache = {}
- mp.register_script_message("osc_update_title", function(filename, title)
- title_cache[filename] = title
- end)
- function get_playlist()
- local pos = mp.get_property_number('playlist-pos', 0) + 1
- local count, limlist = limited_list('playlist', pos)
- if count == 0 then
- return 'Empty playlist.'
- end
- local message = string.format('Playlist [%d/%d]:\n', pos, count)
- for i, v in ipairs(limlist) do
- local title = v.title
- if not title then
- -- try getting title from cache
- if title_cache[v.filename] then
- title = title_cache[v.filename]
- -- title not in cache
- else
- local _
- _, title = utils.split_path(v.filename)
- -- set title to filename
- title_cache[v.filename] = title
- -- try to resolving title in background
- mp.commandv('script-message', 'ytdl_resolve_title', v.filename)
- end
- end
- message = string.format('%s %s %s\n', message,
- (v.current and '●' or '○'), title)
- end
- return message
- end
Add Comment
Please, Sign In to add comment