m_playlist_new: Store input URL in unescaped form
[libquvi.git] / src / misc / playlist.c
blobc670025238037c535d5f338b3039ce0c3bc50f7f
1 /* libquvi
2 * Copyright (C) 2012,2013 Toni Gundogdu <legatvs@gmail.com>
4 * This file is part of libquvi <http://quvi.sourceforge.net/>.
6 * This library is free software: you can redistribute it and/or
7 * modify it under the terms of the GNU Affero General Public
8 * License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
11 * This library 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 Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General
17 * Public License along with this library. If not, see
18 * <http://www.gnu.org/licenses/>.
21 #include "config.h"
23 #include <glib.h>
25 #include "quvi.h"
26 /* -- */
27 #include "_quvi_s.h"
28 #include "_quvi_playlist_s.h"
29 /* -- */
30 #include "misc/playlist.h"
31 #include "misc/slst.h"
32 #include "misc/url.h"
34 gpointer m_playlist_new(_quvi_t q, const gchar *url)
36 _quvi_playlist_t qp;
37 gchar *u;
39 qp = g_new0(struct _quvi_playlist_s, 1);
41 qp->url.thumbnail = g_string_new(NULL);
42 qp->id.playlist = g_string_new(NULL);
45 * Store the input URL in the unescaped form which is what the `ident'
46 * functions of the scripts expect when the support check is run
47 * offline.
49 u = m_url_unescaped_form(url);
50 qp->url.input = g_string_new(u);
51 g_free(u);
53 qp->title = g_string_new(NULL);
54 qp->handle.quvi = q;
56 return (qp);
59 void m_playlist_media_free(_quvi_playlist_media_t qpm)
61 if (qpm == NULL)
62 return;
64 g_string_free(qpm->title, TRUE);
65 qpm->title = NULL;
67 g_string_free(qpm->url, TRUE);
68 qpm->url = NULL;
70 g_free(qpm);
71 qpm = NULL;
74 static void _playlist_media_free(gpointer p, gpointer userdata)
76 m_playlist_media_free(p);
79 void m_playlist_free(_quvi_playlist_t qp)
81 if (qp == NULL)
82 return;
84 m_slist_free_full(qp->media, _playlist_media_free);
85 qp->media = NULL;
87 /* URL */
89 g_string_free(qp->url.thumbnail, TRUE);
90 qp->url.thumbnail = NULL;
92 g_string_free(qp->url.input, TRUE);
93 qp->url.input = NULL;
95 /* ID */
97 g_string_free(qp->id.playlist, TRUE);
98 qp->id.playlist = NULL;
100 /* Other */
102 g_string_free(qp->title, TRUE);
103 qp->title = NULL;
105 g_free(qp);
106 qp = NULL;
109 /* vim: set ts=2 sw=2 tw=72 expandtab: */