Skip to content

Commit

Permalink
Merge pull request #11 from Samillion/dev_customformat_ref
Browse files Browse the repository at this point in the history
refactor: group format params together
  • Loading branch information
Samillion authored Nov 3, 2024
2 parents d24a6b7 + 8ec3eb1 commit 37b06ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ To adjust options, simply change the values inside `local options` within the sc
local options = {
-- Which domains should ytdl-format change on?
domains = {
"youtu.be", "youtube.com", "www.youtube.com",
"twitch.tv", "www.twitch.tv"
"youtu.be", "youtube.com", "www.youtube.com",
"twitch.tv", "www.twitch.tv",
},

-- Set maximum video quality (on load/start)
Expand Down
13 changes: 9 additions & 4 deletions ytdlautoformat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ local function update_ytdl_format()
["av1"] = "[vcodec~='^(av01)']",
["novp9"] = "[vcodec!~='^(vp0?9)']",
}
local quality = options.quality > 0 and "[height<=?" .. options.quality .. "]" or ""
local codec = codec_list[options.codec:lower()] or ""
local fallback = options.fallback and " / " .. options.fallback_format or ""
local ytdl_custom = "bv" .. quality .. codec .. "+ba/b" .. quality .. fallback

local format = {
quality = options.quality > 0 and "[height<=?" .. options.quality .. "]" or "",
codec = codec_list[options.codec:lower()] or "",
fallback = options.fallback and " / " .. options.fallback_format or "",
}

local ytdl_custom = "bv" .. format.quality .. format.codec .. "+ba/b" .. format.quality .. format.fallback

mp.set_property("file-local-options/ytdl-format", ytdl_custom)
msg.info("Changed ytdl-format to: " .. ytdl_custom)
end
Expand Down

0 comments on commit 37b06ba

Please sign in to comment.