From c41e5cc9f3bb69ccc14a0b3b479b0de76fd232d8 Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Fri, 8 Feb 2013 18:01:02 +0200 Subject: [PATCH] ard.lua: Add Ard.quality_from function Have the Ard.quality function return a string containing one of the strings 'ld', 'md', 'sd', 'hd'. Other websites. Plenty of guessing going on here, these strings are roughly based on the findings posted here: http://article.gmane.org/gmane.comp.web.flash.quvi/170 0 = '256x144' -- ld 1 = '512x288' -- md 2 = '960x540' -- sd 3 ='1280x720' -- hd --- share/lua/website/ard.lua | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/share/lua/website/ard.lua b/share/lua/website/ard.lua index db8d357..7e7f516 100644 --- a/share/lua/website/ard.lua +++ b/share/lua/website/ard.lua @@ -121,12 +121,25 @@ function Ard.to_s(t) (t.height) and '_'..t.height or '') end +function Ard.quality_from(suffix) + local q = suffix:match('%.web(%w)%.') or suffix:match('%.(%w)%.') + or suffix:match('[=%.]Web%-(%w)') -- .webs. or Web-S or .s + if q then + q = q:lower() + local t = {s='ld', m='md', l='sd', xl='hd'} + for k,v in pairs(t) do + if q == k then return v end + end + end + return q +end + function Ard.iter_formats(page) local r = {} local s = 'mediaCollection%.addMediaStream' - .. '%(0, (%d), "(.-)", "(.-)", "%w+"%);' + .. '%(0, %d+, "(.-)", "(.-)", "%w+"%);' - for quality, prefix, suffix in page:gmatch(s) do + for prefix, suffix in page:gmatch(s) do local u = prefix .. suffix -- remove querystring u = u:match('^(.-)?') or u @@ -143,8 +156,8 @@ function Ard.iter_formats(page) url = u, container = suffix:match('^(...):') or suffix:match('%.(...)$') or suffix:match('%.(...)$') or 'mp4', - quality = tonumber(quality), encoding = suffix:match('%.(h264)%.'), + quality = Ard.quality_from(suffix), height = height, webx = webx } -- 2.11.4.GIT