Skip to content

Instantly share code, notes, and snippets.

@jameshi16
Last active November 17, 2018 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jameshi16/b5439c1f6248f18b6704a446b98ee807 to your computer and use it in GitHub Desktop.
Save jameshi16/b5439c1f6248f18b6704a446b98ee807 to your computer and use it in GitHub Desktop.
[Mine-ish] VLC & YouTube - Play all 100 videos on your playlists

What

The below is a LUA script that can pull out at most 100 videos from a playlist URL, and add it to your VLC playist. It's basically a clone of the youtube.lua script linked within the youtube-playlists.lua file, but with all the frills removed, because I still want an updated copy of youtube.lua from the official VideoLAN team.

I can't play some videos!

If you're using VLC <=3.0.4, you'd probably not be able to play some videos, especially those from VIVO or otherwise. To fix this, put this youtube.lua script into the same directory as you would for youtube-playlists.lua. This should allow you to watch those videos now.

Reference

--[[
Minimal code for YouTube playlists.
Author: James
With reference to: https://github.com/l-aloha/vlc_youtubeplaylist/blob/f0af373bddfb16a1d2593eed7052b8a6cb4b68c9/youtube.lua
]]
-- Probe function.
function probe()
return ( ( vlc.access == "http" or vlc.access == "https" )
and (
string.match( vlc.path, "^www%.youtube%.com/" )
) and (
string.match( vlc.path, "/playlist%?list=" )
) )
end
-- Parse function.
function parse()
if string.match( vlc.path, "/playlist%?list=" ) then
local line = nil
local path = nil
local name = nil
local thumbnail = nil
local tmp = nil
local items = {}
local item = nil
while true do
line = vlc.readline()
if not line then break end
path = string.match(line, "data%-video%-id=\"(.-)\"")
if path then
name = string.match(line, "data%-title=\"(.-)\"")
item = { path = "https://www.youtube.com/watch?v=" .. path, name = name }
table.insert(items, item)
else
-- Thumbnails are found in the next line.
if item then
thumbnail = string.match(line, "data%-thumb=\"(.-)\"")
if thumbnail then
item["arturl"] = thumbnail
end
end
end
end
return items
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment