From 0f981fa8703ed20babbc0ca3b6243740b6f9dca1 Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Sun, 28 Apr 2013 12:33:07 +0300 Subject: [PATCH] media/sapo.lua: Rewrite ident function Rewrite the `ident' function for the libquvi 0.9+ series. * Add local table `SAPO', implement `can_parse_url' function * Remove any now obsolete code Signed-off-by: Toni Gundogdu --- share/media/sapo.lua | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/share/media/sapo.lua b/share/media/sapo.lua index ccec886..770500a 100644 --- a/share/media/sapo.lua +++ b/share/media/sapo.lua @@ -18,17 +18,14 @@ -- . -- --- Identify the script. -function ident(self) - package.path = self.script_dir .. '/?.lua' - local C = require 'quvi/const' - local r = {} - r.domain = "videos%.sapo%.pt" - r.formats = "default" - r.categories = C.proto_http - local U = require 'quvi/util' - r.handles = U.handles(self.page_url, {r.domain}) - return r +local SAPO = {} -- Utility functions unique to to this script. + +-- Identify the media script. +function ident(qargs) + return { + can_parse_url = SAPO.can_parse_url(qargs), + domains = table.concat({'videos.sapo.pt'}, ',') + } end -- Query available formats. @@ -57,4 +54,21 @@ function parse (self) return self end +-- +-- Utility functions +-- + +function SAPO.can_parse_url(qargs) + local U = require 'socket.url' + local t = U.parse(qargs.input_url) + if t and t.scheme and t.scheme:lower():match('^http$') + and t.host and t.host:lower():match('^videos%.sapo%.pt$') + and t.path and t.path:lower():match('^/%w+$') + then + return true + else + return false + end +end + -- vim: set ts=4 sw=4 tw=72 expandtab: -- 2.11.4.GIT