2 * Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
32 g_print("Usage: script [options]\n"
34 " -p .. Dump playlist scripts\n"
35 " -m .. Dump media scripts [default]\n"
36 " -s .. Dump scan scripts\n"
38 " -t<arg> =pd .. Property mask, possible values: 'd','p','n','s'\n"
43 static QuviScriptType type
= QUVI_SCRIPT_TYPE_MEDIA
;
44 static GString
*mask
= NULL
;
46 static void parse_mask(gchar
*arg
)
53 mask
= g_string_new(NULL
);
63 g_string_append_c(mask
, arg
[i
]);
66 g_printerr("[%s] Unknown property mask character `%c'\n",
72 static void parse_args(gint argc
, gchar
**argv
)
77 if (strlen(argv
[i
]) <2 || argv
[i
][0] != '-')
84 type
= QUVI_SCRIPT_TYPE_PLAYLIST
;
87 type
= QUVI_SCRIPT_TYPE_MEDIA
;
90 type
= QUVI_SCRIPT_TYPE_SCAN
;
102 static void dump_script(quvi_t q
)
104 GString
*o
= g_string_new("Properties:\n");
105 gchar
*prop
= mask
->str
;
110 QuviScriptProperty qsp
;
114 qsp
= QUVI_SCRIPT_PROPERTY_DOMAINS
;
115 g_string_append(o
, " d=");
118 qsp
= QUVI_SCRIPT_PROPERTY_FILEPATH
;
119 g_string_append(o
, " p=");
122 qsp
= QUVI_SCRIPT_PROPERTY_FILENAME
;
123 g_string_append(o
, " n=");
126 qsp
= QUVI_SCRIPT_PROPERTY_SHA1
;
127 g_string_append(o
, " s=");
130 g_warning("Invalid property mask character `%c'\n", prop
[i
]);
135 quvi_script_get(q
, type
, qsp
, &s
);
136 g_string_append_printf(o
, "%s\n", s
);
139 g_print("%s", o
->str
);
140 g_string_free(o
, TRUE
);
143 gint
main(gint argc
, gchar
**argv
)
145 setlocale(LC_ALL
, "");
146 parse_args(argc
, argv
);
149 mask
= g_string_new("pd"); /* Default. */
151 g_printerr("[%s] mask=%s, type=%d\n", __func__
, mask
->str
, type
);
157 while (quvi_script_next(q
, type
) == QUVI_TRUE
)
160 g_string_free(mask
, TRUE
);
168 /* vim: set ts=2 sw=2 tw=72 expandtab: */