From 05edfb52fdc2b651299d9a6ac25e820ae06070e3 Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Sat, 17 Mar 2012 21:46:37 +0200 Subject: [PATCH] blip.lua: Use "foo:match" instead --- share/lua/website/blip.lua | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/share/lua/website/blip.lua b/share/lua/website/blip.lua index d5df713..b170845 100644 --- a/share/lua/website/blip.lua +++ b/share/lua/website/blip.lua @@ -1,6 +1,6 @@ -- libquvi-scripts --- Copyright (C) 2011 Toni Gundogdu +-- Copyright (C) 2011-2012 Toni Gundogdu -- -- This file is part of libquvi-scripts . -- @@ -46,8 +46,8 @@ end -- Query formats. function query_formats(self) - local config = Blip.get_config(self) - local formats = Blip.iter_formats(config) + local c = Blip.get_config(self) + local formats = Blip.iter_formats(c) local t = {} for _,v in pairs(formats) do @@ -62,22 +62,22 @@ end -- Parse media URL. function parse(self) - self.host_id = "blip" - local config,U = Blip.get_config(self) + self.host_id = "blip" - local _,_,s = config:find('media:title>(.-)(.-)<') - self.thumbnail_url = s or '' + self.title = c:match('media:title>(.-)(.-)<') or '' + + local formats = Blip.iter_formats(c) local format = U.choose_format(self, formats, Blip.choose_best, Blip.choose_default, Blip.to_s) or error("unable to choose format") - self.url = {format.url or error("no match: media url")} + self.url = {format.url or error("no match: media URL")} return self end @@ -89,40 +89,40 @@ function Blip.get_config(self) local U = require 'quvi/util' self.page_url = U.unescape(self.page_url) - local _,_,id = self.page_url:find('/flash/(%d+)') + local id = self.page_url:match('/flash/(%d+)') if not id then local r = quvi.resolve(self.page_url) if #r > 0 then r = U.unescape(r) - _,_,id = r:find('/rss/flash/(%d+)') + id = r:match('/rss/flash/(%d+)') end end if not id then - local page = quvi.fetch(self.page_url) - _,_,id = page:find('data%-posts%-id="(.-)"') + local p = quvi.fetch(self.page_url) + id = p:match('data%-posts%-id="(.-)"') end - self.id = id or error('no match: media id') + self.id = id or error('no match: media ID') - local config_url = 'http://blip.tv/rss/flash/' .. self.id + local c_url = 'http://blip.tv/rss/flash/' .. self.id - return quvi.fetch(config_url, {fetch_type = 'config'}), U + return quvi.fetch(c_url, {fetch_type='config'}), U end -function Blip.iter_formats(config) +function Blip.iter_formats(c) local p = '