1 /*****************************************************************************
2 * html.c : HTML playlist export module
3 *****************************************************************************
4 * Copyright (C) 2008-2009 the VideoLAN team
6 * Authors: RĂ©mi Duraffort <ivoire@videolan.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.
21 *****************************************************************************/
27 #include <vlc_common.h>
28 #include <vlc_input_item.h>
29 #include <vlc_playlist_export.h>
30 #include <vlc_strings.h>
35 // Export the playlist in HTML
36 int Export_HTML( vlc_object_t
*p_this
);
40 * Recursively follow the playlist
41 * @param p_export: the export structure
42 * @param p_root: the current node
44 static void DoExport( struct vlc_playlist_export
*p_export
)
46 /* Go through the playlist and add items */
47 size_t count
= vlc_playlist_view_Count(p_export
->playlist_view
);
48 for( size_t i
= 0; i
< count
; ++i
)
50 vlc_playlist_item_t
*item
=
51 vlc_playlist_view_Get(p_export
->playlist_view
, i
);
53 input_item_t
*media
= vlc_playlist_item_GetMedia(item
);
55 char* psz_name
= NULL
;
56 char *psz_tmp
= input_item_GetName(media
);
58 psz_name
= vlc_xml_encode( psz_tmp
);
63 char* psz_artist
= NULL
;
64 psz_tmp
= input_item_GetArtist(media
);
66 psz_artist
= vlc_xml_encode( psz_tmp
);
69 vlc_tick_t i_duration
= input_item_GetDuration(media
);
70 int min
= SEC_FROM_VLC_TICK( i_duration
) / 60;
71 int sec
= SEC_FROM_VLC_TICK( i_duration
) - min
* 60;
73 // Print the artist if we have one
74 if( psz_artist
&& *psz_artist
)
75 fprintf( p_export
->file
, " <li>%s - %s (%02d:%02d)</li>\n", psz_artist
, psz_name
, min
, sec
);
77 fprintf( p_export
->file
, " <li>%s (%2d:%2d)</li>\n", psz_name
, min
, sec
);
87 * Export the playlist as an HTML page
88 * @param p_this: the playlist
89 * @return VLC_SUCCESS if everything goes fine
91 int Export_HTML( vlc_object_t
*p_this
)
93 struct vlc_playlist_export
*p_export
= (struct vlc_playlist_export
*) p_this
;
95 msg_Dbg( p_export
, "saving using HTML format" );
98 fprintf( p_export
->file
, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
99 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"
100 "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n"
102 " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"
103 " <meta name=\"Generator\" content=\"VLC media player\" />\n"
104 " <meta name=\"Author\" content=\"VLC, http://www.videolan.org/vlc/\" />\n"
105 " <title>VLC generated playlist</title>\n"
106 " <style type=\"text/css\">\n"
108 " background-color: #E4F3FF;\n"
109 " font-family: sans-serif, Helvetica, Arial;\n"
110 " font-size: 13px;\n"
114 " font-size: 25px;\n"
122 " <h1>Playlist</h1>\n"
126 // Call the playlist constructor
130 fprintf( p_export
->file
, " </ol>\n"