2 * Copyright (C) 2013 Mohamed El Morabity <melmorabity@fedoraproject.org>
3 * Copyright (C) 2012,2013 Toni Gundogdu <legatvs@gmail.com>
5 * This file is part of libquvi-scripts <http://quvi.sourceforge.net>.
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Affero General Public
9 * License as published by the Free Software Foundation, either
10 * version 3 of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General
18 * Public License along with this program. If not, see
19 * <http://www.gnu.org/licenses/>.
23 * NOTE: Media hosted at videos.arte.tv expire after some time. For this
24 * test, we need to fetch the front page and parse a test media URL from
36 static const gchar PATTERN
[] = "\"url\":\"(.*?)\"";
37 static const gchar WWW
[] = "http://www.arte.tv/guide/fr/plus7.json";
39 static void test_media_arte()
41 struct qm_test_opts_s o
;
46 if (chk_geoblocked() == FALSE
)
49 memset(&o
, 0, sizeof(o
));
51 /* Normally done in qm_test, due to fetch-parse, do it here. */
53 if (chk_skip(__func__
) == TRUE
)
62 c
= capture_new(p
, PATTERN
, 0);
65 while (capture_matches(c
) == TRUE
)
67 r
= capture_fetch(c
, 1);
68 l
= g_slist_prepend(l
, g_strdup_printf("http://www.arte.tv%s", r
));
72 l
= g_slist_reverse(l
);
73 g_assert_cmpint(g_slist_length(l
), >, 0);
75 /* Pick a random URL from the stack. */
77 const gint32 n
= g_random_int_range(0, g_slist_length(l
));
78 u
= (gchar
*) g_slist_nth_data(l
, n
);
82 g_test_message("media URL=%s", u
);
83 qm_test(__func__
, u
, NULL
, &o
);
85 slist_free_full(l
, (GFunc
) g_free
);
90 gint
main(gint argc
, gchar
**argv
)
92 g_test_init(&argc
, &argv
, NULL
);
93 g_test_add_func("/media/arte", test_media_arte
);
94 return (g_test_run());
97 /* vim: set ts=2 sw=2 tw=72 expandtab: */