3 * Copyright (C) 2005-2013 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program 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 General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
21 #include "dbwrappers/Database.h"
22 #include "VideoInfoTag.h"
23 #include "addons/Scraper.h"
25 #include "utils/SortUtils.h"
26 #include "video/VideoDbUrl.h"
34 class CGUIDialogProgress;
35 class CGUIDialogProgressBarHandle;
40 typedef std::vector<field_value> sql_record;
45 #define my_offsetof(TYPE, MEMBER) offsetof(TYPE, MEMBER)
48 Custom version of standard offsetof() macro which can be used to get
49 offsets of members in class for non-POD types (according to the current
50 version of C++ standard offsetof() macro can't be used in such cases and
51 attempt to do so causes warnings to be emitted, OTOH in many cases it is
52 still OK to assume that all instances of the class has the same offsets
53 for the same members).
55 #define my_offsetof(TYPE, MEMBER) \
56 ((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
60 typedef std::vector<CVideoInfoTag> VECMOVIES;
64 class IVideoInfoScannerObserver;
68 // these defines are based on how many columns we have and which column certain data is going to be in
69 // when we do GetDetailsForMovie()
70 #define VIDEODB_MAX_COLUMNS 24
71 #define VIDEODB_DETAILS_FILEID 1
73 #define VIDEODB_DETAILS_MOVIE_SET_ID VIDEODB_MAX_COLUMNS + 2
74 #define VIDEODB_DETAILS_MOVIE_SET_NAME VIDEODB_MAX_COLUMNS + 3
75 #define VIDEODB_DETAILS_MOVIE_FILE VIDEODB_MAX_COLUMNS + 4
76 #define VIDEODB_DETAILS_MOVIE_PATH VIDEODB_MAX_COLUMNS + 5
77 #define VIDEODB_DETAILS_MOVIE_PLAYCOUNT VIDEODB_MAX_COLUMNS + 6
78 #define VIDEODB_DETAILS_MOVIE_LASTPLAYED VIDEODB_MAX_COLUMNS + 7
79 #define VIDEODB_DETAILS_MOVIE_DATEADDED VIDEODB_MAX_COLUMNS + 8
80 #define VIDEODB_DETAILS_MOVIE_RESUME_TIME VIDEODB_MAX_COLUMNS + 9
81 #define VIDEODB_DETAILS_MOVIE_TOTAL_TIME VIDEODB_MAX_COLUMNS + 10
83 #define VIDEODB_DETAILS_EPISODE_TVSHOW_ID VIDEODB_MAX_COLUMNS + 2
84 #define VIDEODB_DETAILS_EPISODE_FILE VIDEODB_MAX_COLUMNS + 3
85 #define VIDEODB_DETAILS_EPISODE_PATH VIDEODB_MAX_COLUMNS + 4
86 #define VIDEODB_DETAILS_EPISODE_PLAYCOUNT VIDEODB_MAX_COLUMNS + 5
87 #define VIDEODB_DETAILS_EPISODE_LASTPLAYED VIDEODB_MAX_COLUMNS + 6
88 #define VIDEODB_DETAILS_EPISODE_DATEADDED VIDEODB_MAX_COLUMNS + 7
89 #define VIDEODB_DETAILS_EPISODE_TVSHOW_NAME VIDEODB_MAX_COLUMNS + 8
90 #define VIDEODB_DETAILS_EPISODE_TVSHOW_STUDIO VIDEODB_MAX_COLUMNS + 9
91 #define VIDEODB_DETAILS_EPISODE_TVSHOW_AIRED VIDEODB_MAX_COLUMNS + 10
92 #define VIDEODB_DETAILS_EPISODE_TVSHOW_MPAA VIDEODB_MAX_COLUMNS + 11
93 #define VIDEODB_DETAILS_EPISODE_TVSHOW_PATH VIDEODB_MAX_COLUMNS + 12
94 #define VIDEODB_DETAILS_EPISODE_RESUME_TIME VIDEODB_MAX_COLUMNS + 13
95 #define VIDEODB_DETAILS_EPISODE_TOTAL_TIME VIDEODB_MAX_COLUMNS + 14
96 #define VIDEODB_DETAILS_EPISODE_SEASON_ID VIDEODB_MAX_COLUMNS + 15
98 #define VIDEODB_DETAILS_TVSHOW_PATH VIDEODB_MAX_COLUMNS + 1
99 #define VIDEODB_DETAILS_TVSHOW_DATEADDED VIDEODB_MAX_COLUMNS + 2
100 #define VIDEODB_DETAILS_TVSHOW_LASTPLAYED VIDEODB_MAX_COLUMNS + 3
101 #define VIDEODB_DETAILS_TVSHOW_NUM_EPISODES VIDEODB_MAX_COLUMNS + 4
102 #define VIDEODB_DETAILS_TVSHOW_NUM_WATCHED VIDEODB_MAX_COLUMNS + 5
103 #define VIDEODB_DETAILS_TVSHOW_NUM_SEASONS VIDEODB_MAX_COLUMNS + 6
105 #define VIDEODB_DETAILS_MUSICVIDEO_FILE VIDEODB_MAX_COLUMNS + 2
106 #define VIDEODB_DETAILS_MUSICVIDEO_PATH VIDEODB_MAX_COLUMNS + 3
107 #define VIDEODB_DETAILS_MUSICVIDEO_PLAYCOUNT VIDEODB_MAX_COLUMNS + 4
108 #define VIDEODB_DETAILS_MUSICVIDEO_LASTPLAYED VIDEODB_MAX_COLUMNS + 5
109 #define VIDEODB_DETAILS_MUSICVIDEO_DATEADDED VIDEODB_MAX_COLUMNS + 6
110 #define VIDEODB_DETAILS_MUSICVIDEO_RESUME_TIME VIDEODB_MAX_COLUMNS + 7
111 #define VIDEODB_DETAILS_MUSICVIDEO_TOTAL_TIME VIDEODB_MAX_COLUMNS + 8
113 #define VIDEODB_TYPE_STRING 1
114 #define VIDEODB_TYPE_INT 2
115 #define VIDEODB_TYPE_FLOAT 3
116 #define VIDEODB_TYPE_BOOL 4
117 #define VIDEODB_TYPE_COUNT 5
118 #define VIDEODB_TYPE_STRINGARRAY 6
119 #define VIDEODB_TYPE_DATE 7
120 #define VIDEODB_TYPE_DATETIME 8
124 VIDEODB_CONTENT_MOVIES = 1,
125 VIDEODB_CONTENT_TVSHOWS = 2,
126 VIDEODB_CONTENT_MUSICVIDEOS = 3,
127 VIDEODB_CONTENT_EPISODES = 4,
128 VIDEODB_CONTENT_MOVIE_SETS = 5
129 } VIDEODB_CONTENT_TYPE;
131 typedef enum // this enum MUST match the offset struct further down!! and make sure to keep min and max at -1 and sizeof(offsets)
134 VIDEODB_ID_TITLE = 0,
136 VIDEODB_ID_PLOTOUTLINE = 2,
137 VIDEODB_ID_TAGLINE = 3,
138 VIDEODB_ID_VOTES = 4,
139 VIDEODB_ID_RATING = 5,
140 VIDEODB_ID_CREDITS = 6,
142 VIDEODB_ID_THUMBURL = 8,
143 VIDEODB_ID_IDENT = 9,
144 VIDEODB_ID_SORTTITLE = 10,
145 VIDEODB_ID_RUNTIME = 11,
146 VIDEODB_ID_MPAA = 12,
147 VIDEODB_ID_TOP250 = 13,
148 VIDEODB_ID_GENRE = 14,
149 VIDEODB_ID_DIRECTOR = 15,
150 VIDEODB_ID_ORIGINALTITLE = 16,
151 VIDEODB_ID_THUMBURL_SPOOF = 17,
152 VIDEODB_ID_STUDIOS = 18,
153 VIDEODB_ID_TRAILER = 19,
154 VIDEODB_ID_FANART = 20,
155 VIDEODB_ID_COUNTRY = 21,
156 VIDEODB_ID_BASEPATH = 22,
157 VIDEODB_ID_PARENTPATHID = 23,
161 const struct SDbTableOffsets
167 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strTitle) },
168 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPlot) },
169 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPlotOutline) },
170 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strTagLine) },
171 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strVotes) },
172 { VIDEODB_TYPE_FLOAT, my_offsetof(CVideoInfoTag,m_fRating) },
173 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_writingCredits) },
174 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iYear) },
175 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_xml) },
176 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strIMDBNumber) },
177 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strSortTitle) },
178 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_duration) },
179 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strMPAARating) },
180 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iTop250) },
181 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_genre) },
182 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_director) },
183 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strOriginalTitle) },
184 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_spoof) },
185 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_studio) },
186 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strTrailer) },
187 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_fanart.m_xml) },
188 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_country) },
189 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_basePath) },
190 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_parentPathID) }
193 typedef enum // this enum MUST match the offset struct further down!! and make sure to keep min and max at -1 and sizeof(offsets)
195 VIDEODB_ID_TV_MIN = -1,
196 VIDEODB_ID_TV_TITLE = 0,
197 VIDEODB_ID_TV_PLOT = 1,
198 VIDEODB_ID_TV_STATUS = 2,
199 VIDEODB_ID_TV_VOTES = 3,
200 VIDEODB_ID_TV_RATING = 4,
201 VIDEODB_ID_TV_PREMIERED = 5,
202 VIDEODB_ID_TV_THUMBURL = 6,
203 VIDEODB_ID_TV_THUMBURL_SPOOF = 7,
204 VIDEODB_ID_TV_GENRE = 8,
205 VIDEODB_ID_TV_ORIGINALTITLE = 9,
206 VIDEODB_ID_TV_EPISODEGUIDE = 10,
207 VIDEODB_ID_TV_FANART = 11,
208 VIDEODB_ID_TV_IDENT = 12,
209 VIDEODB_ID_TV_MPAA = 13,
210 VIDEODB_ID_TV_STUDIOS = 14,
211 VIDEODB_ID_TV_SORTTITLE = 15,
212 VIDEODB_ID_TV_BASEPATH = 16,
213 VIDEODB_ID_TV_PARENTPATHID = 17,
217 const struct SDbTableOffsets DbTvShowOffsets[] =
219 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strTitle) },
220 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPlot) },
221 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strStatus) },
222 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strVotes) },
223 { VIDEODB_TYPE_FLOAT, my_offsetof(CVideoInfoTag,m_fRating) },
224 { VIDEODB_TYPE_DATE, my_offsetof(CVideoInfoTag,m_premiered) },
225 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_xml) },
226 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_spoof) },
227 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_genre) },
228 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strOriginalTitle)},
229 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strEpisodeGuide)},
230 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_fanart.m_xml)},
231 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strIMDBNumber)},
232 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strMPAARating)},
233 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_studio)},
234 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strSortTitle)},
235 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_basePath) },
236 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_parentPathID) }
239 typedef enum // this enum MUST match the offset struct further down!! and make sure to keep min and max at -1 and sizeof(offsets)
241 VIDEODB_ID_EPISODE_MIN = -1,
242 VIDEODB_ID_EPISODE_TITLE = 0,
243 VIDEODB_ID_EPISODE_PLOT = 1,
244 VIDEODB_ID_EPISODE_VOTES = 2,
245 VIDEODB_ID_EPISODE_RATING = 3,
246 VIDEODB_ID_EPISODE_CREDITS = 4,
247 VIDEODB_ID_EPISODE_AIRED = 5,
248 VIDEODB_ID_EPISODE_THUMBURL = 6,
249 VIDEODB_ID_EPISODE_THUMBURL_SPOOF = 7,
250 VIDEODB_ID_EPISODE_PLAYCOUNT = 8, // unused - feel free to repurpose
251 VIDEODB_ID_EPISODE_RUNTIME = 9,
252 VIDEODB_ID_EPISODE_DIRECTOR = 10,
253 VIDEODB_ID_EPISODE_IDENT = 11,
254 VIDEODB_ID_EPISODE_SEASON = 12,
255 VIDEODB_ID_EPISODE_EPISODE = 13,
256 VIDEODB_ID_EPISODE_ORIGINALTITLE = 14,
257 VIDEODB_ID_EPISODE_SORTSEASON = 15,
258 VIDEODB_ID_EPISODE_SORTEPISODE = 16,
259 VIDEODB_ID_EPISODE_BOOKMARK = 17,
260 VIDEODB_ID_EPISODE_BASEPATH = 18,
261 VIDEODB_ID_EPISODE_PARENTPATHID = 19,
262 VIDEODB_ID_EPISODE_UNIQUEID = 20,
263 VIDEODB_ID_EPISODE_MAX
264 } VIDEODB_EPISODE_IDS;
266 const struct SDbTableOffsets DbEpisodeOffsets[] =
268 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strTitle) },
269 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPlot) },
270 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strVotes) },
271 { VIDEODB_TYPE_FLOAT, my_offsetof(CVideoInfoTag,m_fRating) },
272 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_writingCredits) },
273 { VIDEODB_TYPE_DATE, my_offsetof(CVideoInfoTag,m_firstAired) },
274 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_xml) },
275 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_spoof) },
276 { VIDEODB_TYPE_COUNT, my_offsetof(CVideoInfoTag,m_playCount) }, // unused
277 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_duration) },
278 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_director) },
279 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strProductionCode) },
280 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iSeason) },
281 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iEpisode) },
282 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strOriginalTitle)},
283 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iSpecialSortSeason) },
284 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iSpecialSortEpisode) },
285 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iBookmarkId) },
286 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_basePath) },
287 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_parentPathID) },
288 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strUniqueId) }
291 typedef enum // this enum MUST match the offset struct further down!! and make sure to keep min and max at -1 and sizeof(offsets)
293 VIDEODB_ID_MUSICVIDEO_MIN = -1,
294 VIDEODB_ID_MUSICVIDEO_TITLE = 0,
295 VIDEODB_ID_MUSICVIDEO_THUMBURL = 1,
296 VIDEODB_ID_MUSICVIDEO_THUMBURL_SPOOF = 2,
297 VIDEODB_ID_MUSICVIDEO_PLAYCOUNT = 3, // unused - feel free to repurpose
298 VIDEODB_ID_MUSICVIDEO_RUNTIME = 4,
299 VIDEODB_ID_MUSICVIDEO_DIRECTOR = 5,
300 VIDEODB_ID_MUSICVIDEO_STUDIOS = 6,
301 VIDEODB_ID_MUSICVIDEO_YEAR = 7,
302 VIDEODB_ID_MUSICVIDEO_PLOT = 8,
303 VIDEODB_ID_MUSICVIDEO_ALBUM = 9,
304 VIDEODB_ID_MUSICVIDEO_ARTIST = 10,
305 VIDEODB_ID_MUSICVIDEO_GENRE = 11,
306 VIDEODB_ID_MUSICVIDEO_TRACK = 12,
307 VIDEODB_ID_MUSICVIDEO_BASEPATH = 13,
308 VIDEODB_ID_MUSICVIDEO_PARENTPATHID = 14,
309 VIDEODB_ID_MUSICVIDEO_MAX
310 } VIDEODB_MUSICVIDEO_IDS;
312 const struct SDbTableOffsets DbMusicVideoOffsets[] =
314 { VIDEODB_TYPE_STRING, my_offsetof(class CVideoInfoTag,m_strTitle) },
315 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_xml) },
316 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_spoof) },
317 { VIDEODB_TYPE_COUNT, my_offsetof(CVideoInfoTag,m_playCount) }, // unused
318 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_duration) },
319 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_director) },
320 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_studio) },
321 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iYear) },
322 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPlot) },
323 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strAlbum) },
324 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_artist) },
325 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_genre) },
326 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iTrack) },
327 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_basePath) },
328 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_parentPathID) }
331 #define COMPARE_PERCENTAGE 0.90f // 90%
332 #define COMPARE_PERCENTAGE_MIN 0.50f // 50%
334 class CVideoDatabase : public CDatabase
338 class CActor // used for actor retrieval for non-master users
346 class CSeason // used for season retrieval for non-master users
350 std::vector<std::string> genre;
361 DatabaseResults results;
364 CVideoDatabase(void);
365 virtual ~CVideoDatabase(void);
368 virtual bool CommitTransaction();
370 int AddMovie(const CStdString& strFilenameAndPath);
371 int AddEpisode(int idShow, const CStdString& strFilenameAndPath);
374 /*! \brief Set the playcount of an item
375 Sets the playcount and last played date to a given value
376 \param item CFileItem to set the playcount for
377 \param count The playcount to set.
378 \param date The date the file was last viewed (does not denote the video was watched to completion). If empty we current datetime (if count > 0) or never viewed (if count = 0).
379 \sa GetPlayCount, IncrementPlayCount, UpdateLastPlayed
381 void SetPlayCount(const CFileItem &item, int count, const CDateTime &date = CDateTime());
383 /*! \brief Increment the playcount of an item
384 Increments the playcount and updates the last played date
385 \param item CFileItem to increment the playcount for
386 \sa GetPlayCount, SetPlayCount, GetPlayCounts
388 void IncrementPlayCount(const CFileItem &item);
390 /*! \brief Get the playcount of an item
391 \param item CFileItem to get the playcount for
392 \return the playcount of the item, or -1 on error
393 \sa SetPlayCount, IncrementPlayCount, GetPlayCounts
395 int GetPlayCount(const CFileItem &item);
397 /*! \brief Update the last played time of an item
398 Updates the last played date
399 \param item CFileItem to update the last played time for
400 \sa GetPlayCount, SetPlayCount, IncrementPlayCount, GetPlayCounts
402 void UpdateLastPlayed(const CFileItem &item);
404 /*! \brief Get the playcount and resume point of a list of items
405 Note that if the resume point is already set on an item, it won't be overridden.
406 \param path the path to fetch videos from
407 \param items CFileItemList to fetch the playcounts for
408 \sa GetPlayCount, SetPlayCount, IncrementPlayCount
410 bool GetPlayCounts(const CStdString &path, CFileItemList &items);
412 void UpdateMovieTitle(int idMovie, const CStdString& strNewMovieTitle, VIDEODB_CONTENT_TYPE iType=VIDEODB_CONTENT_MOVIES);
413 bool UpdateVideoSortTitle(int idDb, const CStdString& strNewSortTitle, VIDEODB_CONTENT_TYPE iType = VIDEODB_CONTENT_MOVIES);
415 bool HasMovieInfo(const CStdString& strFilenameAndPath);
416 bool HasTvShowInfo(const CStdString& strFilenameAndPath);
417 bool HasEpisodeInfo(const CStdString& strFilenameAndPath);
418 bool HasMusicVideoInfo(const CStdString& strFilenameAndPath);
420 void GetFilePathById(int idMovie, CStdString &filePath, VIDEODB_CONTENT_TYPE iType);
421 CStdString GetGenreById(int id);
422 CStdString GetCountryById(int id);
423 CStdString GetSetById(int id);
424 CStdString GetTagById(int id);
425 CStdString GetPersonById(int id);
426 CStdString GetStudioById(int id);
427 CStdString GetTvShowTitleById(int id);
428 CStdString GetMusicVideoAlbumById(int id);
429 int GetTvShowForEpisode(int idEpisode);
430 int GetSeasonForEpisode(int idEpisode);
432 bool LoadVideoInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details);
433 bool GetMovieInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details, int idMovie = -1);
434 bool GetTvShowInfo(const CStdString& strPath, CVideoInfoTag& details, int idTvShow = -1);
435 bool GetSeasonInfo(int idSeason, CVideoInfoTag& details);
436 bool GetEpisodeInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details, int idEpisode = -1);
437 bool GetMusicVideoInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details, int idMVideo=-1);
438 bool GetSetInfo(int idSet, CVideoInfoTag& details);
439 bool GetFileInfo(const CStdString& strFilenameAndPath, CVideoInfoTag& details, int idFile = -1);
441 int GetPathId(const CStdString& strPath);
442 int GetTvShowId(const CStdString& strPath);
443 int GetEpisodeId(const CStdString& strFilenameAndPath, int idEpisode=-1, int idSeason=-1); // idEpisode, idSeason are used for multipart episodes as hints
444 int GetSeasonId(int idShow, int season);
446 void GetEpisodesByFile(const CStdString& strFilenameAndPath, std::vector<CVideoInfoTag>& episodes);
448 int SetDetailsForMovie(const CStdString& strFilenameAndPath, const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idMovie = -1);
449 int SetDetailsForMovieSet(const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idSet = -1);
450 int SetDetailsForTvShow(const CStdString& strPath, const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, const std::map<int, std::map<std::string, std::string> > &seasonArt, int idTvShow = -1);
451 int SetDetailsForSeason(const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idShow, int idSeason = -1);
452 int SetDetailsForEpisode(const CStdString& strFilenameAndPath, const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idShow, int idEpisode=-1);
453 int SetDetailsForMusicVideo(const CStdString& strFilenameAndPath, const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idMVideo = -1);
454 void SetStreamDetailsForFile(const CStreamDetails& details, const CStdString &strFileNameAndPath);
455 void SetStreamDetailsForFileId(const CStreamDetails& details, int idFile);
457 bool SetSingleValue(VIDEODB_CONTENT_TYPE type, int dbId, int dbField, const std::string &strValue);
458 bool SetSingleValue(VIDEODB_CONTENT_TYPE type, int dbId, Field dbField, const std::string &strValue);
459 bool SetSingleValue(const std::string &table, const std::string &fieldName, const std::string &strValue,
460 const std::string &conditionName = "", int conditionValue = -1);
462 void DeleteMovie(int idMovie, bool bKeepId = false);
463 void DeleteMovie(const CStdString& strFilenameAndPath, bool bKeepId = false, int idMovie = -1);
464 void DeleteTvShow(int idTvShow, bool bKeepId = false);
465 void DeleteTvShow(const CStdString& strPath, bool bKeepId = false, int idTvShow = -1);
466 void DeleteEpisode(int idEpisode, bool bKeepId = false);
467 void DeleteEpisode(const CStdString& strFilenameAndPath, int idEpisode = -1, bool bKeepId = false);
468 void DeleteMusicVideo(int idMusicVideo, bool bKeepId = false);
469 void DeleteMusicVideo(const CStdString& strFilenameAndPath, bool bKeepId = false, int idMVideo = -1);
470 void DeleteDetailsForTvShow(const CStdString& strPath, int idTvShow = -1);
471 void RemoveContentForPath(const CStdString& strPath,CGUIDialogProgress *progress = NULL);
472 void UpdateFanart(const CFileItem &item, VIDEODB_CONTENT_TYPE type);
473 void DeleteSet(int idSet);
474 void DeleteTag(int idTag, VIDEODB_CONTENT_TYPE mediaType);
476 // per-file video settings
477 bool GetVideoSettings(const CStdString &strFilenameAndPath, CVideoSettings &settings);
478 void SetVideoSettings(const CStdString &strFilenameAndPath, const CVideoSettings &settings);
479 void EraseVideoSettings();
481 bool GetStackTimes(const CStdString &filePath, std::vector<int> ×);
482 void SetStackTimes(const CStdString &filePath, std::vector<int> ×);
484 void GetBookMarksForFile(const CStdString& strFilenameAndPath, VECBOOKMARKS& bookmarks, CBookmark::EType type = CBookmark::STANDARD, bool bAppend=false, long partNumber=0);
485 void AddBookMarkToFile(const CStdString& strFilenameAndPath, const CBookmark &bookmark, CBookmark::EType type = CBookmark::STANDARD);
486 bool GetResumeBookMark(const CStdString& strFilenameAndPath, CBookmark &bookmark);
487 void DeleteResumeBookMark(const CStdString &strFilenameAndPath);
488 void ClearBookMarkOfFile(const CStdString& strFilenameAndPath, CBookmark& bookmark, CBookmark::EType type = CBookmark::STANDARD);
489 void ClearBookMarksOfFile(const CStdString& strFilenameAndPath, CBookmark::EType type = CBookmark::STANDARD);
490 bool GetBookMarkForEpisode(const CVideoInfoTag& tag, CBookmark& bookmark);
491 void AddBookMarkForEpisode(const CVideoInfoTag& tag, const CBookmark& bookmark);
492 void DeleteBookMarkForEpisode(const CVideoInfoTag& tag);
493 bool GetResumePoint(CVideoInfoTag& tag);
494 bool GetStreamDetails(CFileItem& item);
495 bool GetStreamDetails(CVideoInfoTag& tag) const;
498 void SetScraperForPath(const CStdString& filePath, const ADDON::ScraperPtr& info, const VIDEO::SScanSettings& settings);
499 ADDON::ScraperPtr GetScraperForPath(const CStdString& strPath);
500 ADDON::ScraperPtr GetScraperForPath(const CStdString& strPath, VIDEO::SScanSettings& settings);
502 /*! \brief Retrieve the scraper and settings we should use for the specified path
503 If the scraper is not set on this particular path, we'll recursively check parent folders.
504 \param strPath path to start searching in.
505 \param settings [out] scan settings for this folder.
506 \param foundDirectly [out] true if a scraper was found directly for strPath, false if it was in a parent path.
507 \return A ScraperPtr containing the scraper information. Returns NULL if a trivial (Content == CONTENT_NONE)
508 scraper or no scraper is found.
510 ADDON::ScraperPtr GetScraperForPath(const CStdString& strPath, VIDEO::SScanSettings& settings, bool& foundDirectly);
512 /*! \brief Retrieve the content type of videos in the given path
513 If content is set on the folder, we return the given content type, except in the case of tvshows,
514 where we first check for whether we have episodes directly in the path (thus return episodes) or whether
515 we've found a scraper directly (shows). Any folders inbetween are treated as seasons (regardless of whether
516 they actually are seasons). Note that any subfolders in movies will be treated as movies.
517 \param strPath path to start searching in.
518 \return A content type string for the current path.
520 CStdString GetContentForPath(const CStdString& strPath);
522 /*! \brief Get videos of the given content type from the given path
523 \param content the content type to fetch.
524 \param path the path to fetch videos from.
525 \param items the returned items
526 \return true if items are found, false otherwise.
528 bool GetItemsForPath(const CStdString &content, const CStdString &path, CFileItemList &items);
530 /*! \brief Check whether a given scraper is in use.
531 \param scraperID the scraper to check for.
532 \return true if the scraper is in use, false otherwise.
534 bool ScraperInUse(const CStdString &scraperID) const;
536 // scanning hashes and paths scanned
537 bool SetPathHash(const CStdString &path, const CStdString &hash);
538 bool GetPathHash(const CStdString &path, CStdString &hash);
539 bool GetPaths(std::set<CStdString> &paths);
540 bool GetPathsForTvShow(int idShow, std::set<int>& paths);
542 /*! \brief retrieve subpaths of a given path. Assumes a heirarchical folder structure
543 \param basepath the root path to retrieve subpaths for
544 \param subpaths the returned subpaths
545 \return true if we successfully retrieve subpaths (may be zero), false on error
547 bool GetSubPaths(const CStdString& basepath, std::vector< std::pair<int, std::string> >& subpaths);
549 // for music + musicvideo linkups - if no album and title given it will return the artist id, else the id of the matching video
550 int GetMatchingMusicVideo(const CStdString& strArtist, const CStdString& strAlbum = "", const CStdString& strTitle = "");
552 // searching functions
553 void GetMoviesByActor(const CStdString& strActor, CFileItemList& items);
554 void GetTvShowsByActor(const CStdString& strActor, CFileItemList& items);
555 void GetEpisodesByActor(const CStdString& strActor, CFileItemList& items);
557 void GetMusicVideosByArtist(const CStdString& strArtist, CFileItemList& items);
558 void GetMusicVideosByAlbum(const CStdString& strAlbum, CFileItemList& items);
560 void GetMovieGenresByName(const CStdString& strSearch, CFileItemList& items);
561 void GetTvShowGenresByName(const CStdString& strSearch, CFileItemList& items);
562 void GetMusicVideoGenresByName(const CStdString& strSearch, CFileItemList& items);
564 void GetMovieCountriesByName(const CStdString& strSearch, CFileItemList& items);
566 void GetMusicVideoAlbumsByName(const CStdString& strSearch, CFileItemList& items);
568 void GetMovieActorsByName(const CStdString& strSearch, CFileItemList& items);
569 void GetTvShowsActorsByName(const CStdString& strSearch, CFileItemList& items);
570 void GetMusicVideoArtistsByName(const CStdString& strSearch, CFileItemList& items);
572 void GetMovieDirectorsByName(const CStdString& strSearch, CFileItemList& items);
573 void GetTvShowsDirectorsByName(const CStdString& strSearch, CFileItemList& items);
574 void GetMusicVideoDirectorsByName(const CStdString& strSearch, CFileItemList& items);
576 void GetMoviesByName(const CStdString& strSearch, CFileItemList& items);
577 void GetTvShowsByName(const CStdString& strSearch, CFileItemList& items);
578 void GetEpisodesByName(const CStdString& strSearch, CFileItemList& items);
579 void GetMusicVideosByName(const CStdString& strSearch, CFileItemList& items);
581 void GetEpisodesByPlot(const CStdString& strSearch, CFileItemList& items);
582 void GetMoviesByPlot(const CStdString& strSearch, CFileItemList& items);
584 bool LinkMovieToTvshow(int idMovie, int idShow, bool bRemove);
585 bool IsLinkedToTvshow(int idMovie);
586 bool GetLinksToTvShow(int idMovie, std::vector<int>& ids);
589 bool GetGenresNav(const CStdString& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false);
590 bool GetCountriesNav(const CStdString& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false);
591 bool GetStudiosNav(const CStdString& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false);
592 bool GetYearsNav(const CStdString& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter());
593 bool GetActorsNav(const CStdString& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false);
594 bool GetDirectorsNav(const CStdString& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false);
595 bool GetWritersNav(const CStdString& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false);
596 bool GetSetsNav(const CStdString& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool ignoreSingleMovieSets = false);
597 bool GetTagsNav(const CStdString& strBaseDir, CFileItemList& items, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false);
598 bool GetMusicVideoAlbumsNav(const CStdString& strBaseDir, CFileItemList& items, int idArtist, const Filter &filter = Filter(), bool countOnly = false);
600 bool GetMoviesNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idActor=-1, int idDirector=-1, int idStudio=-1, int idCountry=-1, int idSet=-1, int idTag=-1, const SortDescription &sortDescription = SortDescription());
601 bool GetTvShowsNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idActor=-1, int idDirector=-1, int idStudio=-1, int idTag=-1, const SortDescription &sortDescription = SortDescription());
602 bool GetSeasonsNav(const CStdString& strBaseDir, CFileItemList& items, int idActor=-1, int idDirector=-1, int idGenre=-1, int idYear=-1, int idShow=-1, bool getLinkedMovies = true);
603 bool GetEpisodesNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idActor=-1, int idDirector=-1, int idShow=-1, int idSeason=-1, const SortDescription &sortDescription = SortDescription());
604 bool GetMusicVideosNav(const CStdString& strBaseDir, CFileItemList& items, int idGenre=-1, int idYear=-1, int idArtist=-1, int idDirector=-1, int idStudio=-1, int idAlbum=-1, int idTag=-1, const SortDescription &sortDescription = SortDescription());
606 bool GetRecentlyAddedMoviesNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit=0);
607 bool GetRecentlyAddedEpisodesNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit=0);
608 bool GetRecentlyAddedMusicVideosNav(const CStdString& strBaseDir, CFileItemList& items, unsigned int limit=0);
611 bool HasContent(VIDEODB_CONTENT_TYPE type);
612 bool HasSets() const;
614 void CleanDatabase(CGUIDialogProgressBarHandle* handle=NULL, const std::set<int>* paths=NULL, bool showProgress=true);
616 /*! \brief Add a file to the database, if necessary
617 If the file is already in the database, we simply return its id.
618 \param url - full path of the file to add.
619 \return id of the file, -1 if it could not be added.
621 int AddFile(const CStdString& url);
623 /*! \brief Add a file to the database, if necessary
624 Works for both videodb:// items and normal fileitems
625 \param item CFileItem to add.
626 \return id of the file, -1 if it could not be added.
628 int AddFile(const CFileItem& item);
630 /*! \brief Add a path to the database, if necessary
631 If the path is already in the database, we simply return its id.
632 \param strPath the path to add
633 \param strDateAdded datetime when the path was added to the filesystem/database
634 \return id of the file, -1 if it could not be added.
636 int AddPath(const CStdString& strPath, const CStdString &strDateAdded = "");
638 /*! \brief Updates the dateAdded field in the files table for the file
639 with the given idFile and the given path based on the files modification date
640 \param idFile id of the file in the files table
641 \param strFileNameAndPath path to the file
643 void UpdateFileDateAdded(int idFile, const CStdString& strFileNameAndPath);
645 void ExportToXML(const CStdString &path, bool singleFiles = false, bool images=false, bool actorThumbs=false, bool overwrite=false);
646 bool ExportSkipEntry(const CStdString &nfoFile);
647 void ExportActorThumbs(const CStdString &path, const CVideoInfoTag& tag, bool singleFiles, bool overwrite=false);
648 void ImportFromXML(const CStdString &path);
649 void DumpToDummyFiles(const CStdString &path);
650 bool ImportArtFromXML(const TiXmlNode *node, std::map<std::string, std::string> &artwork);
652 // smart playlists and main retrieval work in these functions
653 bool GetMoviesByWhere(const CStdString& strBaseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription = SortDescription());
654 bool GetSetsByWhere(const CStdString& strBaseDir, const Filter &filter, CFileItemList& items, bool ignoreSingleMovieSets = false);
655 bool GetTvShowsByWhere(const CStdString& strBaseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription = SortDescription());
656 bool GetEpisodesByWhere(const CStdString& strBaseDir, const Filter &filter, CFileItemList& items, bool appendFullShowPath = true, const SortDescription &sortDescription = SortDescription());
657 bool GetMusicVideosByWhere(const CStdString &baseDir, const Filter &filter, CFileItemList& items, bool checkLocks = true, const SortDescription &sortDescription = SortDescription());
659 // retrieve sorted and limited items
660 bool GetSortedVideos(MediaType mediaType, const CStdString& strBaseDir, const SortDescription &sortDescription, CFileItemList& items, const Filter &filter = Filter());
662 // retrieve a list of items
663 bool GetItems(const CStdString &strBaseDir, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription());
664 bool GetItems(const CStdString &strBaseDir, const CStdString &mediaType, const CStdString &itemType, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription());
665 bool GetItems(const CStdString &strBaseDir, VIDEODB_CONTENT_TYPE mediaType, const CStdString &itemType, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription());
666 CStdString GetItemById(const CStdString &itemType, int id);
669 int GetMusicVideoCount(const CStdString& strWhere);
670 unsigned int GetMusicVideoIDs(const CStdString& strWhere, std::vector<std::pair<int,int> > &songIDs);
671 bool GetRandomMusicVideo(CFileItem* item, int& idSong, const CStdString& strWhere);
673 static void VideoContentTypeToString(VIDEODB_CONTENT_TYPE type, CStdString& out)
677 case VIDEODB_CONTENT_MOVIES:
680 case VIDEODB_CONTENT_TVSHOWS:
683 case VIDEODB_CONTENT_EPISODES:
686 case VIDEODB_CONTENT_MUSICVIDEOS:
694 void SetArtForItem(int mediaId, const std::string &mediaType, const std::string &artType, const std::string &url);
695 void SetArtForItem(int mediaId, const std::string &mediaType, const std::map<std::string, std::string> &art);
696 bool GetArtForItem(int mediaId, const std::string &mediaType, std::map<std::string, std::string> &art);
697 std::string GetArtForItem(int mediaId, const std::string &mediaType, const std::string &artType);
698 bool RemoveArtForItem(int mediaId, const std::string &mediaType, const std::string &artType);
699 bool RemoveArtForItem(int mediaId, const std::string &mediaType, const std::set<std::string> &artTypes);
700 bool GetTvShowSeasonArt(int mediaId, std::map<int, std::map<std::string, std::string> > &seasonArt);
701 bool GetArtTypes(const std::string &mediaType, std::vector<std::string> &artTypes);
703 int AddTag(const std::string &tag);
704 void AddTagToItem(int idItem, int idTag, const std::string &type);
705 void RemoveTagFromItem(int idItem, int idTag, const std::string &type);
706 void RemoveTagsFromItem(int idItem, const std::string &type);
708 virtual bool GetFilter(CDbUrl &videoUrl, Filter &filter, SortDescription &sorting);
710 int AddSet(const CStdString& strSet);
711 void ClearMovieSet(int idMovie);
712 void SetMovieSet(int idMovie, int idSet);
715 friend class CEdenVideoArtUpdater;
716 int GetMovieId(const CStdString& strFilenameAndPath);
717 int GetMusicVideoId(const CStdString& strFilenameAndPath);
719 /*! \brief Get the id of this fileitem
720 Works for both videodb:// items and normal fileitems
721 \param item CFileItem to grab the fileid of
722 \return id of the file, -1 if it is not in the db.
724 int GetFileId(const CFileItem &item);
726 /*! \brief Get the id of a file from path
727 \param url full path to the file
728 \return id of the file, -1 if it is not in the db.
730 int GetFileId(const CStdString& url);
732 int AddToTable(const CStdString& table, const CStdString& firstField, const CStdString& secondField, const CStdString& value);
733 int AddGenre(const CStdString& strGenre1);
734 int AddActor(const CStdString& strActor, const CStdString& thumbURL, const CStdString &thumb = "");
735 int AddCountry(const CStdString& strCountry);
736 int AddStudio(const CStdString& strStudio1);
738 int AddTvShow(const CStdString& strPath);
739 int AddMusicVideo(const CStdString& strFilenameAndPath);
740 int AddSeason(int showID, int season);
742 // link functions - these two do all the work
743 void AddLinkToActor(const char *table, int actorID, const char *secondField, int secondID, const CStdString &role, int order);
744 void AddToLinkTable(const char *table, const char *firstField, int firstID, const char *secondField, int secondID, const char *typeField = NULL, const char *type = NULL);
745 void RemoveFromLinkTable(const char *table, const char *firstField, int firstID, const char *secondField, int secondID, const char *typeField = NULL, const char *type = NULL);
747 void AddCast(int idMedia, const char *table, const char *field, const std::vector<SActorInfo> &cast);
748 void AddArtistToMusicVideo(int lMVideo, int idArtist);
750 void AddDirectorToMovie(int idMovie, int idDirector);
751 void AddDirectorToTvShow(int idTvShow, int idDirector);
752 void AddDirectorToEpisode(int idEpisode, int idDirector);
753 void AddDirectorToMusicVideo(int lMVideo, int idDirector);
754 void AddWriterToEpisode(int idEpisode, int idWriter);
755 void AddWriterToMovie(int idMovie, int idWriter);
757 void AddGenreToMovie(int idMovie, int idGenre);
758 void AddGenreToTvShow(int idTvShow, int idGenre);
759 void AddGenreToMusicVideo(int idMVideo, int idGenre);
761 void AddStudioToMovie(int idMovie, int idStudio);
762 void AddStudioToTvShow(int idTvShow, int idStudio);
763 void AddStudioToMusicVideo(int idMVideo, int idStudio);
765 void AddCountryToMovie(int idMovie, int idCountry);
767 void AddGenreAndDirectorsAndStudios(const CVideoInfoTag& details, std::vector<int>& vecDirectors, std::vector<int>& vecGenres, std::vector<int>& vecStudios);
769 void DeleteStreamDetails(int idFile);
770 CVideoInfoTag GetDetailsByTypeAndId(VIDEODB_CONTENT_TYPE type, int id);
771 CVideoInfoTag GetDetailsForMovie(std::auto_ptr<dbiplus::Dataset> &pDS, bool getDetails = false);
772 CVideoInfoTag GetDetailsForMovie(const dbiplus::sql_record* const record, bool getDetails = false);
773 CVideoInfoTag GetDetailsForTvShow(std::auto_ptr<dbiplus::Dataset> &pDS, bool getDetails = false, CFileItem* item = NULL);
774 CVideoInfoTag GetDetailsForTvShow(const dbiplus::sql_record* const record, bool getDetails = false, CFileItem* item = NULL);
775 CVideoInfoTag GetDetailsForEpisode(std::auto_ptr<dbiplus::Dataset> &pDS, bool getDetails = false);
776 CVideoInfoTag GetDetailsForEpisode(const dbiplus::sql_record* const record, bool getDetails = false);
777 CVideoInfoTag GetDetailsForMusicVideo(std::auto_ptr<dbiplus::Dataset> &pDS, bool getDetails = false);
778 CVideoInfoTag GetDetailsForMusicVideo(const dbiplus::sql_record* const record, bool getDetails = false);
779 bool GetPeopleNav(const CStdString& strBaseDir, CFileItemList& items, const CStdString& type, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false);
780 bool GetNavCommon(const CStdString& strBaseDir, CFileItemList& items, const CStdString& type, int idContent=-1, const Filter &filter = Filter(), bool countOnly = false);
781 void GetCast(const CStdString &table, const CStdString &table_id, int type_id, std::vector<SActorInfo> &cast);
783 void GetDetailsFromDB(std::auto_ptr<dbiplus::Dataset> &pDS, int min, int max, const SDbTableOffsets *offsets, CVideoInfoTag &details, int idxOffset = 2);
784 void GetDetailsFromDB(const dbiplus::sql_record* const record, int min, int max, const SDbTableOffsets *offsets, CVideoInfoTag &details, int idxOffset = 2);
785 CStdString GetValueString(const CVideoInfoTag &details, int min, int max, const SDbTableOffsets *offsets) const;
788 virtual void CreateTables();
789 virtual void CreateAnalytics();
790 virtual void UpdateTables(int version);
792 /*! \brief (Re)Create the generic database views for movies, tvshows,
793 episodes and music videos
795 virtual void CreateViews();
797 /*! \brief Run a query on the main dataset and return the number of rows
798 If no rows are found we close the dataset and return 0.
799 \param sql the sql query to run
800 \return the number of rows, -1 for an error.
802 int RunQuery(const CStdString &sql);
804 /*! \brief Determine whether the path is using lookup using folders
805 \param path the path to check
806 \param shows whether this path is from a tvshow (defaults to false)
808 bool LookupByFolders(const CStdString &path, bool shows = false);
810 virtual int GetMinSchemaVersion() const { return 60; };
811 virtual int GetSchemaVersion() const;
812 virtual int GetExportVersion() const { return 1; };
813 const char *GetBaseDBName() const { return "MyVideos"; };
815 void ConstructPath(CStdString& strDest, const CStdString& strPath, const CStdString& strFileName);
816 void SplitPath(const CStdString& strFileNameAndPath, CStdString& strPath, CStdString& strFileName);
817 void InvalidatePathHash(const CStdString& strPath);
819 bool GetStackedTvShowList(int idShow, CStdString& strIn) const;
820 void Stack(CFileItemList& items, VIDEODB_CONTENT_TYPE type, bool maintainSortOrder = false);
822 /*! \brief Get a safe filename from a given string
823 \param dir directory to use for the file
824 \param name movie, show name, or actor to get a safe filename for
825 \return safe filename based on this title
827 CStdString GetSafeFile(const CStdString &dir, const CStdString &name) const;
829 std::vector<int> CleanMediaType(const std::string &mediaType, const std::string &cleanableFileIDs,
830 std::map<int, bool> &pathsDeleteDecisions, std::string &deletedFileIDs, bool silent);
832 void AnnounceRemove(std::string content, int id);
833 void AnnounceUpdate(std::string content, int id);