yt-2, with suggestions from sturm@, okay sturm@, jasper@
This commit is contained in:
parent
78ecfcb087
commit
4a0e94069e
@ -1,11 +1,10 @@
|
||||
# $OpenBSD: Makefile,v 1.1.1.1 2007/02/04 13:23:12 jasper Exp $
|
||||
# $OpenBSD: Makefile,v 1.2 2007/02/21 13:50:18 pedro Exp $
|
||||
|
||||
COMMENT= "customizable script to fetch youtube videos"
|
||||
|
||||
DISTNAME= yt-1
|
||||
CATEGORIES= misc
|
||||
|
||||
HOMEPAGE= http://ambientworks.net/~pedro/yt/
|
||||
PKGNAME= yt-2
|
||||
CATEGORIES= net
|
||||
DISTFILES=
|
||||
|
||||
MAINTAINER= Pedro Martelletto <pedro@openbsd.org>
|
||||
|
||||
@ -15,15 +14,12 @@ PERMIT_PACKAGE_FTP= Yes
|
||||
PERMIT_DISTFILES_CDROM= Yes
|
||||
PERMIT_DISTFILES_FTP= Yes
|
||||
|
||||
MASTER_SITES= ${HOMEPAGE}
|
||||
|
||||
NO_BUILD= Yes
|
||||
NO_REGRESS= Yes
|
||||
RUN_DEPENDS= ::graphics/ffmpeg \
|
||||
::net/curl \
|
||||
::net/luasocket
|
||||
|
||||
do-install:
|
||||
${INSTALL_SCRIPT} ${WRKSRC}/yt.lua ${PREFIX}/bin/yt
|
||||
${INSTALL_SCRIPT} ${FILESDIR}/yt.lua ${PREFIX}/bin/yt
|
||||
|
||||
.include <bsd.port.mk>
|
||||
|
@ -1,4 +0,0 @@
|
||||
MD5 (yt-1.tar.gz) = aba71d2db3b865f8237cee5ca7fdb140
|
||||
RMD160 (yt-1.tar.gz) = 7cd8cb23db29706f72cd6e722ac8ffe733e67748
|
||||
SHA1 (yt-1.tar.gz) = ef504b76967b367561d640b501832957483f90d2
|
||||
SIZE (yt-1.tar.gz) = 990
|
53
net/yt/files/yt.lua
Normal file
53
net/yt/files/yt.lua
Normal file
@ -0,0 +1,53 @@
|
||||
-- $OpenBSD: yt.lua,v 1.1 2007/02/21 13:50:18 pedro Exp $
|
||||
-- Fetch videos from YouTube.com and convert them to MPEG.
|
||||
-- Written by Pedro Martelletto in August 2006. Public domain.
|
||||
-- Example: lua yt.lua http://www.youtube.com/watch?v=c5uoo1Kl_uA
|
||||
|
||||
http = require("socket.http")
|
||||
|
||||
-- Make sure a URL was given.
|
||||
url = assert(arg[1], "Wrong usage, no URL given")
|
||||
|
||||
-- Set this to a command capable of talking HTTP and following 3XX requests.
|
||||
fetch = "ftp -o <file> <url>"
|
||||
|
||||
-- Set this to a command capable of converting from FLV to MPEG.
|
||||
convert = "ffmpeg -y -i <flv> -b 1000k -vcodec mpeg4 -acodec copy <avi> 1>/dev/null 2>&1"
|
||||
|
||||
-- Set this to the base location where to fetch YouTube videos from.
|
||||
base_url = "http://www.youtube.com/get_video?video_id="
|
||||
|
||||
-- Fetch the page holding the embedded video.
|
||||
print(string.format("Getting %s ...", url))
|
||||
body = assert(http.request(url))
|
||||
|
||||
-- Look for the video title.
|
||||
pattern = "<meta name=\"title\" content=\"(.-)\""
|
||||
title = assert(string.match(body, pattern))
|
||||
|
||||
-- Build a name for the files the video will be stored in.
|
||||
file = string.gsub(title, " ", "_")
|
||||
file = "youtube-" .. string.lower(file)
|
||||
flv = file .. ".flv"
|
||||
avi = file .. ".avi"
|
||||
|
||||
-- Escape the file names.
|
||||
e_flv = string.format("%q", flv)
|
||||
e_avi = string.format("%q", avi)
|
||||
|
||||
-- Look for the video ID.
|
||||
pattern = "player2.swf[?]video_id=(.-)\","
|
||||
id = assert(string.match(body, pattern))
|
||||
|
||||
-- Fetch the video.
|
||||
url = string.format("%q", base_url .. id)
|
||||
cmd = string.gsub(fetch, "<(%w+)>", { url = url, file = e_flv })
|
||||
assert(os.execute(cmd) == 0, "Failed")
|
||||
|
||||
-- Convert it to MPEG.
|
||||
cmd = string.gsub(convert, "<(%w+)>", { flv = e_flv, avi = e_avi })
|
||||
print("Converting ...")
|
||||
assert(os.execute(cmd) == 0, "Failed")
|
||||
|
||||
os.remove(flv)
|
||||
print("Done. Video saved in " .. avi .. ".")
|
@ -1,3 +1,3 @@
|
||||
yt is an extensible Lua script to fetch videos from YouTube.com. You can
|
||||
(and probaly should) customize it to use your preferred tools. By
|
||||
default it uses net/curl and graphics/ffmpeg.
|
||||
(and probaly should) customize it to use your preferred encoding tool.
|
||||
By default it uses graphics/ffmpeg.
|
||||
|
@ -1,2 +0,0 @@
|
||||
yt is pretty standard as-is. By default it comes with stock settings.
|
||||
It is very much prefered you configure it to use your favorite tools.
|
Loading…
Reference in New Issue
Block a user