From e30ad750353d3599fb791db99d80bed069dcf140 Mon Sep 17 00:00:00 2001 From: Antoine Cellerier Date: Sat, 6 Feb 2010 15:25:26 +0100 Subject: [PATCH] Lua's like python, not C. You don't need parentheses around a control/loop statement's condition. --- share/lua/extensions/imdb.lua | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/share/lua/extensions/imdb.lua b/share/lua/extensions/imdb.lua index 2eaa7e5edf..0520779d85 100644 --- a/share/lua/extensions/imdb.lua +++ b/share/lua/extensions/imdb.lua @@ -38,10 +38,10 @@ end -- Update title text field. Removes file extensions. function update_title() local title = vlc.input.get_title() - if (title ~= nil) then + if title ~= nil then title = string.gsub(title, "(.*)(%.%w+)$", "%1") end - if (title ~= nil) then + if title ~= nil then txt:set_text(title) end end @@ -83,7 +83,7 @@ function click_okay() html = nil end - if (not list) then + if not list then list = dlg:add_list(1, 3, 4, 1) button_open = dlg:add_button("Open", "click_open", 1, 4, 4, 1) end @@ -108,11 +108,11 @@ function click_okay() -- Find title types _, idxEnd, titleType = string.find(data, "([^<]*Titles[^<]*)", idxEnd) _, _, nextTitle = string.find(data, "([^<]*Titles[^<]*)", idxEnd) - if (not titleType) then + if not titleType then break else -- Find current scope - if (not nextTitle) then + if not nextTitle then _, _, table = string.find(data, "(.*)
", idxEnd) else nextTitle = string.gsub(nextTitle, "%(", "%%(") @@ -120,13 +120,13 @@ function click_okay() _, _, table = string.find(data, "(.*)
.*"..nextTitle, idxEnd) end -- Find all titles in this scope - if (not table) then break end + if not table then break end pos = 0 - while (pos ~= nil) do + while pos ~= nil do _, _, link = string.find(table, "]*>([^<]+)", pos) - if (not title) then break end -- this would not be normal behavior... + if not title then break end -- this would not be normal behavior... _, _, year = string.find(table, "\((%d+)\)", pos) -- Add this title to the list count = count + 1 @@ -144,8 +144,8 @@ end function click_open() selection = list:get_selection() - if (not selection) then return 1 end - if (not html) then + if not selection then return 1 end + if not html then html = dlg:add_html("Loading IMDb page...", 1, 3, 4, 1) -- userLink = dlg:add_label("", 1, 4, 5, 1) end @@ -174,10 +174,10 @@ function click_open() -- Director local director = nil _, nextIdx, _ = string.find(data, "
]+>([%w%s]+)", nextIdx) end - if (not director) then + if not director then director = "(Unknown)" end text = text .. "Director" .. director .. "" @@ -186,7 +186,7 @@ function click_open() local genres = "Genres" local first = true for genre, _ in string.gmatch(data, "/Sections/Genres/(%w+)/\">") do - if (first) then + if first then genres = genres .. "" .. genre .. "" else genres = genres .. "" .. genre .. "" @@ -199,7 +199,7 @@ function click_open() local actors = "Cast" first = true for nm, char in string.gmatch(data, "]+>([%w%s]+) ... ]+>([%w%s]+)") do - if (not first) then + if not first then actors = actors .. "" end actors = actors .. "" .. nm .. "" .. char .. "" @@ -213,7 +213,7 @@ function click_open() -- We read only the first summary _, _, summary = string.find(data, "

([^<]+)") - if (not summary) then + if not summary then summary = "(Unknown)" end text = text .. "

" .. summary .. "

" @@ -224,7 +224,7 @@ end -- Convert some HTML characters into UTF8 function replace_html_chars(txt) - if (not txt) then return nil end + if not txt then return nil end -- return vlc.strings.resolve_xml_special_chars(txt) for num in string.gmatch(txt, "&#x(%x+);") do -- Convert to decimal (any better way?) -- 2.39.2