Curb your ethusiasm most
This commit is contained in:
parent
8d96c8277e
commit
51be032dbc
|
@ -13,9 +13,12 @@ local function video_length (video_filename)
|
||||||
assert(type(video_filename) == 'string')
|
assert(type(video_filename) == 'string')
|
||||||
local f = io.popen(('ffprobe -i "%s" -show_entries format=duration -v quiet -of csv="p=0"'):format(video_filename), 'r')
|
local f = io.popen(('ffprobe -i "%s" -show_entries format=duration -v quiet -of csv="p=0"'):format(video_filename), 'r')
|
||||||
local str = f:read '*all'
|
local str = f:read '*all'
|
||||||
local len = tonumber(str)
|
|
||||||
assert(type(len) == 'number')
|
|
||||||
f:close()
|
f:close()
|
||||||
|
local len = tonumber(str)
|
||||||
|
if type(len) ~= 'number' then
|
||||||
|
error('Could not determine length of file "'..video_filename..'". ffprobe had this to say: '..str)
|
||||||
|
end
|
||||||
|
--
|
||||||
return len
|
return len
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -122,5 +125,5 @@ end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
return curb_your_video
|
return { your_video = curb_your_video }
|
||||||
|
|
||||||
|
|
|
@ -266,7 +266,8 @@ end
|
||||||
function internet.download_video (url)
|
function internet.download_video (url)
|
||||||
assert(type(url) == 'string')
|
assert(type(url) == 'string')
|
||||||
local video_filename = os.tmpname()
|
local video_filename = os.tmpname()
|
||||||
os.execute(('youtube-dl "%s" -o "%s" &> /dev/null'):format(url, video_filename))
|
local status = os.execute(('youtube-dl "%s" -o "%s"'):format(url, video_filename))
|
||||||
|
assert(status == 0)
|
||||||
return video_filename..'.mkv'
|
return video_filename..'.mkv'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
12
memes.lua
12
memes.lua
|
@ -503,7 +503,7 @@ local function generate_bait_link()
|
||||||
return 'https://dcav.pw/jbait'
|
return 'https://dcav.pw/jbait'
|
||||||
end
|
end
|
||||||
|
|
||||||
local curb_your_video = require 'curb_your_enthusiasm'
|
local curb = require 'curb_your_enthusiasm'
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -520,13 +520,13 @@ function memes.generate_for_message (user, message)
|
||||||
return 'https://www.youtube.com/watch?v=wl-LeTFM8zo', 'MACHINE'
|
return 'https://www.youtube.com/watch?v=wl-LeTFM8zo', 'MACHINE'
|
||||||
end
|
end
|
||||||
|
|
||||||
do
|
do -- Curb your enthusiasm
|
||||||
local url = message:lower():match '^curb%s+your%s+(.+)$'
|
local url = message:match '^[Cc]urb%s+[Yy]our%s+(.+)$'
|
||||||
local url2, timestamp = message:match '^(..-)%s+at%s+(-?[%d.]+)$'
|
local url2, timestamp = message:match '^(..-)%s+at%s+(-?[%d.]+)$'
|
||||||
if url2 then url = url2 end
|
if url2 then url = url2 end
|
||||||
timestamp = timestamp and tonumber(timestamp) or nil
|
timestamp = timestamp and tonumber(timestamp) or nil
|
||||||
assert(type(timestamp) == 'number' or timestamp == nil)
|
assert(type(timestamp) == 'number' or timestamp == nil)
|
||||||
local video_filename = curb_your_video(url, timestamp)
|
local video_filename = curb.your_video(url, timestamp)
|
||||||
local video_url = save_file_to_dcav(video_filename)
|
local video_url = save_file_to_dcav(video_filename)
|
||||||
return video_url, 'CURB'
|
return video_url, 'CURB'
|
||||||
end
|
end
|
||||||
|
@ -546,8 +546,8 @@ function memes.generate_for_message (user, message)
|
||||||
do
|
do
|
||||||
-- Attempt to match
|
-- Attempt to match
|
||||||
local problem_text
|
local problem_text
|
||||||
for _, pattern in ipairs { '^(.-)%s+er%s+skrald(.-)$', '^(.-)%s+is%s+trash(.-)$' } do
|
for _, pattern in ipairs { '^(.-)%s+[Ee][Rr]%s+[Ss][Kk][Rr][Aa][Ll][Dd](.-)$', '^(.-)%s+[Ii][Ss]%s+[Tt][Rr][Aa][Ss][Hh](.-)$' } do
|
||||||
problem_text = message:lower():match(pattern)
|
problem_text = message:match(pattern)
|
||||||
if problem_text then break end
|
if problem_text then break end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user