1 /*****************************************************************************
2 * html.c : HTML playlist export module
3 *****************************************************************************
4 * Copyright (C) 2008-2009 the VideoLAN team
7 * Authors: RĂ©mi Duraffort <ivoire@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
28 #include <vlc_common.h>
29 #include <vlc_playlist.h>
30 #include <vlc_input.h>
31 #include <vlc_strings.h>
36 // Export the playlist in HTML
37 int Export_HTML( vlc_object_t
*p_this
);
41 * Recursively follow the playlist
42 * @param p_export: the export structure
43 * @param p_root: the current node
45 static void DoChildren( playlist_export_t
*p_export
, playlist_item_t
*p_root
)
47 /* Go through the playlist and add items */
48 for( int i
= 0; i
< p_root
->i_children
; i
++)
50 playlist_item_t
*p_current
= p_root
->pp_children
[i
];
53 if( p_current
->i_children
>= 0 )
55 DoChildren( p_export
, p_current
);
59 char* psz_name
= NULL
;
60 char *psz_tmp
= input_item_GetName( p_current
->p_input
);
62 psz_name
= vlc_xml_encode( psz_tmp
);
67 char* psz_artist
= NULL
;
68 psz_tmp
= input_item_GetArtist( p_current
->p_input
);
70 psz_artist
= vlc_xml_encode( psz_tmp
);
73 mtime_t i_duration
= input_item_GetDuration( p_current
->p_input
);
74 int min
= ( i_duration
/ 1000000 ) / 60;
75 int sec
= ( i_duration
/ 1000000 ) - min
* 60;
77 // Print the artist if we have one
78 if( psz_artist
&& *psz_artist
)
79 fprintf( p_export
->p_file
, " <li>%s - %s (%02d:%02d)</li>\n", psz_artist
, psz_name
, min
, sec
);
81 fprintf( p_export
->p_file
, " <li>%s (%2d:%2d)</li>\n", psz_name
, min
, sec
);
91 * Export the playlist as an HTML page
92 * @param p_this: the playlist
93 * @return VLC_SUCCESS if everything goes fine
95 int Export_HTML( vlc_object_t
*p_this
)
97 playlist_export_t
*p_export
= (playlist_export_t
*)p_this
;
99 msg_Dbg( p_export
, "saving using HTML format" );
102 fprintf( p_export
->p_file
, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
103 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"
104 "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n"
106 " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"
107 " <meta name=\"Generator\" content=\"VLC media player\" />\n"
108 " <meta name=\"Author\" content=\"VLC, http://www.videolan.org/vlc/\" />\n"
109 " <title>VLC generated playlist</title>\n"
110 " <style type=\"text/css\">\n"
112 " background-color: #E4F3FF;\n"
113 " font-family: sans-serif, Helvetica, Arial;\n"
114 " font-size: 13px;\n"
118 " font-size: 25px;\n"
126 " <h1>Playlist</h1>\n"
130 // Call the playlist constructor
131 DoChildren( p_export
, p_export
->p_root
);
134 fprintf( p_export
->p_file
, " </ol>\n"