No issues found
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * The Rhythmbox authors hereby grant permission for non-GPL compatible
9 * GStreamer plugins to be used and distributed together with GStreamer
10 * and Rhythmbox. This permission is above and beyond the permissions granted
11 * by the GPL license by which Rhythmbox is covered. If you modify this code
12 * you may extend this exception to your version of the code, but you are not
13 * obligated to do so. If you do not wish to do so, delete this exception
14 * statement from your version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24 *
25 */
26
27
28 #include "config.h"
29
30 #include <locale.h>
31 #include <glib.h>
32 #include <glib-object.h>
33 #include <glib/gi18n.h>
34
35 #include "rb-podcast-parse.h"
36
37 #include <string.h>
38
39 static gboolean debug = FALSE;
40
41 void rb_debug_realf (const char *func,
42 const char *file,
43 int line,
44 gboolean newline,
45 const char *format, ...) G_GNUC_PRINTF (5, 6);
46
47 /* For the benefit of the podcast parsing code */
48 void
49 rb_debug_realf (const char *func,
50 const char *file,
51 int line,
52 gboolean newline,
53 const char *format, ...)
54 {
55 va_list args;
56 char buffer[1025];
57
58 if (debug == FALSE)
59 return;
60
61 va_start (args, format);
62 g_vsnprintf (buffer, 1024, format, args);
63 va_end (args);
64
65 g_printerr (newline ? "%s:%d [%s] %s\n" : "%s:%d [%s] %s",
66 file, line, func, buffer);
67 }
68
69 int main (int argc, char **argv)
70 {
71 RBPodcastChannel *data;
72 GList *l;
73 GDate date = {0,};
74 char datebuf[1024];
75 GError *error = NULL;
76
77 g_type_init ();
78 setlocale (LC_ALL, "");
79 bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
80 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
81
82 if (argv[2] != NULL && strcmp (argv[2], "--debug") == 0) {
83 debug = TRUE;
84 }
85
86 data = g_new0 (RBPodcastChannel, 1);
87 if (rb_podcast_parse_load_feed (data, argv[1], FALSE, &error) == FALSE) {
88 g_warning ("Couldn't parse %s: %s", argv[1], error->message);
89 g_clear_error (&error);
90 return 1;
91 }
92
93 g_date_set_time_t (&date, data->pub_date);
94 g_date_strftime (datebuf, 1024, "%F %T", &date);
95
96 g_print ("Podcast title: %s\n", data->title);
97 g_print ("Description: %s\n", data->description);
98 g_print ("Author: %s\n", data->author);
99 g_print ("Date: %s\n", datebuf);
100 g_print ("\n");
101
102 for (l = data->posts; l != NULL; l = l->next) {
103 RBPodcastItem *item = l->data;
104
105 g_date_set_time_t (&date, item->pub_date);
106 g_date_strftime (datebuf, 1024, "%F %T", &date);
107
108 g_print ("\tItem title: %s\n", item->title);
109 g_print ("\tURL: %s\n", item->url);
110 g_print ("\tAuthor: %s\n", item->author);
111 g_print ("\tDate: %s\n", datebuf);
112 g_print ("\tDescription: %s\n", item->description);
113 g_print ("\n");
114 }
115
116 return 0;
117 }