4 Copyright © 2010 VideoLAN and AUTHORS
6 Authors: Rémi Duraffort <ivoire at videolan dot org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26 return { title
= 'librivox' }
29 -- Transform a duration 'mm:ss' or 'hh::mm::ss' into an integer
30 function string_2_duration(str
)
31 local index
= string.find( str
, ':' )
32 if( index
== nil ) then return str
35 return string.sub( str
, 2 )
37 local index2
= string.find( str
, ':', index
+ 1 )
38 if( index2
== nil ) then
39 return string.sub( str
, 0, index
- 1 ) * 60 + string.sub( str
, index
+ 1 )
41 return string.sub( str
, 0, index
- 1 ) * 3600 + string.sub( str
, index
+ 1, index2
- 1 ) * 60 + string.sub( str
, index2
+ 1 )
47 local podcast
= simplexml
.parse_url( 'http://librivox.org/podcast.xml' )
48 simplexml
.add_name_maps( podcast
)
50 local channel
= podcast
.children_map
['channel'][1]
54 for _
, item
in ipairs( channel
.children
) do
55 if( item
.name
== 'item' ) then
56 simplexml
.add_name_maps( item
)
58 -- If the book title is unknown, create a node for it in the sd
59 local book_title
= item
.children_map
['itunes:subtitle'][1].children
[1]
60 if( books
[book_title
] == nil ) then
61 books
[book_title
] = vlc
.sd
.add_node( { title
= book_title
,
65 -- Add the new chapter to the book
66 books
[book_title
]:add_subitem( { path
= item
.children_map
['link'][1].children
[1],
67 title
= item
.children_map
['title'][1].children
[1],
68 album
= item
.children_map
['itunes:subtitle'][1].children
[1],
69 artist
= item
.children_map
['itunes:author'][1].children
[1],
70 duration
= string_2_duration( item
.children_map
['itunes:duration'][1].children
[1] ),
73 elseif( item
.name
== 'itunes:image' ) then
74 arturl
= item
.attributes
['href']