From 6e580da685a0f4f55a643074dcab862a9c1b99ee Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Sat, 28 Sep 2013 11:04:19 +0300 Subject: [PATCH] media/myspass.lua: Rewrite ident function Rewrite the `ident' function for the libquvi 0.9+ series. * Implement `MySpass.can_parse_url' function * Remove any now obsolete code Signed-off-by: Toni Gundogdu --- share/media/myspass.lua | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/share/media/myspass.lua b/share/media/myspass.lua index dcb52d8..2b52981 100644 --- a/share/media/myspass.lua +++ b/share/media/myspass.lua @@ -1,4 +1,5 @@ -- libquvi-scripts +-- Copyright (C) 2013 Toni Gundogdu -- Copyright (C) 2012 Guido Leisker -- -- This file is part of libquvi-scripts . @@ -18,26 +19,14 @@ -- . -- --- About --- Each video url ends with an id composed of digits. --- This id leads us to a metadata xml file (see function --- MySpass.getMetadataValue) containing all necessary information --- including download link. - local MySpass = {} -- Utility functions unique to this script --- Identify the script. -function ident(self) - package.path = self.script_dir .. '/?.lua' - local C = require 'quvi/const' - local r = {} - r.domain = "myspass%.de" - r.formats = "default" - r.categories = C.proto_http - local U = require 'quvi/util' - -- expect all urls ending with digits to be videos - r.handles = U.handles(self.page_url, {r.domain}, {"/myspass/.-/%d+/?$"}) - return r +-- Identify the media script. +function ident(qargs) + return { + can_parse_url = MySpass.can_parse_url(qargs), + domains = table.concat({'myspass.de'}, ',') + } end -- Query available formats. @@ -71,6 +60,20 @@ end -- Utility functions -- +function MySpass.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('myspass%.de$') + -- Expect all URLs ending with digits to be videos. + and t.path and t.path:lower():match('^/myspass/.-/%d+/?$') + then + return true + else + return false + end +end + function MySpass.getMetadataValue(self, key) if self.metadata == nil then self.metadata = quvi.fetch( -- 2.11.4.GIT