Created
September 24, 2024 20:08
-
-
Save michaelmrose/19ab09d9756a573490c906a92d04b803 to your computer and use it in GitHub Desktop.
Revisions
-
michaelmrose created this gist
Sep 24, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ local intro_video_url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ" local has_prepended = false -- A flag to prevent repeated prepending mp.register_event("file-loaded", function() -- Check if we've already prepended the URL if not has_prepended then -- Insert the YouTube video at the beginning of the playlist mp.commandv("loadfile", intro_video_url, "append-play") -- Wait for the video to be properly appended mp.add_timeout(1, function() local playlist_count = mp.get_property_number("playlist-count", 1) -- Move the newly added video to the front mp.command("playlist-move " .. (playlist_count - 1) .. " 0") -- Switch to the first playlist entry (the prepended YouTube URL) mp.set_property("playlist-pos", 0) -- Mark that the URL has been prepended to avoid repeating has_prepended = true end) end end)