mirror of
https://github.com/ksyasuda/mpv-youtube-queue.git
synced 2024-10-28 04:44:11 -07:00
fix is_file printing error message each time a url is passed (#10)
* fix is_file printing error message each time a url is passed - remove print to osd on false result - remove log messages - change to check if not local file first when adding to queue * appease the linter
This commit is contained in:
parent
e88e7f7f1c
commit
a1c2bfd9a7
@ -116,10 +116,8 @@ end
|
||||
|
||||
-- returns true if the provided path exists and is a file
|
||||
local function is_file(filepath)
|
||||
mp.msg.info("FILEPATH: " .. filepath)
|
||||
local result = utils.file_info(filepath)
|
||||
if result == nil then
|
||||
print_osd_message("File not found: " .. filepath, 3, style.error)
|
||||
return false
|
||||
end
|
||||
return result.is_file
|
||||
@ -453,21 +451,8 @@ function YouTubeQueue.add_to_queue(url, update_internal_playlist)
|
||||
return
|
||||
end
|
||||
|
||||
local video, channel_url, channel_name, video_name, video_url
|
||||
if is_file(url) then
|
||||
video_url = url
|
||||
channel_url, video_name = split_path(video_url)
|
||||
mp.msg.info("channel_url: " .. channel_url)
|
||||
mp.msg.info("video_name: " .. video_name)
|
||||
channel_name = "Local file"
|
||||
|
||||
video = {
|
||||
video_url = video_url,
|
||||
video_name = video_name,
|
||||
channel_url = channel_url,
|
||||
channel_name = channel_name
|
||||
}
|
||||
else
|
||||
local video, channel_url, channel_name, video_name
|
||||
if not is_file(url) then
|
||||
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
|
||||
@ -482,6 +467,19 @@ function YouTubeQueue.add_to_queue(url, update_internal_playlist)
|
||||
channel_name = channel_name
|
||||
}
|
||||
end
|
||||
else
|
||||
channel_url, video_name = split_path(url)
|
||||
if channel_url == nil or video_name == nil or channel_url == "" or
|
||||
video_name == "" then
|
||||
print_osd_message("Error getting video info.", MSG_DURATION,
|
||||
style.error)
|
||||
end
|
||||
video = {
|
||||
video_url = url,
|
||||
video_name = video_name,
|
||||
channel_url = channel_url,
|
||||
channel_name = "Local file"
|
||||
}
|
||||
end
|
||||
|
||||
table.insert(video_queue, video)
|
||||
|
Loading…
Reference in New Issue
Block a user