commit 8aaa0516d19b3532f1962b831a76af66452d1fb9 Author: FalloNero Date: Thu Nov 21 13:06:20 2024 +0100 first first commit diff --git a/youtube.lua b/youtube.lua new file mode 100644 index 0000000..e977ffb --- /dev/null +++ b/youtube.lua @@ -0,0 +1,55 @@ +-- YouTube Link Resolver for VLC with Separate Video and Audio URLs +-- Place this script in VLC's lua/playlist directory + +function probe() + -- Check if the input is a YouTube link + return vlc.access == "http" or vlc.access == "https" and + (string.match(vlc.path, "youtube%.com") or string.match(vlc.path, "youtu%.be")) +end + +function parse() + -- Construct the full YouTube URL + local youtube_url = vlc.access .. "://" .. vlc.path + + -- Path to yt-dlp executable (modify as needed) + local yt_dlp_path = "C:\\YT-DLP\\yt-dlp.exe" + + -- Construct the command to get the direct video and audio URLs + local cmd = string.format( + '%s -g "%s"', + yt_dlp_path, + youtube_url + ) + + -- Execute yt-dlp to get the direct video and audio URLs + local handle = io.popen(cmd) + + -- Read video URL (first line) + local video_url = handle:read("*l") + + -- Read audio URL (second line) + local audio_url = handle:read("*l") + + handle:close() + + -- Trim any whitespace + video_url = video_url:gsub("^%s+", ""):gsub("%s+$", "") + audio_url = audio_url:gsub("^%s+", ""):gsub("%s+$", "") + + -- Log the resolved URLs + vlc.msg.info("[YouTube Resolver] Original URL: " .. youtube_url) + vlc.msg.info("[YouTube Resolver] Video URL: " .. video_url) + vlc.msg.info("[YouTube Resolver] Audio URL: " .. audio_url) + + -- Create a playlist item with both video and audio URLs + return { + { + path = video_url, + name = vlc.path .. " (Video)", + options = { + -- Add audio URL as input option + ":input-slave=" .. audio_url + } + } + } +end \ No newline at end of file