From c5ce42bf8ca3ccbb0f4af22f18e67c3d2dc8f7ec Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Tue, 31 Jul 2012 12:27:21 +0300 Subject: [PATCH] parse: Rewrite for qargs.streams --- share/lua/media/break.lua | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/share/lua/media/break.lua b/share/lua/media/break.lua index d3ef45c..f05bde5 100644 --- a/share/lua/media/break.lua +++ b/share/lua/media/break.lua @@ -34,23 +34,27 @@ end -- Parse media properties. function parse(qargs) - local p = quvi.fetch(self.page_url) + local p = quvi.fetch(qargs.input_url) - self.title = p:match('id="vid_title" content="(.-)"') - or error("no match: media title") + qargs.title = p:match('id="vid_title" content="(.-)"') or '' + qargs.id = p:match("ContentID='(.-)'") or '' - self.id = p:match("ContentID='(.-)'") - or error("no match: media ID") + local n = p:match("FileName='(.-)'") or error("no match: file name") + local h = p:match('flashVars.icon = "(.-)"') or error("no match: file hash") - local fn = p:match("FileName='(.-)'") - or error("no match: file name") + qargs.streams = Break.iter_streams(n, h) - local fh = p:match('flashVars.icon = "(.-)"') - or error("no match: file hash") + return qargs +end - self.url = {string.format("%s.flv?%s", fn, fh)} +-- +-- Utility functions. +-- - return self +function Break.iter_streams(n, h) + local u = string.format("%s.flv?%s", n, h) + local S = require 'quvi/stream' + return {S.stream_new(u)} end -- vim: set ts=4 sw=4 tw=72 expandtab: -- 2.11.4.GIT