From 0052c94b0eab665003336d4aba8f3735779c0a78 Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Sat, 17 Mar 2012 21:35:42 +0200 Subject: [PATCH] videobash.lua: Use "foo:match" instead --- share/lua/website/videobash.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/share/lua/website/videobash.lua b/share/lua/website/videobash.lua index ddd1a4c..db5437b 100644 --- a/share/lua/website/videobash.lua +++ b/share/lua/website/videobash.lua @@ -1,5 +1,6 @@ -- libquvi-scripts +-- Copyright (C) 2012 Toni Gundogdu -- Copyright (C) 2011 Thomas Preud'homme -- -- This file is part of libquvi-scripts . @@ -21,7 +22,7 @@ -- -- Identify the script. -function ident (self) +function ident(self) package.path = self.script_dir .. '/?.lua' local C = require 'quvi/const' local r = {} @@ -40,18 +41,19 @@ function query_formats(self) end -- Parse media URL. -function parse (self) +function parse(self) self.host_id = "videobash" - local page = quvi.fetch(self.page_url) - local _,_,s = page:find("(.-)%s+-") - self.title = s or error ("no match: media title") + local p = quvi.fetch(self.page_url) - local _,_,s = page:find("addFavorite%((%d+)") - self.id = s or error ("no match: media id") + self.title = p:match("<title>(.-)%s+-") + or error ("no match: media title") - local s = page:match('video_url=(.-)&') - or error("no match: media url") + self.id = p:match("addFavorite%((%d+)") + or error ("no match: media ID") + + local s = p:match('video_url=(.-)&') + or error("no match: media URL") local U = require 'quvi/util' self.url = {U.unescape(s)} -- 2.11.4.GIT