From edbbf7c8b3fe178e1c22ac9e912daa805882e52a Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Wed, 12 Sep 2012 15:39:05 +0300 Subject: [PATCH] playlist/soundcloud.lua: Rewrite for can_parse_url --- share/playlist/soundcloud.lua | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/share/playlist/soundcloud.lua b/share/playlist/soundcloud.lua index 69d540f..cb5fb81 100644 --- a/share/playlist/soundcloud.lua +++ b/share/playlist/soundcloud.lua @@ -19,14 +19,14 @@ -- 02110-1301 USA -- +local Soundcloud = {} -- Utility functions unique to this script + -- Identify the playlist script. function ident(qargs) - local A = require 'quvi/accepts' - local r = { - accepts = A.accepts(qargs.input_url, - {"soundcloud%.com"}, {'/sets/[%w-_]+/'}) + return { + domains = table.concat({'soundcloud.com'}, ','), + can_parse_url = Soundcloud.can_parse_url(qargs) } - return r end -- Parse playlist properties. @@ -63,4 +63,21 @@ function parse(qargs) return qargs end +-- +-- Utility functions +-- + +function Soundcloud.can_parse_url(qargs) + local U = require 'quvi/url' + local t = U.parse(qargs.input_url) + if t and t.scheme and t.scheme:lower():match('^https?$') + and t.host and t.host:lower():match('soundcloud%.com$') + and t.path and t.path:lower():match('/sets/[%w-_]+/') + then + return true + else + return false + end +end + -- vim: set ts=2 sw=2 tw=72 expandtab: -- 2.11.4.GIT