Last edit: @jkrause in <!error getting other user for D4H2HRQM8> 2 years ago - Slack Archive

{lua} local query = args
if query == "" then print("Usage: !mdb <movie/tv show/actors>") return end
if query == "test" then print("Don't look this creepy ass movie up, at all...") return end
url = "https://api.themoviedb.org/3/search/multi?api_key=" .. fmap.api_keys.moviedb .. "&language=en-US&page=1&include_adult=false&query=" .. bot.uriencode(query)
local resp, err = requests.get(url)
if err ~= nil then print("Error: " .. err) return end
local j = resp:json()
if j['results'] == nil then print("Error: That movie/tv show/actor was not found in the database.") return end
local res = j['results'][1]
if res == nil then print("Error: That movie/tv show/actor was not found in the database.") return end
local type = res['media_type']
if type == "person" then
  local knownfor = res['known_for']
  url = "https://api.themoviedb.org/3/person/" .. res['id'] .. "?api_key=" .. fmap.api_keys.moviedb .. "&language=en-US"
  local perres, err = requests.get(url)
  if err ~= nil then print("First Error: " .. err) return end
  person = perres:json()
  local birthyear = ""
  local deathyear = ""

  if getmetatable(person['birthday'])['sub'] ~= nil then birthyear = string.sub(person['birthday'], 0, 4) end
  local imdb_id = person['imdb_id']
  
  -- There is some weird bug with null values in a table, this is the only way I could fix it.
  if getmetatable(person['deathday'])['sub'] ~= nil then deathyear = string.sub(person['deathday'], 0, 4) end
  local msg = "*" .. person['name'] .. "* (" .. birthyear .. "―" .. deathyear .. ")"
  msg = msg .. "\n"
  if getmetatable(person['biography'])['sub'] ~= nil then
    local bio = string.find(person['biography'], "\n\n")
    if bio ~= nil then
      if (string.find(string.sub(person['biography'], bio + 1), "\n\n") ~= nil) then bio = bio + string.find(string.sub(person['biography'], bio + 1), "\n\n") end
      msg = msg .. string.sub(person['biography'], 0, bio)
    else
      msg = msg .. person['biography']
    end
  else
    msg = msg .. "This person is so unknown that the API broke.  So I'm simply just going to fill this text with random garbage until it looks as if I know all about this person."
  end
  msg = msg .. "\n\nLearn more at: http://www.imdb.com/name/" .. imdb_id
  print(msg)
else
  local movietv = j['results'][1]
  url = "https://api.themoviedb.org/3/" .. type .. "/" .. res['id'] .. "?api_key=" .. fmap.api_keys.moviedb .. "&language=en-US"
  local moviedbinfo, err = requests.get(url)
  if err ~= nil then print("Second Error: " .. err) return end
  moviedbinfo = moviedbinfo:json()
  local imdb_id = moviedbinfo['imdb_id']
  
  local year,title = ""
  if type == "tv" then year = string.sub(movietv['first_air_date'], 0, 4) else year = string.sub(movietv['release_date'], 0, 4) end
  if type == "tv" then title = movietv['original_name'] else title = movietv['original_title'] end
  local msg = "*" .. title .. "* (" .. year .. ")"
  msg = msg .. "\n"
  msg = msg .. movietv['overview']
  -- Use the imdb search link if it's a TV show, fix later.
  --if imdb_id == nil then msg = msg .. "\n\nLearn more at: https://www.themoviedb.org/" .. type .. "/" .. movietv['id'] else msg = msg .. "\n\nLearn more at: http://www.imdb.com/title/" .. imdb_id end
  if imdb_id == nil then msg = msg .. "\n\nLearn more at: http://www.imdb.com/find?ref_=nv_sr_fn&q=" .. bot.uriencode(title) .. "&s=tv_episode" else msg = msg .. "\n\nLearn more at: http://www.imdb.com/title/" .. imdb_id end
  print(msg)
end

History

{lua} local query = args
if query == "" then print("Usage: !mdb <movie/tv show/actors>") return end
if query == "test" then print("Don't look this creepy ass movie up, at all...") return end
url = "https://api.themoviedb.org/3/search/multi?api_key=" .. fmap.api_keys.moviedb .. "&language=en-US&page=1&include_adult=false&query=" .. bot.uriencode(query)
local resp, err = requests.get(url)
if err ~= nil then print("Error: " .. err) return end
local j = resp:json()
if j['results'] == nil then print("Error: That movie/tv show/actor was not found in the database.") return end
local res = j['results'][1]
if res == nil then print("Error: That movie/tv show/actor was not found in the database.") return end
local type = res['media_type']
if type == "person" then
  local knownfor = res['known_for']
  url = "https://api.themoviedb.org/3/person/" .. res['id'] .. "?api_key=" .. fmap.api_keys.moviedb .. "&language=en-US"
  local perres, err = requests.get(url)
  if err ~= nil then print("First Error: " .. err) return end
  person = perres:json()
  local birthyear = ""
  local deathyear = ""

  if getmetatable(person['birthday'])['sub'] ~= nil then birthyear = string.sub(person['birthday'], 0, 4) end
  local imdb_id = person['imdb_id']
  
  -- There is some weird bug with null values in a table, this is the only way I could fix it.
  if getmetatable(person['deathday'])['sub'] ~= nil then deathyear = string.sub(person['deathday'], 0, 4) end
  local msg = "*" .. person['name'] .. "* (" .. birthyear .. "―" .. deathyear .. ")"
  msg = msg .. "\n"
  if getmetatable(person['biography'])['sub'] ~= nil then
    local bio = string.find(person['biography'], "\n\n")
    if bio ~= nil then
      if (string.find(string.sub(person['biography'], bio + 1), "\n\n") ~= nil) then bio = bio + string.find(string.sub(person['biography'], bio + 1), "\n\n") end
      msg = msg .. string.sub(person['biography'], 0, bio)
    else
      msg = msg .. person['biography']
    end
  else
    msg = msg .. "This person is so unknown that the API broke.  So I'm simply just going to fill this text with random garbage until it looks as if I know all about this person."
  end
  msg = msg .. "\n\nLearn more at: http://www.imdb.com/name/" .. imdb_id
  print(msg)
else
  local movietv = j['results'][1]
  url = "https://api.themoviedb.org/3/" .. type .. "/" .. res['id'] .. "?api_key=" .. fmap.api_keys.moviedb .. "&language=en-US"
  local moviedbinfo, err = requests.get(url)
  if err ~= nil then print("Second Error: " .. err) return end
  moviedbinfo = moviedbinfo:json()
  local imdb_id = moviedbinfo['imdb_id']
  
  local year,title = ""
  if type == "tv" then year = string.sub(movietv['first_air_date'], 0, 4) else year = string.sub(movietv['release_date'], 0, 4) end
  if type == "tv" then title = movietv['original_name'] else title = movietv['original_title'] end
  local msg = "*" .. title .. "* (" .. year .. ")"
  msg = msg .. "\n"
  msg = msg .. movietv['overview']
  -- Use the imdb search link if it's a TV show, fix later.
  --if imdb_id == nil then msg = msg .. "\n\nLearn more at: https://www.themoviedb.org/" .. type .. "/" .. movietv['id'] else msg = msg .. "\n\nLearn more at: http://www.imdb.com/title/" .. imdb_id end
  if imdb_id == nil then msg = msg .. "\n\nLearn more at: http://www.imdb.com/find?ref_=nv_sr_fn&q=" .. bot.uriencode(title) .. "&s=tv_episode" else msg = msg .. "\n\nLearn more at: http://www.imdb.com/title/" .. imdb_id end
  print(msg)
end
{lua} local query = args
if query == "" then print("Usage: !mdb <movie/tv show/actors>") return end
if query == "test" then print("Don't look this creepy ass movie up, at all...") return end
url = "https://api.themoviedb.org/3/search/multi?api_key=" .. fmap.api_keys.moviedb .. "&language=en-US&page=1&include_adult=false&query=" .. bot.uriencode(query)
local resp, err = requests.get(url)
if err ~= nil then print("Error: " .. err) return end
local j = resp:json()
if j['results'] == nil then print("Error: That movie/tv show/actor was not found in the database.") return end
local res = j['results'][1]
if res == nil then print("Error: That movie/tv show/actor was not found in the database.") return end
local type = res['media_type']
if type == "person" then
  local knownfor = res['known_for']
  url = "https://api.themoviedb.org/3/person/" .. res['id'] .. "?api_key=" .. fmap.api_keys.moviedb .. "&language=en-US"
  local perres, err = requests.get(url)
  if err ~= nil then print("First Error: " .. err) return end
  person = perres:json()
  local birthyear = ""
  local deathyear = ""
  if getmetatable(person['birthday']):__tostring() ~= "(null)" then birthyear = string.sub(person['birthday'], 0, 4) end
  local imdb_id = person['imdb_id']
  
  -- There is some weird bug with null values in a table, this is the only way I could fix it.
  if getmetatable(person['deathday']):__tostring() ~= "(null)" then deathyear = string.sub(person['deathday'], 0, 4) end
  local msg = "*" .. person['name'] .. "* (" .. birthyear .. "―" .. deathyear .. ")"
  msg = msg .. "\n"
  if getmetatable(person['deathday']):__tostring() ~= "(null)" then
    local bio = string.find(person['biography'], "\n\n")
    if bio ~= nil then
      if (string.find(string.sub(person['biography'], bio + 1), "\n\n") ~= nil) then bio = bio + string.find(string.sub(person['biography'], bio + 1), "\n\n") end
      msg = msg .. string.sub(person['biography'], 0, bio)
    else
      msg = msg .. person['biography']
    end
  else
    msg = msg .. "This person is so unknown that the API broke.  So I'm simply just going to fill this text with random garbage until it looks as if I know all about this person."
  end
  msg = msg .. "\n\nLearn more at: http://www.imdb.com/name/" .. imdb_id
  print(msg)
else
  local movietv = j['results'][1]
  url = "https://api.themoviedb.org/3/" .. type .. "/" .. res['id'] .. "?api_key=" .. fmap.api_keys.moviedb .. "&language=en-US"
  local moviedbinfo, err = requests.get(url)
  if err ~= nil then print("Second Error: " .. err) return end
  moviedbinfo = moviedbinfo:json()
  local imdb_id = moviedbinfo['imdb_id']
  
  local year,title = ""
  if type == "tv" then year = string.sub(movietv['first_air_date'], 0, 4) else year = string.sub(movietv['release_date'], 0, 4) end
  if type == "tv" then title = movietv['original_name'] else title = movietv['original_title'] end
  local msg = "*" .. title .. "* (" .. year .. ")"
  msg = msg .. "\n"
  msg = msg .. movietv['overview']
  -- Use the imdb search link if it's a TV show, fix later.
  --if imdb_id == nil then msg = msg .. "\n\nLearn more at: https://www.themoviedb.org/" .. type .. "/" .. movietv['id'] else msg = msg .. "\n\nLearn more at: http://www.imdb.com/title/" .. imdb_id end
  if imdb_id == nil then msg = msg .. "\n\nLearn more at: http://www.imdb.com/find?ref_=nv_sr_fn&q=" .. bot.uriencode(title) .. "&s=tv_episode" else msg = msg .. "\n\nLearn more at: http://www.imdb.com/title/" .. imdb_id end
  print(msg)
end
{lua} local query = args
if query == "" then print("Usage: !mdb <movie>") return end
url = "https://api.themoviedb.org/3/search/movie?api_key=95558a17139738f0cf4e289b9e05f44c&language=en-US&page=1&include_adult=false&query=" .. bot.uriencode(query)
local resp, err = requests.get(url)
if err ~= nil then print("Error: " .. err) return end
local j = resp:json()
local movie = j['results'][1]
if movie == nil then print("Error: That movie was not found in the database.") return end
local year = string.sub(movie['release_date'], 0, 4)
local msg = "*" .. movie['original_title'] .. "* (" .. year .. ")"
msg = msg .. "\n"
msg = msg .. movie['overview']
--local image = movie['poster_path'];
--if image ~= nil then print("https://image.tmdb.org/t/p/w300_and_h450_bestv2/" .. image) end
msg = msg .. "\n\nLearn more at: https://www.themoviedb.org/movie/" .. movie['id']
print(msg)
{lua} local query = args
if query == "" then print("Usage: !mdb <movie>") return end
url = "https://api.themoviedb.org/3/search/movie?api_key=95558a17139738f0cf4e289b9e05f44c&language=en-US&page=1&include_adult=false&query=" .. bot.uriencode(query)
local resp, err = requests.get(url)
if err ~= nil then print("Error: " .. err) return end
local j = resp:json()
local movie = j['results'][1]
if movie = nil then print("Error: That movie was not found in the database.") return end
local year = string.sub(movie['release_date'], 0, 4)
local msg = "*" .. movie['original_title'] .. "* (" .. year .. ")"
msg = msg .. "\n"
msg = msg .. movie['overview']
--local image = movie['poster_path'];
--if image ~= nil then print("https://image.tmdb.org/t/p/w300_and_h450_bestv2/" .. image) end
msg = msg .. "\n\nLearn more at: https://www.themoviedb.org/movie/" .. movie['id']
print(msg)
{lua} local query = args
if query == "" then print("Usage: !mdb <movie>") return end
url = "https://api.themoviedb.org/3/search/movie?api_key=95558a17139738f0cf4e289b9e05f44c&language=en-US&page=1&include_adult=false&query=" .. bot.uriencode(query)
local resp, err = requests.get(url)
if err ~= nil then print("Error: " .. err) return end
local j = resp:json()
local movie = j['results'][1]
local year = string.sub(movie['release_date'], 0, 4)
local msg = "*" .. movie['original_title'] .. "* (" .. year .. ")"
msg = msg .. "\n"
msg = msg .. movie['overview']
--local image = movie['poster_path'];
--if image ~= nil then print("https://image.tmdb.org/t/p/w300_and_h450_bestv2/" .. image) end
msg = msg .. "\n\nLearn more at: https://www.themoviedb.org/movie/" .. movie['id']
print(msg)
{lua} local query = args
if query == nil then print("Usage: !mdb <movie>") return end
url = "https://api.themoviedb.org/3/search/movie?api_key=95558a17139738f0cf4e289b9e05f44c&language=en-US&page=1&include_adult=false&query=" .. bot.uriencode(query)
local resp, err = requests.get(url)
if err ~= nil then print("Error: " .. err) return end
local j = resp:json()
local movie = j['results'][1]
local year = string.sub(movie['release_date'], 0, 4)
local msg = "*" .. movie['original_title'] .. "* (" .. year .. ")"
msg = msg .. "\n"
msg = msg .. movie['overview']
--local image = movie['poster_path'];
--if image ~= nil then print("https://image.tmdb.org/t/p/w300_and_h450_bestv2/" .. image) end
msg = msg .. "\n\nLearn more at: https://www.themoviedb.org/movie/" .. movie['id']
print(msg)