libnfo  1.0.1
nfo.h
Go to the documentation of this file.
1 /*
2  * GeeXboX libnfo: a .NFO file reader/writer.
3  * Copyright (C) 2009-2010 Benjamin Zores <ben@geexbox.org>
4  *
5  * This file is part of libnfo.
6  *
7  * libnfo is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * libnfo 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 GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with libvalhalla; if not, write to the Free Software
19  * Foundation, Inc, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef NFO_H
23 #define NFO_H
24 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif /* __cplusplus */
34 
35 #define NFO_STRINGIFY(s) #s
36 #define NFO_TOSTRING(s) NFO_STRINGIFY(s)
37 
38 #define NFO_VERSION_INT(a, b, c) (a << 16 | b << 8 | c)
39 #define NFO_VERSION_DOT(a, b, c) a ##.## b ##.## c
40 #define NFO_VERSION(a, b, c) NFO_VERSION_DOT(a, b, c)
41 
42 #define LIBNFO_VERSION_MAJOR 1
43 #define LIBNFO_VERSION_MINOR 0
44 #define LIBNFO_VERSION_MICRO 1
45 
46 #define LIBNFO_VERSION_INT NFO_VERSION_INT(LIBNFO_VERSION_MAJOR, \
47  LIBNFO_VERSION_MINOR, \
48  LIBNFO_VERSION_MICRO)
49 #define LIBNFO_VERSION NFO_VERSION(LIBNFO_VERSION_MAJOR, \
50  LIBNFO_VERSION_MINOR, \
51  LIBNFO_VERSION_MICRO)
52 #define LIBNFO_VERSION_STR NFO_TOSTRING(LIBNFO_VERSION)
53 #define LIBNFO_BUILD LIBNFO_VERSION_INT
54 
55 #include <inttypes.h>
56 
57 /* Structure definitions */
58 typedef struct nfo_stream_video_s nfo_stream_video_t;
59 typedef struct nfo_stream_audio_s nfo_stream_audio_t;
60 typedef struct nfo_stream_sub_s nfo_stream_sub_t;
61 typedef struct nfo_fileinfo_s nfo_fileinfo_t;
62 typedef struct nfo_actor_s nfo_actor_t;
63 typedef struct nfo_movie_s nfo_movie_t;
64 typedef struct nfo_tvshow_s nfo_tvshow_t;
65 typedef struct nfo_tvshow_episode_s nfo_tvshow_episode_t;
66 typedef struct nfo_s nfo_t;
67 
68 typedef enum nfo_type_s
69 {
70  NFO_UNKNOWN,
71  NFO_MOVIE,
72  NFO_TVSHOW,
73  NFO_MUSIC,
74 } nfo_type_t;
75 
76 typedef enum nfo_actor_field_s {
77  NFO_ACTOR_NAME,
78  NFO_ACTOR_ROLE,
79  NFO_ACTOR_THUMB,
80 } nfo_actor_field_t;
81 
82 typedef enum nfo_video_field_s {
83  NFO_VIDEO_WIDTH,
84  NFO_VIDEO_HEIGHT,
85  NFO_VIDEO_CODEC,
86  NFO_VIDEO_FORMAT_INFO,
87  NFO_VIDEO_DURATION,
88  NFO_VIDEO_BITRATE,
89  NFO_VIDEO_BITRATE_MODE,
90  NFO_VIDEO_BITRATE_MAX,
91  NFO_VIDEO_CONTAINER,
92  NFO_VIDEO_CODEC_ID,
93  NFO_VIDEO_CODEC_INFO,
94  NFO_VIDEO_SCAN_TYPE,
95  NFO_VIDEO_ASPECT,
96 } nfo_video_field_t;
97 
98 typedef enum nfo_audio_field_s {
99  NFO_AUDIO_LANG,
100  NFO_AUDIO_CODEC,
101  NFO_AUDIO_CHANNELS,
102  NFO_AUDIO_BITRATE,
103 } nfo_audio_field_t;
104 
105 typedef enum nfo_sub_field_s {
106  NFO_SUB_LANG,
107 } nfo_sub_field_t;
108 
109 typedef enum nfo_movie_field_s {
110  NFO_MOVIE_TITLE,
111  NFO_MOVIE_ORIGINAL_TITLE,
112  NFO_MOVIE_RATING,
113  NFO_MOVIE_YEAR,
114  NFO_MOVIE_TOP250,
115  NFO_MOVIE_VOTES,
116  NFO_MOVIE_OUTLINE,
117  NFO_MOVIE_PLOT,
118  NFO_MOVIE_TAGLINE,
119  NFO_MOVIE_RUNTIME,
120  NFO_MOVIE_THUMB,
121  NFO_MOVIE_FAN_ART,
122  NFO_MOVIE_MPAA,
123  NFO_MOVIE_PLAY_COUNT,
124  NFO_MOVIE_WATCHED,
125  NFO_MOVIE_ID,
126  NFO_MOVIE_TRAILER,
127  NFO_MOVIE_GENRE,
128  NFO_MOVIE_CREDITS,
129  NFO_MOVIE_DIRECTOR,
130  NFO_MOVIE_STUDIO,
131 } nfo_movie_field_t;
132 
133 typedef enum nfo_tvshow_field_s {
134  NFO_TVSHOW_TITLE,
135  NFO_TVSHOW_RATING,
136  NFO_TVSHOW_SEASON,
137  NFO_TVSHOW_EPISODE,
138  NFO_TVSHOW_DISPLAY_SEASON,
139  NFO_TVSHOW_DISPLAY_EPISODE,
140  NFO_TVSHOW_EPISODE_GUIDE_URL,
141  NFO_TVSHOW_PLOT,
142  NFO_TVSHOW_MPAA,
143  NFO_TVSHOW_WATCHED,
144  NFO_TVSHOW_GENRE,
145  NFO_TVSHOW_PREMIERED,
146  NFO_TVSHOW_STUDIO,
147  NFO_TVSHOW_FANART,
148  NFO_TVSHOW_FANART_HEADER,
149  NFO_TVSHOW_FANART_COVER,
150 } nfo_tvshow_field_t;
151 
152 typedef enum nfo_tvshow_episode_field_s {
153  NFO_TVSHOW_EPISODE_TITLE,
154  NFO_TVSHOW_EPISODE_RATING,
155  NFO_TVSHOW_EPISODE_SEASON,
156  NFO_TVSHOW_EPISODE_EPISODE,
157  NFO_TVSHOW_EPISODE_PLOT,
158  NFO_TVSHOW_EPISODE_THUMB,
159  NFO_TVSHOW_EPISODE_FANART,
160  NFO_TVSHOW_EPISODE_FANART_SEASON,
161  NFO_TVSHOW_EPISODE_PLAY_COUNT,
162  NFO_TVSHOW_EPISODE_CREDITS,
163  NFO_TVSHOW_EPISODE_DIRECTOR,
164  NFO_TVSHOW_EPISODE_AIRED,
165  NFO_TVSHOW_EPISODE_VOTES,
166 } nfo_tvshow_episode_field_t;
167 
168 /* (Un)Init Routines */
169 nfo_t *nfo_init (const char *filename);
170 void nfo_free (nfo_t *nfo);
171 
172 /* NFO Get Methods */
173 nfo_type_t nfo_get_type (nfo_t *nfo);
174 nfo_movie_t *nfo_get_movie (nfo_t *nfo);
175 nfo_tvshow_episode_t *nfo_get_tvshow_episode (nfo_t *nfo);
176 
177 /* Movie Get Methods */
178 char *nfo_movie_get (nfo_movie_t *movie, nfo_movie_field_t f);
179 
180 int nfo_movie_get_actors_count (nfo_movie_t *movie);
181 nfo_actor_t *nfo_movie_get_actor (nfo_movie_t *movie, int id);
182 
183 int nfo_movie_get_video_streams_count (nfo_movie_t *movie);
184 nfo_stream_video_t *nfo_movie_get_video_stream (nfo_movie_t *movie, int id);
185 
186 int nfo_movie_get_audio_streams_count (nfo_movie_t *movie);
187 nfo_stream_audio_t *nfo_movie_get_audio_stream (nfo_movie_t *movie, int id);
188 
189 int nfo_movie_get_sub_streams_count (nfo_movie_t *movie);
190 nfo_stream_sub_t *nfo_movie_get_sub_stream (nfo_movie_t *movie, int id);
191 
192 /* TVShow Get Methods */
193 char *nfo_tvshow_episode_get (nfo_tvshow_episode_t *ep,
194  nfo_tvshow_episode_field_t f);
195 
196 int nfo_tvshow_episode_get_actors_count (nfo_tvshow_episode_t *ep);
197 nfo_actor_t *nfo_tvshow_episode_get_actor (nfo_tvshow_episode_t *ep, int id);
198 
199 int nfo_tvshow_episode_get_video_streams_count (nfo_tvshow_episode_t *ep);
200 nfo_stream_video_t *nfo_tvshow_episode_get_video_stream
201  (nfo_tvshow_episode_t *ep, int id);
202 
203 int nfo_tvshow_episode_get_audio_streams_count (nfo_tvshow_episode_t *ep);
204 nfo_stream_audio_t *nfo_tvshow_episode_get_audio_stream
205  (nfo_tvshow_episode_t *ep, int id);
206 
207 int nfo_tvshow_episode_get_sub_streams_count (nfo_tvshow_episode_t *ep);
208 nfo_stream_sub_t *nfo_tvshow_episode_get_sub_stream
209  (nfo_tvshow_episode_t *ep, int id);
210 
211 nfo_tvshow_t *nfo_tvshow_episode_get_show (nfo_tvshow_episode_t *ep);
212 char *nfo_tvshow_get (nfo_tvshow_t *ep, nfo_tvshow_field_t f);
213 
214 /* Actor Get Methods */
215 char *nfo_actor_get (nfo_actor_t *actor, nfo_actor_field_t f);
216 
217 /* Streams Get Methods */
218 char *nfo_video_stream_get (nfo_stream_video_t *video, nfo_video_field_t f);
219 char *nfo_audio_stream_get (nfo_stream_audio_t *audio, nfo_audio_field_t f);
220 char *nfo_sub_stream_get (nfo_stream_sub_t *sub, nfo_sub_field_t f);
221 
222 #ifdef __cplusplus
223 }
224 #endif /* __cplusplus */
225 
226 #endif /* NFO_H */