1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2019 VLC authors and VideoLAN
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program 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
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
25 #include <vlc_playlist_export.h>
30 #include <vlc_common.h>
32 #include <vlc_modules.h>
37 struct vlc_playlist_view
39 vlc_playlist_t
*playlist
;
43 vlc_playlist_view_Count(struct vlc_playlist_view
*view
)
45 return vlc_playlist_Count(view
->playlist
);
49 vlc_playlist_view_Get(struct vlc_playlist_view
*view
, size_t index
)
51 return vlc_playlist_Get(view
->playlist
, index
);
55 vlc_playlist_Export(struct vlc_playlist
*playlist
, const char *filename
,
58 vlc_playlist_AssertLocked(playlist
);
60 struct vlc_playlist_export
*export
=
61 vlc_custom_create(vlc_player_GetObject(playlist
->player
),
62 sizeof(*export
), "playlist export");
67 int ret
= VLC_EGENERIC
;
69 struct vlc_playlist_view playlist_view
= { .playlist
= playlist
};
71 export
->playlist_view
= &playlist_view
;
72 export
->base_url
= vlc_path2uri(filename
, NULL
);
73 export
->file
= vlc_fopen(filename
, "wt");
76 msg_Err(export
, "Could not create playlist file %s, %s",
77 filename
, vlc_strerror_c(errno
));
81 // this will actually export
82 module_t
*module
= module_need(export
, "playlist export", type
, true);
86 msg_Err(export
, "Could not export playlist");
90 module_unneed(export
, module
);
92 if (!ferror(export
->file
))
95 msg_Err(export
, "Could not write playlist file: %s",
96 vlc_strerror_c(errno
));
101 free(export
->base_url
);
102 vlc_object_delete(export
);