@@ -124,13 +124,33 @@ if not input_import then
124
124
-- If mp.input is not available, use an empty implementation
125
125
input = {
126
126
get = function (foo ) end ,
127
- terminate = function () end ,
127
+ terminate = function ()
128
+ mp .osd_message (" " , 1 )
129
+ -- Print media info (in case the input box is closed without playing a new video)
130
+ local media_title = mp .get_property (" media-title" )
131
+ local metadata = mp .get_property_native (" metadata" )
132
+ if metadata then
133
+ if metadata [" uploader" ] then
134
+ mp .commandv (" print-text" , " Uploader: " .. metadata [" uploader" ])
135
+ end
136
+ if metadata [" channel_url" ] then
137
+ mp .commandv (" print-text" , " Channel URL: " .. metadata [" channel_url" ])
138
+ end
139
+ end
140
+ if media_title then
141
+ mp .commandv (" print-text" , " Title: " .. media_title )
142
+ end
143
+ end ,
128
144
set_log = function (lines )
129
145
local text = " "
130
146
for i = 1 , # lines do
131
- text = text .. " \n " .. lines [i ].terminal_style .. lines [i ].text .. " \027 [0m"
147
+ if type (lines [i ]) == ' table' then
148
+ text = text .. " \n " .. lines [i ].terminal_style .. lines [i ].text .. " \027 [0m"
149
+ else
150
+ text = text .. " \n " .. tostring (lines [i ])
151
+ end
132
152
end
133
- mp .osd_message (" \n " .. text )
153
+ mp .osd_message (text , 999 )
134
154
end
135
155
}
136
156
end
@@ -827,7 +847,6 @@ local function show_menu()
827
847
if destroyer ~= nil then
828
848
destroyer ()
829
849
end
830
- input .terminate ()
831
850
end
832
851
833
852
local function terminal_submit (text , text_override )
@@ -920,6 +939,21 @@ local function show_menu()
920
939
ass :append (opts .style_ass_tags )
921
940
922
941
local terminal_lines = {}
942
+ -- Print media info
943
+ local media_title = mp .get_property (" media-title" )
944
+ local metadata = mp .get_property_native (" metadata" )
945
+ if metadata then
946
+ if metadata [" uploader" ] then
947
+ table.insert (terminal_lines , " Uploader: " .. metadata [" uploader" ])
948
+ end
949
+ if metadata [" channel_url" ] then
950
+ table.insert (terminal_lines , " Channel URL: " .. metadata [" channel_url" ])
951
+ end
952
+ end
953
+ if media_title then
954
+ table.insert (terminal_lines , " Title: " .. media_title )
955
+ end
956
+
923
957
table.insert (terminal_lines , {
924
958
text = " ░░░░░░░░░░░░░░░░░░░░░░░░ Up Next ░░░░░░░░░░░░░░░░░░░░░░░░" ,
925
959
terminal_style = " \027 [1m" ,
@@ -1017,9 +1051,14 @@ local function show_menu()
1017
1051
mp .observe_property (" osd-dimensions" , " native" , update_dimensions )
1018
1052
1019
1053
local function destroy ()
1054
+ destroyer = nil
1055
+ redraw_menu = nil
1020
1056
if timeout ~= nil then
1021
1057
timeout :kill ()
1022
1058
end
1059
+ if no_video then
1060
+ input .terminate ()
1061
+ end
1023
1062
mp .set_osd_ass (0 , 0 , " " )
1024
1063
mp .remove_key_binding (" move_up" )
1025
1064
mp .remove_key_binding (" move_down" )
@@ -1028,8 +1067,6 @@ local function show_menu()
1028
1067
mp .remove_key_binding (" escape" )
1029
1068
mp .remove_key_binding (" quit" )
1030
1069
mp .unobserve_property (update_dimensions )
1031
- destroyer = nil
1032
- redraw_menu = nil
1033
1070
end
1034
1071
1035
1072
if not no_video then
0 commit comments