From e7f8c1583ad27749733939c83f401c3d5b1fbfad Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Sun, 5 May 2013 16:33:29 +0300 Subject: [PATCH] media/clipfish.lua: Rewrite ident function Rewrite the `ident' function for the libquvi 0.9+ series. * Add local table `ClipFish', implement `can_parse_url' * Remove any now obsolete code Signed-off-by: Toni Gundogdu --- share/media/clipfish.lua | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/share/media/clipfish.lua b/share/media/clipfish.lua index 497bb63..be9aaaa 100644 --- a/share/media/clipfish.lua +++ b/share/media/clipfish.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 = "clipfish%.de" - r.formats = "default" - r.categories = C.proto_http - local U = require 'quvi/util' - r.handles = U.handles(self.page_url, {r.domain}, {"/video/%d+/"}) - return r +local ClipFish = {} -- Utility functions unique to this script. + +-- Identify the media script. +function ident(qargs) + return { + can_parse_url = ClipFish.can_parse_url(qargs), + domains = table.concat({'clipfish.de'}, ',') + } end -- Query available formats. @@ -60,4 +57,21 @@ function parse(self) return self end +-- +-- Utility functions +-- + +function ClipFish.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('clipfish%.de$') + and t.path and t.path:lower():match('/video/%d+/.-/$') + then + return true + else + return false + end +end + -- vim: set ts=4 sw=4 tw=72 expandtab: -- 2.11.4.GIT