2 -- Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 -- This file is part of libquvi-scripts <http://quvi.sourceforge.net/>.
6 -- This library is free software; you can redistribute it and/or
7 -- modify it under the terms of the GNU Lesser General Public
8 -- License as published by the Free Software Foundation; either
9 -- version 2.1 of the License, or (at your option) any later version.
11 -- This library is distributed in the hope that it will be useful,
12 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 -- Lesser General Public License for more details.
16 -- You should have received a copy of the GNU Lesser General Public
17 -- License along with this library; if not, write to the Free Software
18 -- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 -- Identify the playlist script.
24 local A
= require
'quvi/accepts'
26 accepts
= A
.accepts(qargs
.input_url
,
27 {"soundcloud%.com"}, {'/sets/[%w-_]+/'})
32 -- Parse playlist properties.
35 qargs
.id
, s
= qargs
.input_url
:match('/([%w-_]+)/sets/([%w-_]+)/')
36 if qargs
.id
and s
then
37 qargs
.id
= qargs
.id
.."_".. s
40 local C
= require
'quvi/const'
41 local o
= { [C
.qfo_type
] = C
.qft_playlist
}
42 local p
= quvi
.fetch(qargs
.input_url
, o
)
44 qargs
.thumb_url
= p
:match('.+content="(.-)"%s+property="og:image"') or ''
45 qargs
.title
= p
:match('.+content="(.-)"%s+property="og:title"') or ''
47 local m
= 'class="info">.-href="(.-)"'
48 .. '.-class="set%-track%-title">(.-)<'
49 .. '.-class="time">(.-)<'
53 for u
,t
,d
in p
:gmatch(m
) do
54 local m
,s
= d
:match('(%d+)%.(%d+)')
56 duration_ms
= ((tonumber(m
or '0')*60) + tonumber(s
or '0')) *1000,
57 url
= "http://soundcloud" ..u
,
60 table.insert(qargs
.media
, r
)
66 -- vim: set ts=2 sw=2 tw=72 expandtab: