mirror of https://github.com/mpv-player/mpv
ytdl_hook.lua: fix some lint warnings
This commit is contained in:
parent
f348a8b303
commit
e5e17c80ba
|
@ -129,7 +129,7 @@ local function set_http_headers(http_headers)
|
||||||
mp.set_property("file-local-options/user-agent", useragent)
|
mp.set_property("file-local-options/user-agent", useragent)
|
||||||
end
|
end
|
||||||
local additional_fields = {"Cookie", "Referer", "X-Forwarded-For"}
|
local additional_fields = {"Cookie", "Referer", "X-Forwarded-For"}
|
||||||
for idx, item in pairs(additional_fields) do
|
for _, item in pairs(additional_fields) do
|
||||||
local field_value = http_headers[item]
|
local field_value = http_headers[item]
|
||||||
if field_value then
|
if field_value then
|
||||||
headers[#headers + 1] = item .. ": " .. field_value
|
headers[#headers + 1] = item .. ": " .. field_value
|
||||||
|
@ -335,7 +335,7 @@ local function make_absolute_url(base_url, url)
|
||||||
rest:gsub("([^/]+)", function(c) table.insert(segs, c) end)
|
rest:gsub("([^/]+)", function(c) table.insert(segs, c) end)
|
||||||
url:gsub("([^/]+)", function(c) table.insert(segs, c) end)
|
url:gsub("([^/]+)", function(c) table.insert(segs, c) end)
|
||||||
local resolved_url = {}
|
local resolved_url = {}
|
||||||
for i, v in ipairs(segs) do
|
for _, v in ipairs(segs) do
|
||||||
if v == ".." then
|
if v == ".." then
|
||||||
table.remove(resolved_url)
|
table.remove(resolved_url)
|
||||||
elseif v ~= "." then
|
elseif v ~= "." then
|
||||||
|
@ -478,7 +478,7 @@ local function formats_to_edl(json, formats, use_all_formats)
|
||||||
local streams = {}
|
local streams = {}
|
||||||
|
|
||||||
local tbr_only = true
|
local tbr_only = true
|
||||||
for index, track in ipairs(formats) do
|
for _, track in ipairs(formats) do
|
||||||
tbr_only = tbr_only and track["tbr"] and
|
tbr_only = tbr_only and track["tbr"] and
|
||||||
(not track["abr"]) and (not track["vbr"])
|
(not track["abr"]) and (not track["vbr"])
|
||||||
end
|
end
|
||||||
|
@ -492,8 +492,7 @@ local function formats_to_edl(json, formats, use_all_formats)
|
||||||
-- Iterate in reverse to get best track first.
|
-- Iterate in reverse to get best track first.
|
||||||
for index = #formats, 1, -1 do
|
for index = #formats, 1, -1 do
|
||||||
local track = formats[index]
|
local track = formats[index]
|
||||||
local edl_track = nil
|
local edl_track = edl_track_joined(track.fragments,
|
||||||
edl_track = edl_track_joined(track.fragments,
|
|
||||||
track.protocol, json.is_live,
|
track.protocol, json.is_live,
|
||||||
track.fragment_base_url)
|
track.fragment_base_url)
|
||||||
if not edl_track and not url_is_safe(track.url) then
|
if not edl_track and not url_is_safe(track.url) then
|
||||||
|
@ -686,8 +685,7 @@ local function add_single_video(json)
|
||||||
|
|
||||||
if streamurl == "" and json.url then
|
if streamurl == "" and json.url then
|
||||||
format_info = "youtube-dl (single)"
|
format_info = "youtube-dl (single)"
|
||||||
local edl_track = nil
|
local edl_track = edl_track_joined(json.fragments, json.protocol,
|
||||||
edl_track = edl_track_joined(json.fragments, json.protocol,
|
|
||||||
json.is_live, json.fragment_base_url)
|
json.is_live, json.fragment_base_url)
|
||||||
|
|
||||||
if not edl_track and not url_is_safe(json.url) then
|
if not edl_track and not url_is_safe(json.url) then
|
||||||
|
@ -1075,7 +1073,7 @@ function run_ytdl_hook(url)
|
||||||
json.entries[entry_wsubs].duration ~= nil then
|
json.entries[entry_wsubs].duration ~= nil then
|
||||||
for j, req in pairs(json.entries[entry_wsubs].requested_subtitles) do
|
for j, req in pairs(json.entries[entry_wsubs].requested_subtitles) do
|
||||||
local subfile = "edl://"
|
local subfile = "edl://"
|
||||||
for i, entry in pairs(json.entries) do
|
for _, entry in pairs(json.entries) do
|
||||||
if entry.requested_subtitles ~= nil and
|
if entry.requested_subtitles ~= nil and
|
||||||
entry.requested_subtitles[j] ~= nil and
|
entry.requested_subtitles[j] ~= nil and
|
||||||
url_is_safe(entry.requested_subtitles[j].url) then
|
url_is_safe(entry.requested_subtitles[j].url) then
|
||||||
|
@ -1096,7 +1094,7 @@ function run_ytdl_hook(url)
|
||||||
else
|
else
|
||||||
local playlist_index = parse_yt_playlist(url, json)
|
local playlist_index = parse_yt_playlist(url, json)
|
||||||
local playlist = {"#EXTM3U"}
|
local playlist = {"#EXTM3U"}
|
||||||
for i, entry in pairs(json.entries) do
|
for _, entry in pairs(json.entries) do
|
||||||
local site = entry.url
|
local site = entry.url
|
||||||
local title = entry.title
|
local title = entry.title
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue