From 71dfa2466441c9cec0172fec89ef1ace886cc315 Mon Sep 17 00:00:00 2001 From: jsg Date: Sun, 14 Sep 2008 12:28:10 +0000 Subject: [PATCH] Download higher quality videos (fmt=6) if available. ok martynas@ --- net/yt/Makefile | 4 ++-- net/yt/files/yt.lua | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/net/yt/Makefile b/net/yt/Makefile index 072ecb2835b..04b0749aad0 100644 --- a/net/yt/Makefile +++ b/net/yt/Makefile @@ -1,8 +1,8 @@ -# $OpenBSD: Makefile,v 1.19 2008/09/11 11:58:09 jsg Exp $ +# $OpenBSD: Makefile,v 1.20 2008/09/14 12:28:10 jsg Exp $ COMMENT= customizable script to fetch youtube videos -PKGNAME= yt-8p8 +PKGNAME= yt-9 CATEGORIES= net DISTFILES= diff --git a/net/yt/files/yt.lua b/net/yt/files/yt.lua index 6a7e43d9d2d..385b3779aa2 100644 --- a/net/yt/files/yt.lua +++ b/net/yt/files/yt.lua @@ -1,5 +1,5 @@ #!/usr/local/bin/lua --- $OpenBSD: yt.lua,v 1.13 2008/09/11 11:58:09 jsg Exp $ +-- $OpenBSD: yt.lua,v 1.14 2008/09/14 12:28:11 jsg 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 @@ -29,6 +29,13 @@ body = assert(http.request(url)) pattern = "(.-)" title = assert(string.match(body, pattern)) +-- Fetch high quality if available +if (string.match(body, "yt.VideoQualityConstants.HIGH") ~= nil) then + fmt = "&fmt=6" +else + fmt = "" +end + -- Build a name for the files the video will be stored in. file = string.gsub(title, "[^%w-]", "_") file = string.lower(file) @@ -48,7 +55,7 @@ if video_id then pattern = "/watch_fullscreen%?.*&t=(.-)&" t = assert(string.match(body, pattern)) url = string.format("%q", base_url .. "?video_id=" .. video_id - .. "&t=" .. t) + .. "&t=" .. t .. fmt) else -- We assume it's Google Video URL. pattern = "'/googleplayer.swf%?videoUrl(.-)'"