mirror of
https://github.com/ksyasuda/mpv-youtube-queue.git
synced 2024-10-28 04:44:11 -07:00
fix error due to adding video to queue already surrounded by quotes (#8)
- fix surround with quotes function to only surround with quotes if not already there - remove quotes before adding to video_queue
This commit is contained in:
parent
64bde58672
commit
6ca5de8aa4
@ -91,8 +91,16 @@ local current_video = nil
|
|||||||
|
|
||||||
-- HELPERS {{{
|
-- HELPERS {{{
|
||||||
|
|
||||||
-- surround string with single quotes
|
-- surround string with single quotes if it does not already have them
|
||||||
local function surround_with_quotes(s) return '\'' .. s .. '\'' end
|
local function surround_with_quotes(s)
|
||||||
|
if string.sub(s, 0, 1) == "'" and string.sub(s, -1) == "'" then
|
||||||
|
return s
|
||||||
|
else
|
||||||
|
return "'" .. s .. "'"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function remove_quotes(s) return string.gsub(s, "'", "") end
|
||||||
|
|
||||||
-- run sleep shell command for n seconds
|
-- run sleep shell command for n seconds
|
||||||
local function sleep(n) os.execute("sleep " .. tonumber(n)) end
|
local function sleep(n) os.execute("sleep " .. tonumber(n)) end
|
||||||
@ -457,6 +465,7 @@ function YouTubeQueue.add_to_queue(url, update_internal_playlist)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
channel_url, channel_name, video_name = YouTubeQueue.get_video_info(url)
|
channel_url, channel_name, video_name = YouTubeQueue.get_video_info(url)
|
||||||
|
url = remove_quotes(url)
|
||||||
if (channel_url == nil or channel_name == nil or video_name == nil) or
|
if (channel_url == nil or channel_name == nil or video_name == nil) or
|
||||||
(channel_url == "" or channel_name == "" or video_name == "") then
|
(channel_url == "" or channel_name == "" or video_name == "") then
|
||||||
print_osd_message("Error getting video info.", MSG_DURATION,
|
print_osd_message("Error getting video info.", MSG_DURATION,
|
||||||
|
Loading…
Reference in New Issue
Block a user