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_flags & PLAYLIST_SAVE_FLAG )
56 if( p_current->i_children >= 0 )
58 DoChildren( p_export, p_current );
62 char* psz_name = NULL;
63 char *psz_tmp = input_item_GetName( p_current->p_input );
65 psz_name = convert_xml_special_chars( psz_tmp );
70 char* psz_artist = NULL;
71 psz_tmp = input_item_GetArtist( p_current->p_input );
73 psz_artist = convert_xml_special_chars( psz_tmp );
76 mtime_t i_duration = input_item_GetDuration( p_current->p_input );
77 int min = ( i_duration / 1000000 ) / 60;
78 int sec = ( i_duration / 1000000 ) - min * 60;
80 // Print the artist if we have one
81 if( psz_artist && *psz_artist )
82 fprintf( p_export->p_file, " <li>%s - %s (%02d:%02d)</li>\n", psz_artist, psz_name, min, sec );
84 fprintf( p_export->p_file, " <li>%s (%2d:%2d)</li>\n", psz_name, min, sec );
94 * Export the playlist as an HTML page
95 * @param p_this: the playlist
96 * @return VLC_SUCCESS if everything goes fine
98 int Export_HTML( vlc_object_t *p_this )
100 playlist_export_t *p_export = (playlist_export_t *)p_this;
102 msg_Dbg( p_export, "saving using HTML format" );
105 fprintf( p_export->p_file, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
106 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"
107 "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n"
109 " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n"
110 " <meta name=\"Generator\" content=\"VLC media player\" />\n"
111 " <meta name=\"Author\" content=\"videolan@videolan.org (VideoLAN team)\" />\n"
112 " <title>VLC generated playlist</title>\n"
113 " <style type=\"text/css\">\n"
115 " background-color: #E4F3FF;\n"
116 " font-family: sans-serif, Helvetica, Arial;\n"
117 " font-size: 13px;\n"
121 " font-size: 25px;\n"
129 " <h1>Playlist</h1>\n"
133 // Call the playlist constructor
134 DoChildren( p_export, p_export->p_root );
137 fprintf( p_export->p_file, " </ol>\n"