[videodb] Add error handling to AddVideoAsset()
[xbmc.git] / xbmc / video / VideoDatabase.h
blob2f8635c401628442ba24680fe45bd8405fa2883f
1 /*
2 * Copyright (C) 2016-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "Bookmark.h"
12 #include "VideoInfoTag.h"
13 #include "addons/Scraper.h"
14 #include "dbwrappers/Database.h"
15 #include "utils/SortUtils.h"
16 #include "utils/UrlOptions.h"
18 #include <memory>
19 #include <set>
20 #include <utility>
21 #include <vector>
23 class CFileItem;
24 class CFileItemList;
25 class CStreamDetails;
26 class CVideoSettings;
27 class CGUIDialogProgress;
28 class CGUIDialogProgressBarHandle;
29 class TiXmlNode;
31 struct VideoAssetInfo;
33 enum class VideoAssetTypeOwner;
34 enum class VideoAssetType;
36 namespace dbiplus
38 class field_value;
39 typedef std::vector<field_value> sql_record;
42 #ifndef my_offsetof
43 #ifndef TARGET_POSIX
44 #define my_offsetof(TYPE, MEMBER) offsetof(TYPE, MEMBER)
45 #else
47 Custom version of standard offsetof() macro which can be used to get
48 offsets of members in class for non-POD types (according to the current
49 version of C++ standard offsetof() macro can't be used in such cases and
50 attempt to do so causes warnings to be emitted, OTOH in many cases it is
51 still OK to assume that all instances of the class has the same offsets
52 for the same members).
54 #define my_offsetof(TYPE, MEMBER) \
55 ((size_t)((char *)&(((TYPE *)0x10)->MEMBER) - (char*)0x10))
56 #endif
57 #endif
59 typedef std::vector<CVideoInfoTag> VECMOVIES;
61 namespace KODI::VIDEO
63 class IVideoInfoScannerObserver;
64 struct SScanSettings;
67 enum VideoDbDetails
69 VideoDbDetailsNone = 0x00,
70 VideoDbDetailsRating = 0x01,
71 VideoDbDetailsTag = 0x02,
72 VideoDbDetailsShowLink = 0x04,
73 VideoDbDetailsStream = 0x08,
74 VideoDbDetailsCast = 0x10,
75 VideoDbDetailsBookmark = 0x20,
76 VideoDbDetailsUniqueID = 0x40,
77 VideoDbDetailsAll = 0xFF
78 } ;
80 // these defines are based on how many columns we have and which column certain data is going to be in
81 // when we do GetDetailsForMovie()
82 #define VIDEODB_MAX_COLUMNS 24
83 #define VIDEODB_DETAILS_FILEID 1
85 #define VIDEODB_DETAILS_MOVIE_SET_ID VIDEODB_MAX_COLUMNS + 2
86 #define VIDEODB_DETAILS_MOVIE_USER_RATING VIDEODB_MAX_COLUMNS + 3
87 #define VIDEODB_DETAILS_MOVIE_PREMIERED VIDEODB_MAX_COLUMNS + 4
88 #define VIDEODB_DETAILS_MOVIE_SET_NAME VIDEODB_MAX_COLUMNS + 5
89 #define VIDEODB_DETAILS_MOVIE_SET_OVERVIEW VIDEODB_MAX_COLUMNS + 6
90 #define VIDEODB_DETAILS_MOVIE_FILE VIDEODB_MAX_COLUMNS + 7
91 #define VIDEODB_DETAILS_MOVIE_PATH VIDEODB_MAX_COLUMNS + 8
92 #define VIDEODB_DETAILS_MOVIE_PLAYCOUNT VIDEODB_MAX_COLUMNS + 9
93 #define VIDEODB_DETAILS_MOVIE_LASTPLAYED VIDEODB_MAX_COLUMNS + 10
94 #define VIDEODB_DETAILS_MOVIE_DATEADDED VIDEODB_MAX_COLUMNS + 11
95 #define VIDEODB_DETAILS_MOVIE_RESUME_TIME VIDEODB_MAX_COLUMNS + 12
96 #define VIDEODB_DETAILS_MOVIE_TOTAL_TIME VIDEODB_MAX_COLUMNS + 13
97 #define VIDEODB_DETAILS_MOVIE_PLAYER_STATE VIDEODB_MAX_COLUMNS + 14
98 #define VIDEODB_DETAILS_MOVIE_RATING VIDEODB_MAX_COLUMNS + 15
99 #define VIDEODB_DETAILS_MOVIE_VOTES VIDEODB_MAX_COLUMNS + 16
100 #define VIDEODB_DETAILS_MOVIE_RATING_TYPE VIDEODB_MAX_COLUMNS + 17
101 #define VIDEODB_DETAILS_MOVIE_UNIQUEID_VALUE VIDEODB_MAX_COLUMNS + 18
102 #define VIDEODB_DETAILS_MOVIE_UNIQUEID_TYPE VIDEODB_MAX_COLUMNS + 19
103 #define VIDEODB_DETAILS_MOVIE_HASVERSIONS VIDEODB_MAX_COLUMNS + 20
104 #define VIDEODB_DETAILS_MOVIE_HASEXTRAS VIDEODB_MAX_COLUMNS + 21
105 #define VIDEODB_DETAILS_MOVIE_ISDEFAULTVERSION VIDEODB_MAX_COLUMNS + 22
106 #define VIDEODB_DETAILS_MOVIE_VERSION_FILEID VIDEODB_MAX_COLUMNS + 23
107 #define VIDEODB_DETAILS_MOVIE_VERSION_TYPEID VIDEODB_MAX_COLUMNS + 24
108 #define VIDEODB_DETAILS_MOVIE_VERSION_TYPENAME VIDEODB_MAX_COLUMNS + 25
109 #define VIDEODB_DETAILS_MOVIE_VERSION_ITEMTYPE VIDEODB_MAX_COLUMNS + 26
111 #define VIDEODB_DETAILS_EPISODE_TVSHOW_ID VIDEODB_MAX_COLUMNS + 2
112 #define VIDEODB_DETAILS_EPISODE_USER_RATING VIDEODB_MAX_COLUMNS + 3
113 #define VIDEODB_DETAILS_EPISODE_SEASON_ID VIDEODB_MAX_COLUMNS + 4
114 #define VIDEODB_DETAILS_EPISODE_FILE VIDEODB_MAX_COLUMNS + 5
115 #define VIDEODB_DETAILS_EPISODE_PATH VIDEODB_MAX_COLUMNS + 6
116 #define VIDEODB_DETAILS_EPISODE_PLAYCOUNT VIDEODB_MAX_COLUMNS + 7
117 #define VIDEODB_DETAILS_EPISODE_LASTPLAYED VIDEODB_MAX_COLUMNS + 8
118 #define VIDEODB_DETAILS_EPISODE_DATEADDED VIDEODB_MAX_COLUMNS + 9
119 #define VIDEODB_DETAILS_EPISODE_TVSHOW_NAME VIDEODB_MAX_COLUMNS + 10
120 #define VIDEODB_DETAILS_EPISODE_TVSHOW_GENRE VIDEODB_MAX_COLUMNS + 11
121 #define VIDEODB_DETAILS_EPISODE_TVSHOW_STUDIO VIDEODB_MAX_COLUMNS + 12
122 #define VIDEODB_DETAILS_EPISODE_TVSHOW_AIRED VIDEODB_MAX_COLUMNS + 13
123 #define VIDEODB_DETAILS_EPISODE_TVSHOW_MPAA VIDEODB_MAX_COLUMNS + 14
124 #define VIDEODB_DETAILS_EPISODE_RESUME_TIME VIDEODB_MAX_COLUMNS + 15
125 #define VIDEODB_DETAILS_EPISODE_TOTAL_TIME VIDEODB_MAX_COLUMNS + 16
126 #define VIDEODB_DETAILS_EPISODE_PLAYER_STATE VIDEODB_MAX_COLUMNS + 17
127 #define VIDEODB_DETAILS_EPISODE_RATING VIDEODB_MAX_COLUMNS + 18
128 #define VIDEODB_DETAILS_EPISODE_VOTES VIDEODB_MAX_COLUMNS + 19
129 #define VIDEODB_DETAILS_EPISODE_RATING_TYPE VIDEODB_MAX_COLUMNS + 20
130 #define VIDEODB_DETAILS_EPISODE_UNIQUEID_VALUE VIDEODB_MAX_COLUMNS + 21
131 #define VIDEODB_DETAILS_EPISODE_UNIQUEID_TYPE VIDEODB_MAX_COLUMNS + 22
133 #define VIDEODB_DETAILS_TVSHOW_USER_RATING VIDEODB_MAX_COLUMNS + 1
134 #define VIDEODB_DETAILS_TVSHOW_DURATION VIDEODB_MAX_COLUMNS + 2
135 #define VIDEODB_DETAILS_TVSHOW_PARENTPATHID VIDEODB_MAX_COLUMNS + 3
136 #define VIDEODB_DETAILS_TVSHOW_PATH VIDEODB_MAX_COLUMNS + 4
137 #define VIDEODB_DETAILS_TVSHOW_DATEADDED VIDEODB_MAX_COLUMNS + 5
138 #define VIDEODB_DETAILS_TVSHOW_LASTPLAYED VIDEODB_MAX_COLUMNS + 6
139 #define VIDEODB_DETAILS_TVSHOW_NUM_EPISODES VIDEODB_MAX_COLUMNS + 7
140 #define VIDEODB_DETAILS_TVSHOW_NUM_WATCHED VIDEODB_MAX_COLUMNS + 8
141 #define VIDEODB_DETAILS_TVSHOW_NUM_SEASONS VIDEODB_MAX_COLUMNS + 9
142 #define VIDEODB_DETAILS_TVSHOW_RATING VIDEODB_MAX_COLUMNS + 10
143 #define VIDEODB_DETAILS_TVSHOW_VOTES VIDEODB_MAX_COLUMNS + 11
144 #define VIDEODB_DETAILS_TVSHOW_RATING_TYPE VIDEODB_MAX_COLUMNS + 12
145 #define VIDEODB_DETAILS_TVSHOW_UNIQUEID_VALUE VIDEODB_MAX_COLUMNS + 13
146 #define VIDEODB_DETAILS_TVSHOW_UNIQUEID_TYPE VIDEODB_MAX_COLUMNS + 14
147 #define VIDEODB_DETAILS_TVSHOW_NUM_INPROGRESS VIDEODB_MAX_COLUMNS + 15
149 #define VIDEODB_DETAILS_MUSICVIDEO_USER_RATING VIDEODB_MAX_COLUMNS + 2
150 #define VIDEODB_DETAILS_MUSICVIDEO_PREMIERED VIDEODB_MAX_COLUMNS + 3
151 #define VIDEODB_DETAILS_MUSICVIDEO_FILE VIDEODB_MAX_COLUMNS + 4
152 #define VIDEODB_DETAILS_MUSICVIDEO_PATH VIDEODB_MAX_COLUMNS + 5
153 #define VIDEODB_DETAILS_MUSICVIDEO_PLAYCOUNT VIDEODB_MAX_COLUMNS + 6
154 #define VIDEODB_DETAILS_MUSICVIDEO_LASTPLAYED VIDEODB_MAX_COLUMNS + 7
155 #define VIDEODB_DETAILS_MUSICVIDEO_DATEADDED VIDEODB_MAX_COLUMNS + 8
156 #define VIDEODB_DETAILS_MUSICVIDEO_RESUME_TIME VIDEODB_MAX_COLUMNS + 9
157 #define VIDEODB_DETAILS_MUSICVIDEO_TOTAL_TIME VIDEODB_MAX_COLUMNS + 10
158 #define VIDEODB_DETAILS_MUSICVIDEO_PLAYER_STATE VIDEODB_MAX_COLUMNS + 11
159 #define VIDEODB_DETAILS_MUSICVIDEO_UNIQUEID_VALUE VIDEODB_MAX_COLUMNS + 12
160 #define VIDEODB_DETAILS_MUSICVIDEO_UNIQUEID_TYPE VIDEODB_MAX_COLUMNS + 13
162 #define VIDEODB_TYPE_UNUSED 0
163 #define VIDEODB_TYPE_STRING 1
164 #define VIDEODB_TYPE_INT 2
165 #define VIDEODB_TYPE_FLOAT 3
166 #define VIDEODB_TYPE_BOOL 4
167 #define VIDEODB_TYPE_COUNT 5
168 #define VIDEODB_TYPE_STRINGARRAY 6
169 #define VIDEODB_TYPE_DATE 7
170 #define VIDEODB_TYPE_DATETIME 8
172 enum class VideoDbContentType
174 UNKNOWN = -1,
175 MOVIES = 1,
176 TVSHOWS = 2,
177 MUSICVIDEOS = 3,
178 EPISODES = 4,
179 MOVIE_SETS = 5,
180 MUSICALBUMS = 6
183 typedef enum // this enum MUST match the offset struct further down!! and make sure to keep min and max at -1 and sizeof(offsets)
185 VIDEODB_ID_MIN = -1,
186 VIDEODB_ID_TITLE = 0,
187 VIDEODB_ID_PLOT = 1,
188 VIDEODB_ID_PLOTOUTLINE = 2,
189 VIDEODB_ID_TAGLINE = 3,
190 VIDEODB_ID_VOTES = 4, // unused
191 VIDEODB_ID_RATING_ID = 5,
192 VIDEODB_ID_CREDITS = 6,
193 VIDEODB_ID_YEAR = 7, // unused
194 VIDEODB_ID_THUMBURL = 8,
195 VIDEODB_ID_IDENT_ID = 9,
196 VIDEODB_ID_SORTTITLE = 10,
197 VIDEODB_ID_RUNTIME = 11,
198 VIDEODB_ID_MPAA = 12,
199 VIDEODB_ID_TOP250 = 13,
200 VIDEODB_ID_GENRE = 14,
201 VIDEODB_ID_DIRECTOR = 15,
202 VIDEODB_ID_ORIGINALTITLE = 16,
203 VIDEODB_ID_THUMBURL_SPOOF = 17,
204 VIDEODB_ID_STUDIOS = 18,
205 VIDEODB_ID_TRAILER = 19,
206 VIDEODB_ID_FANART = 20,
207 VIDEODB_ID_COUNTRY = 21,
208 VIDEODB_ID_BASEPATH = 22,
209 VIDEODB_ID_PARENTPATHID = 23,
210 VIDEODB_ID_MAX
211 } VIDEODB_IDS;
213 const struct SDbTableOffsets
215 int type;
216 size_t offset;
217 } DbMovieOffsets[] =
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_strPlotOutline) },
222 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strTagLine) },
223 { VIDEODB_TYPE_UNUSED, 0 }, // unused
224 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iIdRating) },
225 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_writingCredits) },
226 { VIDEODB_TYPE_UNUSED, 0 }, // unused
227 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_data) },
228 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iIdUniqueID) },
229 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strSortTitle) },
230 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_duration) },
231 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strMPAARating) },
232 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iTop250) },
233 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_genre) },
234 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_director) },
235 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strOriginalTitle) },
236 { VIDEODB_TYPE_UNUSED, 0 }, // unused
237 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_studio) },
238 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strTrailer) },
239 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_fanart.m_xml) },
240 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_country) },
241 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_basePath) },
242 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_parentPathID) }
245 typedef enum // this enum MUST match the offset struct further down!! and make sure to keep min and max at -1 and sizeof(offsets)
247 VIDEODB_ID_TV_MIN = -1,
248 VIDEODB_ID_TV_TITLE = 0,
249 VIDEODB_ID_TV_PLOT = 1,
250 VIDEODB_ID_TV_STATUS = 2,
251 VIDEODB_ID_TV_VOTES = 3, // unused
252 VIDEODB_ID_TV_RATING_ID = 4,
253 VIDEODB_ID_TV_PREMIERED = 5,
254 VIDEODB_ID_TV_THUMBURL = 6,
255 VIDEODB_ID_TV_THUMBURL_SPOOF = 7,
256 VIDEODB_ID_TV_GENRE = 8,
257 VIDEODB_ID_TV_ORIGINALTITLE = 9,
258 VIDEODB_ID_TV_EPISODEGUIDE = 10,
259 VIDEODB_ID_TV_FANART = 11,
260 VIDEODB_ID_TV_IDENT_ID = 12,
261 VIDEODB_ID_TV_MPAA = 13,
262 VIDEODB_ID_TV_STUDIOS = 14,
263 VIDEODB_ID_TV_SORTTITLE = 15,
264 VIDEODB_ID_TV_TRAILER = 16,
265 VIDEODB_ID_TV_MAX
266 } VIDEODB_TV_IDS;
268 const struct SDbTableOffsets DbTvShowOffsets[] =
270 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strTitle) },
271 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPlot) },
272 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strStatus) },
273 { VIDEODB_TYPE_UNUSED, 0 }, //unused
274 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iIdRating) },
275 { VIDEODB_TYPE_DATE, my_offsetof(CVideoInfoTag,m_premiered) },
276 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_data) },
277 { VIDEODB_TYPE_UNUSED, 0 }, // unused
278 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_genre) },
279 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strOriginalTitle)},
280 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strEpisodeGuide)},
281 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_fanart.m_xml)},
282 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iIdUniqueID)},
283 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strMPAARating)},
284 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_studio)},
285 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strSortTitle)},
286 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strTrailer)}
289 //! @todo is this comment valid for seasons? There is no offset structure or am I wrong?
290 typedef enum // this enum MUST match the offset struct further down!! and make sure to keep min and max at -1 and sizeof(offsets)
292 VIDEODB_ID_SEASON_MIN = -1,
293 VIDEODB_ID_SEASON_ID = 0,
294 VIDEODB_ID_SEASON_TVSHOW_ID = 1,
295 VIDEODB_ID_SEASON_NUMBER = 2,
296 VIDEODB_ID_SEASON_NAME = 3,
297 VIDEODB_ID_SEASON_USER_RATING = 4,
298 VIDEODB_ID_SEASON_TVSHOW_PATH = 5,
299 VIDEODB_ID_SEASON_TVSHOW_TITLE = 6,
300 VIDEODB_ID_SEASON_TVSHOW_PLOT = 7,
301 VIDEODB_ID_SEASON_TVSHOW_PREMIERED = 8,
302 VIDEODB_ID_SEASON_TVSHOW_GENRE = 9,
303 VIDEODB_ID_SEASON_TVSHOW_STUDIO = 10,
304 VIDEODB_ID_SEASON_TVSHOW_MPAA = 11,
305 VIDEODB_ID_SEASON_EPISODES_TOTAL = 12,
306 VIDEODB_ID_SEASON_EPISODES_WATCHED = 13,
307 VIDEODB_ID_SEASON_PREMIERED = 14,
308 VIDEODB_ID_SEASON_EPISODES_INPROGRESS = 15,
309 VIDEODB_ID_SEASON_MAX
310 } VIDEODB_SEASON_IDS;
312 typedef enum // this enum MUST match the offset struct further down!! and make sure to keep min and max at -1 and sizeof(offsets)
314 VIDEODB_ID_EPISODE_MIN = -1,
315 VIDEODB_ID_EPISODE_TITLE = 0,
316 VIDEODB_ID_EPISODE_PLOT = 1,
317 VIDEODB_ID_EPISODE_VOTES = 2, // unused
318 VIDEODB_ID_EPISODE_RATING_ID = 3,
319 VIDEODB_ID_EPISODE_CREDITS = 4,
320 VIDEODB_ID_EPISODE_AIRED = 5,
321 VIDEODB_ID_EPISODE_THUMBURL = 6,
322 VIDEODB_ID_EPISODE_THUMBURL_SPOOF = 7,
323 VIDEODB_ID_EPISODE_PLAYCOUNT = 8, // unused - feel free to repurpose
324 VIDEODB_ID_EPISODE_RUNTIME = 9,
325 VIDEODB_ID_EPISODE_DIRECTOR = 10,
326 VIDEODB_ID_EPISODE_PRODUCTIONCODE = 11,
327 VIDEODB_ID_EPISODE_SEASON = 12,
328 VIDEODB_ID_EPISODE_EPISODE = 13,
329 VIDEODB_ID_EPISODE_ORIGINALTITLE = 14,
330 VIDEODB_ID_EPISODE_SORTSEASON = 15,
331 VIDEODB_ID_EPISODE_SORTEPISODE = 16,
332 VIDEODB_ID_EPISODE_BOOKMARK = 17,
333 VIDEODB_ID_EPISODE_BASEPATH = 18,
334 VIDEODB_ID_EPISODE_PARENTPATHID = 19,
335 VIDEODB_ID_EPISODE_IDENT_ID = 20,
336 VIDEODB_ID_EPISODE_MAX
337 } VIDEODB_EPISODE_IDS;
339 const struct SDbTableOffsets DbEpisodeOffsets[] =
341 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strTitle) },
342 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPlot) },
343 { VIDEODB_TYPE_UNUSED, 0 }, // unused
344 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iIdRating) },
345 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_writingCredits) },
346 { VIDEODB_TYPE_DATE, my_offsetof(CVideoInfoTag,m_firstAired) },
347 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_data) },
348 { VIDEODB_TYPE_UNUSED, 0 }, // unused
349 { VIDEODB_TYPE_UNUSED, 0 }, // unused
350 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_duration) },
351 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_director) },
352 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strProductionCode) },
353 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iSeason) },
354 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iEpisode) },
355 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strOriginalTitle)},
356 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iSpecialSortSeason) },
357 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iSpecialSortEpisode) },
358 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iBookmarkId) },
359 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_basePath) },
360 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_parentPathID) },
361 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iIdUniqueID) }
364 typedef enum // this enum MUST match the offset struct further down!! and make sure to keep min and max at -1 and sizeof(offsets)
366 VIDEODB_ID_MUSICVIDEO_MIN = -1,
367 VIDEODB_ID_MUSICVIDEO_TITLE = 0,
368 VIDEODB_ID_MUSICVIDEO_THUMBURL = 1,
369 VIDEODB_ID_MUSICVIDEO_THUMBURL_SPOOF = 2,
370 VIDEODB_ID_MUSICVIDEO_PLAYCOUNT = 3, // unused - feel free to repurpose
371 VIDEODB_ID_MUSICVIDEO_RUNTIME = 4,
372 VIDEODB_ID_MUSICVIDEO_DIRECTOR = 5,
373 VIDEODB_ID_MUSICVIDEO_STUDIOS = 6,
374 VIDEODB_ID_MUSICVIDEO_YEAR = 7, // unused
375 VIDEODB_ID_MUSICVIDEO_PLOT = 8,
376 VIDEODB_ID_MUSICVIDEO_ALBUM = 9,
377 VIDEODB_ID_MUSICVIDEO_ARTIST = 10,
378 VIDEODB_ID_MUSICVIDEO_GENRE = 11,
379 VIDEODB_ID_MUSICVIDEO_TRACK = 12,
380 VIDEODB_ID_MUSICVIDEO_BASEPATH = 13,
381 VIDEODB_ID_MUSICVIDEO_PARENTPATHID = 14,
382 VIDEODB_ID_MUSICVIDEO_IDENT_ID = 15,
383 VIDEODB_ID_MUSICVIDEO_MAX
384 } VIDEODB_MUSICVIDEO_IDS;
386 const struct SDbTableOffsets DbMusicVideoOffsets[] =
388 { VIDEODB_TYPE_STRING, my_offsetof(class CVideoInfoTag,m_strTitle) },
389 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPictureURL.m_data) },
390 { VIDEODB_TYPE_UNUSED, 0 }, // unused
391 { VIDEODB_TYPE_UNUSED, 0 }, // unused
392 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_duration) },
393 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_director) },
394 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_studio) },
395 { VIDEODB_TYPE_UNUSED, 0 }, // unused
396 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strPlot) },
397 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_strAlbum) },
398 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_artist) },
399 { VIDEODB_TYPE_STRINGARRAY, my_offsetof(CVideoInfoTag,m_genre) },
400 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iTrack) },
401 { VIDEODB_TYPE_STRING, my_offsetof(CVideoInfoTag,m_basePath) },
402 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_parentPathID) },
403 { VIDEODB_TYPE_INT, my_offsetof(CVideoInfoTag,m_iIdUniqueID)}
406 enum class ArtFallbackOptions
408 NONE,
409 PARENT
412 enum class DeleteMovieCascadeAction
414 DEFAULT_VERSION,
415 ALL_ASSETS
418 enum class DeleteMovieHashAction
420 HASH_DELETE,
421 HASH_PRESERVE
424 #define COMPARE_PERCENTAGE 0.90f // 90%
425 #define COMPARE_PERCENTAGE_MIN 0.50f // 50%
427 class CVideoDatabase : public CDatabase
429 public:
431 class CActor // used for actor retrieval for non-master users
433 public:
434 std::string name;
435 std::string thumb;
436 int playcount;
437 int appearances;
440 class CSeason // used for season retrieval for non-master users
442 public:
443 std::string path;
444 std::vector<std::string> genre;
445 int numEpisodes;
446 int numWatched;
447 int id;
450 class CSetInfo
452 public:
453 std::string name;
454 VECMOVIES movies;
455 DatabaseResults results;
458 CVideoDatabase(void);
459 ~CVideoDatabase(void) override;
461 bool Open() override;
462 bool CommitTransaction() override;
464 int AddNewEpisode(int idShow, CVideoInfoTag& details);
466 // editing functions
467 /*! \brief Set the playcount of an item, update last played time
468 Sets the playcount and last played date to a given value
469 \param item CFileItem to set the playcount for
470 \param count The playcount to set.
471 \param date The date the file was last viewed (does not denote the video was watched to completion).
472 If empty we use current datetime (if count > 0) or never viewed (if count = 0).
473 \return on success, the new last played time set, invalid datetime otherwise.
474 \sa GetPlayCount, IncrementPlayCount, UpdateLastPlayed
476 CDateTime SetPlayCount(const CFileItem& item, int count, const CDateTime& date = CDateTime());
478 /*! \brief Increment the playcount of an item
479 Increments the playcount and updates the last played date
480 \param item CFileItem to increment the playcount for
481 \return on success, the new last played time set, invalid datetime otherwise.
482 \sa GetPlayCount, SetPlayCount, GetPlayCounts
484 CDateTime IncrementPlayCount(const CFileItem& item);
486 /*! \brief Get the playcount of an item
487 \param item CFileItem to get the playcount for
488 \return the playcount of the item, or -1 on error
489 \sa SetPlayCount, IncrementPlayCount, GetPlayCounts
491 int GetPlayCount(const CFileItem &item);
493 /*! \brief Get the playcount of a filename and path
494 \param strFilenameAndPath filename and path to get the playcount for
495 \return the playcount of the item, or -1 on error
496 \sa SetPlayCount, IncrementPlayCount, GetPlayCounts
498 int GetPlayCount(const std::string& strFilenameAndPath);
500 /*! \brief Get the last played time of a filename and path
501 \param strFilenameAndPath filename and path to get the last played time for
502 \return the last played time of the item, or an invalid CDateTime on error
503 \sa UpdateLastPlayed
505 CDateTime GetLastPlayed(const std::string& strFilenameAndPath);
507 /*! \brief Update the last played time of an item
508 Updates the last played date
509 \param item CFileItem to update the last played time for
510 \return on success, the last played time set, invalid datetime otherwise.
511 \sa GetPlayCount, SetPlayCount, IncrementPlayCount, GetPlayCounts
513 CDateTime UpdateLastPlayed(const CFileItem& item);
515 /*! \brief Get the playcount and resume point of a list of items
516 Note that if the resume point is already set on an item, it won't be overridden.
517 \param path the path to fetch videos from
518 \param items CFileItemList to fetch the playcounts for
519 \sa GetPlayCount, SetPlayCount, IncrementPlayCount
521 bool GetPlayCounts(const std::string &path, CFileItemList &items);
523 void UpdateMovieTitle(int idMovie,
524 const std::string& strNewMovieTitle,
525 VideoDbContentType iType = VideoDbContentType::MOVIES);
526 bool UpdateVideoSortTitle(int idDb,
527 const std::string& strNewSortTitle,
528 VideoDbContentType iType = VideoDbContentType::MOVIES);
530 bool HasMovieInfo(const std::string& strFilenameAndPath);
531 bool HasTvShowInfo(const std::string& strFilenameAndPath);
532 bool HasEpisodeInfo(const std::string& strFilenameAndPath);
533 bool HasMusicVideoInfo(const std::string& strFilenameAndPath);
535 void GetFilePathById(int idMovie, std::string& filePath, VideoDbContentType iType);
536 std::string GetGenreById(int id);
537 std::string GetCountryById(int id);
538 std::string GetSetById(int id);
539 std::string GetTagById(int id);
540 std::string GetPersonById(int id);
541 std::string GetStudioById(int id);
542 std::string GetTvShowTitleById(int id);
543 std::string GetMusicVideoAlbumById(int id);
544 int GetTvShowForEpisode(int idEpisode);
545 int GetSeasonForEpisode(int idEpisode);
547 bool LoadVideoInfo(const std::string& strFilenameAndPath, CVideoInfoTag& details, int getDetails = VideoDbDetailsAll);
548 bool GetMovieInfo(const std::string& strFilenameAndPath,
549 CVideoInfoTag& details,
550 int idMovie = -1,
551 int idVersion = -1,
552 int getDetails = VideoDbDetailsAll);
553 bool GetTvShowInfo(const std::string& strPath, CVideoInfoTag& details, int idTvShow = -1, CFileItem* item = NULL, int getDetails = VideoDbDetailsAll);
554 bool GetSeasonInfo(const std::string& path, int season, CVideoInfoTag& details, CFileItem* item);
555 bool GetSeasonInfo(int idSeason, CVideoInfoTag& details, CFileItem* item);
556 bool GetSeasonInfo(int idSeason, CVideoInfoTag& details, bool allDetails = true);
557 bool GetEpisodeBasicInfo(const std::string& strFilenameAndPath, CVideoInfoTag& details, int idEpisode = -1);
558 bool GetEpisodeInfo(const std::string& strFilenameAndPath, CVideoInfoTag& details, int idEpisode = -1, int getDetails = VideoDbDetailsAll);
559 bool GetMusicVideoInfo(const std::string& strFilenameAndPath, CVideoInfoTag& details, int idMVideo = -1, int getDetails = VideoDbDetailsAll);
560 bool GetSetInfo(int idSet, CVideoInfoTag& details, CFileItem* item = nullptr);
561 bool GetFileInfo(const std::string& strFilenameAndPath, CVideoInfoTag& details, int idFile = -1);
563 int GetPathId(const std::string& strPath);
564 int GetTvShowId(const std::string& strPath);
565 int GetEpisodeId(const std::string& strFilenameAndPath, int idEpisode=-1, int idSeason=-1); // idEpisode, idSeason are used for multipart episodes as hints
566 int GetSeasonId(int idShow, int season);
568 void GetEpisodesByFile(const std::string& strFilenameAndPath, std::vector<CVideoInfoTag>& episodes);
570 int SetDetailsForItem(CVideoInfoTag& details, const std::map<std::string, std::string> &artwork);
571 int SetDetailsForItem(int id, const MediaType& mediaType, CVideoInfoTag& details, const std::map<std::string, std::string> &artwork);
573 int SetDetailsForMovie(CVideoInfoTag& details,
574 const std::map<std::string, std::string>& artwork,
575 int idMovie = -1);
576 int SetDetailsForMovieSet(const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idSet = -1);
578 /*! \brief add a tvshow to the library, setting metadata detail
579 First checks for whether this TV Show is already in the database (based on idTvShow, or via GetMatchingTvShow)
580 and if present adds the paths to the show. If not present, we add a new show and set the show metadata.
581 \param paths a vector<string,string> list of the path(s) and parent path(s) for the show.
582 \param details a CVideoInfoTag filled with the metadata for the show.
583 \param artwork the artwork map for the show.
584 \param seasonArt the artwork map for seasons.
585 \param idTvShow the database id of the tvshow if known (defaults to -1)
586 \return the id of the tvshow.
588 int SetDetailsForTvShow(const std::vector< std::pair<std::string, std::string> > &paths, CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, const std::map<int, std::map<std::string, std::string> > &seasonArt, int idTvShow = -1);
589 bool UpdateDetailsForTvShow(int idTvShow, CVideoInfoTag &details, const std::map<std::string, std::string> &artwork, const std::map<int, std::map<std::string, std::string> > &seasonArt);
590 int SetDetailsForSeason(const CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, int idShow, int idSeason = -1);
591 int SetDetailsForEpisode(CVideoInfoTag& details,
592 const std::map<std::string, std::string>& artwork,
593 int idShow,
594 int idEpisode = -1);
595 bool SetFileForEpisode(const std::string& fileAndPath, int idEpisode, int idFile);
596 bool SetFileForMovie(const std::string& fileAndPath, int idMovie, int idFile);
597 int SetDetailsForMusicVideo(CVideoInfoTag& details,
598 const std::map<std::string, std::string>& artwork,
599 int idMVideo = -1);
600 int SetStreamDetailsForFile(const CStreamDetails& details, const std::string& strFileNameAndPath);
602 * \brief Clear any existing stream details and add the new provided details to a file.
603 * \param[in] details New stream details
604 * \param[in] idFile Identifier of the file
605 * \return operation success. true for success, false for failure
607 bool SetStreamDetailsForFileId(const CStreamDetails& details, int idFile);
609 bool SetSingleValue(VideoDbContentType type, int dbId, int dbField, const std::string& strValue);
610 bool SetSingleValue(VideoDbContentType type,
611 int dbId,
612 Field dbField,
613 const std::string& strValue);
614 bool SetSingleValue(const std::string &table, const std::string &fieldName, const std::string &strValue,
615 const std::string &conditionName = "", int conditionValue = -1);
617 int UpdateDetailsForMovie(int idMovie, CVideoInfoTag& details, const std::map<std::string, std::string> &artwork, const std::set<std::string> &updatedDetails);
619 void DeleteMovie(int idMovie,
620 DeleteMovieCascadeAction action = DeleteMovieCascadeAction::ALL_ASSETS,
621 DeleteMovieHashAction hashAction = DeleteMovieHashAction::HASH_DELETE);
622 void DeleteTvShow(int idTvShow, bool bKeepId = false);
623 void DeleteTvShow(const std::string& strPath);
624 void DeleteSeason(int idSeason, bool bKeepId = false);
625 void DeleteEpisode(int idEpisode, bool bKeepId = false);
626 void DeleteMusicVideo(int idMusicVideo, bool bKeepId = false);
627 void DeleteDetailsForTvShow(int idTvShow);
628 void DeleteStreamDetails(int idFile);
629 void RemoveContentForPath(const std::string& strPath,CGUIDialogProgress *progress = NULL);
630 void UpdateFanart(const CFileItem& item, VideoDbContentType type);
631 void DeleteSet(int idSet);
632 void DeleteTag(int idTag, VideoDbContentType mediaType);
634 /*! \brief Get video settings for the specified file id
635 \param idFile file id to get the settings for
636 \return true if video settings found, false otherwise
637 \sa SetVideoSettings
639 bool GetVideoSettings(int idFile, CVideoSettings &settings);
641 /*! \brief Get video settings for the specified file item
642 \param item item to get the settings for
643 \return true if video settings found, false otherwise
644 \sa SetVideoSettings
646 bool GetVideoSettings(const CFileItem &item, CVideoSettings &settings);
648 /*! \brief Get video settings for the specified file path
649 \param filePath filepath to get the settings for
650 \return true if video settings found, false otherwise
651 \sa SetVideoSettings
653 bool GetVideoSettings(const std::string &filePath, CVideoSettings &settings);
655 /*! \brief Set video settings for the specified file path
656 \param fileItem to set the settings for
657 \sa GetVideoSettings
659 void SetVideoSettings(const CFileItem &item, const CVideoSettings &settings);
661 /*! \brief Set video settings for the specified file path
662 \param fileId to set the settings for
663 \sa GetVideoSettings
665 void SetVideoSettings(int idFile, const CVideoSettings &settings);
668 * Erases video settings for file item
669 * @param fileitem
671 void EraseVideoSettings(const CFileItem &item);
674 * Erases all video settings
676 void EraseAllVideoSettings();
679 * Erases video settings for files starting with path
680 * @param path pattern
682 void EraseAllVideoSettings(const std::string& path);
685 * Erases all entries for files starting with path, including the files and path entries
686 * @param path pattern
688 void EraseAllForPath(const std::string& path);
691 * Erases all entries for the given file, including path entry if no longer used
692 * @param fileNameAndPath The name and path of the file to erase db entries for
694 void EraseAllForFile(const std::string& fileNameAndPath);
696 bool GetStackTimes(const std::string &filePath, std::vector<uint64_t> &times);
697 void SetStackTimes(const std::string &filePath, const std::vector<uint64_t> &times);
699 void GetBookMarksForFile(const std::string& strFilenameAndPath, VECBOOKMARKS& bookmarks, CBookmark::EType type = CBookmark::STANDARD, bool bAppend=false, long partNumber=0);
700 void AddBookMarkToFile(const std::string& strFilenameAndPath, const CBookmark &bookmark, CBookmark::EType type = CBookmark::STANDARD);
701 bool GetResumeBookMark(const std::string& strFilenameAndPath, CBookmark &bookmark);
702 void DeleteResumeBookMark(const CFileItem& item);
703 void ClearBookMarkOfFile(const std::string& strFilenameAndPath, CBookmark& bookmark, CBookmark::EType type = CBookmark::STANDARD);
704 void ClearBookMarksOfFile(const std::string& strFilenameAndPath, CBookmark::EType type = CBookmark::STANDARD);
705 void ClearBookMarksOfFile(int idFile, CBookmark::EType type = CBookmark::STANDARD);
706 bool GetBookMarkForEpisode(const CVideoInfoTag& tag, CBookmark& bookmark);
707 void AddBookMarkForEpisode(const CVideoInfoTag& tag, const CBookmark& bookmark);
708 void DeleteBookMarkForEpisode(const CVideoInfoTag& tag);
709 bool GetResumePoint(CVideoInfoTag& tag);
710 bool GetStreamDetails(CFileItem& item);
711 bool GetStreamDetails(CVideoInfoTag& tag);
712 bool GetStreamDetails(const std::string& filenameAndPath, CStreamDetails& details);
713 bool GetDetailsByTypeAndId(CFileItem& item, VideoDbContentType type, int id);
714 CVideoInfoTag GetDetailsByTypeAndId(VideoDbContentType type, int id);
716 // scraper settings
717 void SetScraperForPath(const std::string& filePath,
718 const ADDON::ScraperPtr& info,
719 const KODI::VIDEO::SScanSettings& settings);
720 ADDON::ScraperPtr GetScraperForPath(const std::string& strPath);
721 ADDON::ScraperPtr GetScraperForPath(const std::string& strPath,
722 KODI::VIDEO::SScanSettings& settings);
724 /*! \brief Retrieve the scraper and settings we should use for the specified path
725 If the scraper is not set on this particular path, we'll recursively check parent folders.
726 \param strPath path to start searching in.
727 \param settings [out] scan settings for this folder.
728 \param foundDirectly [out] true if a scraper was found directly for strPath, false if it was in a parent path.
729 \return A ScraperPtr containing the scraper information. Returns NULL if a trivial (Content == CONTENT_NONE)
730 scraper or no scraper is found.
732 ADDON::ScraperPtr GetScraperForPath(const std::string& strPath,
733 KODI::VIDEO::SScanSettings& settings,
734 bool& foundDirectly);
736 /*! \brief Retrieve the content type of videos in the given path
737 If content is set on the folder, we return the given content type, except in the case of tvshows,
738 where we first check for whether we have episodes directly in the path (thus return episodes) or whether
739 we've found a scraper directly (shows). Any folders inbetween are treated as seasons (regardless of whether
740 they actually are seasons). Note that any subfolders in movies will be treated as movies.
741 \param strPath path to start searching in.
742 \return A content type string for the current path.
744 std::string GetContentForPath(const std::string& strPath);
746 /*! \brief Get videos of the given content type from the given path
747 \param content the content type to fetch.
748 \param path the path to fetch videos from.
749 \param items the returned items
750 \return true if items are found, false otherwise.
752 bool GetItemsForPath(const std::string &content, const std::string &path, CFileItemList &items);
754 /*! \brief Check whether a given scraper is in use.
755 \param scraperID the scraper to check for.
756 \return true if the scraper is in use, false otherwise.
758 bool ScraperInUse(const std::string &scraperID) const;
760 // scanning hashes and paths scanned
761 bool SetPathHash(const std::string &path, const std::string &hash);
762 bool GetPathHash(const std::string &path, std::string &hash);
763 bool GetPaths(std::set<std::string> &paths);
764 bool GetPathsForTvShow(int idShow, std::set<int>& paths);
766 /*! \brief return the paths linked to a tvshow.
767 \param idShow the id of the tvshow.
768 \param paths [out] the list of paths associated with the show.
769 \return true on success, false on failure.
771 bool GetPathsLinkedToTvShow(int idShow, std::vector<std::string> &paths);
773 /*! \brief retrieve subpaths of a given path. Assumes a hierarchical folder structure
774 \param basepath the root path to retrieve subpaths for
775 \param subpaths the returned subpaths
776 \return true if we successfully retrieve subpaths (may be zero), false on error
778 bool GetSubPaths(const std::string& basepath, std::vector< std::pair<int, std::string> >& subpaths);
780 bool GetSourcePath(const std::string &path, std::string &sourcePath);
781 bool GetSourcePath(const std::string& path,
782 std::string& sourcePath,
783 KODI::VIDEO::SScanSettings& settings);
785 // for music + musicvideo linkups - if no album and title given it will return the artist id, else the id of the matching video
786 int GetMatchingMusicVideo(const std::string& strArtist, const std::string& strAlbum = "", const std::string& strTitle = "");
788 // searching functions
789 void GetMoviesByActor(const std::string& strActor, CFileItemList& items);
790 void GetTvShowsByActor(const std::string& strActor, CFileItemList& items);
791 void GetEpisodesByActor(const std::string& strActor, CFileItemList& items);
793 void GetMusicVideosByArtist(const std::string& strArtist, CFileItemList& items);
794 void GetMusicVideosByAlbum(const std::string& strAlbum, CFileItemList& items);
796 void GetMovieGenresByName(const std::string& strSearch, CFileItemList& items);
797 void GetTvShowGenresByName(const std::string& strSearch, CFileItemList& items);
798 void GetMusicVideoGenresByName(const std::string& strSearch, CFileItemList& items);
800 void GetMovieCountriesByName(const std::string& strSearch, CFileItemList& items);
802 void GetMusicVideoAlbumsByName(const std::string& strSearch, CFileItemList& items);
804 void GetMovieActorsByName(const std::string& strSearch, CFileItemList& items);
805 void GetTvShowsActorsByName(const std::string& strSearch, CFileItemList& items);
806 void GetMusicVideoArtistsByName(const std::string& strSearch, CFileItemList& items);
808 void GetMovieDirectorsByName(const std::string& strSearch, CFileItemList& items);
809 void GetTvShowsDirectorsByName(const std::string& strSearch, CFileItemList& items);
810 void GetMusicVideoDirectorsByName(const std::string& strSearch, CFileItemList& items);
812 void GetMoviesByName(const std::string& strSearch, CFileItemList& items);
813 void GetTvShowsByName(const std::string& strSearch, CFileItemList& items);
814 void GetEpisodesByName(const std::string& strSearch, CFileItemList& items);
815 void GetMusicVideosByName(const std::string& strSearch, CFileItemList& items);
817 void GetEpisodesByPlot(const std::string& strSearch, CFileItemList& items);
818 void GetMoviesByPlot(const std::string& strSearch, CFileItemList& items);
820 bool LinkMovieToTvshow(int idMovie, int idShow, bool bRemove);
821 bool IsLinkedToTvshow(int idMovie);
822 bool GetLinksToTvShow(int idMovie, std::vector<int>& ids);
824 // general browsing
825 bool GetGenresNav(const std::string& strBaseDir,
826 CFileItemList& items,
827 VideoDbContentType idContent = VideoDbContentType::UNKNOWN,
828 const Filter& filter = Filter(),
829 bool countOnly = false);
830 bool GetCountriesNav(const std::string& strBaseDir,
831 CFileItemList& items,
832 VideoDbContentType idContent = VideoDbContentType::UNKNOWN,
833 const Filter& filter = Filter(),
834 bool countOnly = false);
835 bool GetStudiosNav(const std::string& strBaseDir,
836 CFileItemList& items,
837 VideoDbContentType idContent = VideoDbContentType::UNKNOWN,
838 const Filter& filter = Filter(),
839 bool countOnly = false);
840 bool GetYearsNav(const std::string& strBaseDir,
841 CFileItemList& items,
842 VideoDbContentType idContent = VideoDbContentType::UNKNOWN,
843 const Filter& filter = Filter());
844 bool GetActorsNav(const std::string& strBaseDir,
845 CFileItemList& items,
846 VideoDbContentType idContent = VideoDbContentType::UNKNOWN,
847 const Filter& filter = Filter(),
848 bool countOnly = false);
849 bool GetDirectorsNav(const std::string& strBaseDir,
850 CFileItemList& items,
851 VideoDbContentType idContent = VideoDbContentType::UNKNOWN,
852 const Filter& filter = Filter(),
853 bool countOnly = false);
854 bool GetWritersNav(const std::string& strBaseDir,
855 CFileItemList& items,
856 VideoDbContentType idContent = VideoDbContentType::UNKNOWN,
857 const Filter& filter = Filter(),
858 bool countOnly = false);
859 bool GetSetsNav(const std::string& strBaseDir,
860 CFileItemList& items,
861 VideoDbContentType idContent = VideoDbContentType::UNKNOWN,
862 const Filter& filter = Filter(),
863 bool ignoreSingleMovieSets = false);
864 bool GetTagsNav(const std::string& strBaseDir,
865 CFileItemList& items,
866 VideoDbContentType idContent = VideoDbContentType::UNKNOWN,
867 const Filter& filter = Filter(),
868 bool countOnly = false);
870 bool GetMusicVideoAlbumsNav(const std::string& strBaseDir, CFileItemList& items, int idArtist, const Filter &filter = Filter(), bool countOnly = false);
872 bool GetMoviesNav(const std::string& 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(), int getDetails = VideoDbDetailsNone);
873 bool GetTvShowsNav(const std::string& 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(), int getDetails = VideoDbDetailsNone);
874 bool GetSeasonsNav(const std::string& strBaseDir, CFileItemList& items, int idActor=-1, int idDirector=-1, int idGenre=-1, int idYear=-1, int idShow=-1, bool getLinkedMovies = true);
875 bool GetEpisodesNav(const std::string& 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(), int getDetails = VideoDbDetailsNone);
876 bool GetMusicVideosNav(const std::string& 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(), int getDetails = VideoDbDetailsNone);
878 bool GetRecentlyAddedMoviesNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit=0, int getDetails = VideoDbDetailsNone);
879 bool GetRecentlyAddedEpisodesNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit=0, int getDetails = VideoDbDetailsNone);
880 bool GetRecentlyAddedMusicVideosNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit=0, int getDetails = VideoDbDetailsNone);
881 bool GetInProgressTvShowsNav(const std::string& strBaseDir, CFileItemList& items, unsigned int limit=0, int getDetails = VideoDbDetailsNone);
883 bool HasContent();
884 bool HasContent(VideoDbContentType type);
885 bool HasSets() const;
887 void CleanDatabase(CGUIDialogProgressBarHandle* handle = NULL, const std::set<int>& paths = std::set<int>(), bool showProgress = true);
889 /*! \brief Add a file to the database, if necessary
890 If the file is already in the database, we simply return its id.
891 \param url - full path of the file to add.
892 \param parentPath the parent path of the path to add. If empty, URIUtils::GetParentPath() will determine the path.
893 \param dateAdded datetime when the file was added to the filesystem/database
894 \param playcount the playcount of the file to add.
895 \param lastPlayed the date and time when the file to add was last played.
896 \return id of the file, -1 if it could not be added.
898 int AddFile(const std::string& url,
899 const std::string& parentPath = "",
900 const CDateTime& dateAdded = CDateTime(),
901 int playcount = 0,
902 const CDateTime& lastPlayed = CDateTime());
904 /*! \brief Add a file to the database, if necessary
905 Works for both videodb:// items and normal fileitems
906 \param item CFileItem to add.
907 \return id of the file, -1 if it could not be added.
909 int AddFile(const CFileItem& item);
911 /*! \brief Add a file to the database, if necessary
912 Works for both videodb:// items and normal fileitems
913 \param url full path of the file to add.
914 \param details details of the item to add.
915 \return id of the file, -1 if it could not be added.
917 int AddFile(const CVideoInfoTag& details, const std::string& parentPath = "");
919 /*! \brief Add a path to the database, if necessary
920 If the path is already in the database, we simply return its id.
921 \param strPath the path to add
922 \param parentPath the parent path of the path to add. If empty, URIUtils::GetParentPath() will determine the path.
923 \param dateAdded datetime when the path was added to the filesystem/database
924 \return id of the file, -1 if it could not be added.
926 int AddPath(const std::string& strPath, const std::string &parentPath = "", const CDateTime& dateAdded = CDateTime());
928 /*! \brief Updates the dateAdded field in the files table for the file
929 with the given idFile and the given path based on the files modification date
930 \param details details of the video file
932 void UpdateFileDateAdded(CVideoInfoTag& details);
934 void ExportToXML(const std::string &path, bool singleFile = true, bool images=false, bool actorThumbs=false, bool overwrite=false);
935 void ExportActorThumbs(const std::string &path, const CVideoInfoTag& tag, bool singleFiles, bool overwrite=false);
936 void ImportFromXML(const std::string &path);
937 void DumpToDummyFiles(const std::string &path);
938 bool ImportArtFromXML(const TiXmlNode *node, std::map<std::string, std::string> &artwork);
940 // smart playlists and main retrieval work in these functions
941 bool GetMoviesByWhere(const std::string& strBaseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription = SortDescription(), int getDetails = VideoDbDetailsNone);
942 bool GetSetsByWhere(const std::string& strBaseDir, const Filter &filter, CFileItemList& items, bool ignoreSingleMovieSets = false);
943 bool GetTvShowsByWhere(const std::string& strBaseDir, const Filter &filter, CFileItemList& items, const SortDescription &sortDescription = SortDescription(), int getDetails = VideoDbDetailsNone);
944 bool GetSeasonsByWhere(const std::string& strBaseDir, const Filter &filter, CFileItemList& items, bool appendFullShowPath = true, const SortDescription &sortDescription = SortDescription());
945 bool GetEpisodesByWhere(const std::string& strBaseDir, const Filter &filter, CFileItemList& items, bool appendFullShowPath = true, const SortDescription &sortDescription = SortDescription(), int getDetails = VideoDbDetailsNone);
946 bool GetMusicVideosByWhere(const std::string &baseDir, const Filter &filter, CFileItemList& items, bool checkLocks = true, const SortDescription &sortDescription = SortDescription(), int getDetails = VideoDbDetailsNone);
948 // retrieve sorted and limited items
949 bool GetSortedVideos(const MediaType &mediaType, const std::string& strBaseDir, const SortDescription &sortDescription, CFileItemList& items, const Filter &filter = Filter());
951 // retrieve a list of items
952 bool GetItems(const std::string &strBaseDir, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription());
953 bool GetItems(const std::string &strBaseDir, const std::string &mediaType, const std::string &itemType, CFileItemList &items, const Filter &filter = Filter(), const SortDescription &sortDescription = SortDescription());
954 bool GetItems(const std::string& strBaseDir,
955 VideoDbContentType mediaType,
956 const std::string& itemType,
957 CFileItemList& items,
958 const Filter& filter = Filter(),
959 const SortDescription& sortDescription = SortDescription());
960 std::string GetItemById(const std::string &itemType, int id);
962 // partymode
963 /*! \brief Gets music video IDs in random order that match the where clause
964 \param strWhere the SQL where clause to apply in the query
965 \param songIDs a vector of <2, id> pairs suited to party mode use
966 \return count of music video IDs found.
968 unsigned int GetRandomMusicVideoIDs(const std::string& strWhere, std::vector<std::pair<int, int> > &songIDs);
970 static void VideoContentTypeToString(VideoDbContentType type, std::string& out)
972 switch (type)
974 case VideoDbContentType::MOVIES:
975 out = MediaTypeMovie;
976 break;
977 case VideoDbContentType::TVSHOWS:
978 out = MediaTypeTvShow;
979 break;
980 case VideoDbContentType::EPISODES:
981 out = MediaTypeEpisode;
982 break;
983 case VideoDbContentType::MUSICVIDEOS:
984 out = MediaTypeMusicVideo;
985 break;
986 default:
987 break;
991 bool SetArtForItem(int mediaId,
992 const MediaType& mediaType,
993 const std::string& artType,
994 const std::string& url);
995 bool SetArtForItem(int mediaId,
996 const MediaType& mediaType,
997 const std::map<std::string, std::string>& art);
998 bool GetArtForItem(int mediaId,
999 const MediaType& mediaType,
1000 std::map<std::string, std::string>& art);
1001 std::string GetArtForItem(int mediaId, const MediaType &mediaType, const std::string &artType);
1003 void UpdateArtForItem(int mediaId, const MediaType& mediaType);
1006 * \brief Retrieve all art for the given video asset, with optional fallback to the art of the
1007 * parent/owner of the asset
1008 * \param assetId id of the file of the asset
1009 * \param fallback optionally request fallback to the art of the parent/owner for each art type
1010 that is not defined for the asset
1011 * \param art collection of the retrieved art
1012 * \return
1014 bool GetArtForAsset(int assetId,
1015 ArtFallbackOptions fallback,
1016 std::map<std::string, std::string>& art);
1017 bool HasArtForItem(int mediaId, const MediaType &mediaType);
1018 bool RemoveArtForItem(int mediaId, const MediaType &mediaType, const std::string &artType);
1019 bool RemoveArtForItem(int mediaId, const MediaType &mediaType, const std::set<std::string> &artTypes);
1020 bool GetTvShowSeasons(int showId, std::map<int, int> &seasons);
1021 bool GetTvShowNamedSeasons(int showId, std::map<int, std::string> &seasons);
1024 * \brief Get the custom named season.
1025 * \param tvshowId The tv show id relative to the season.
1026 * \param seasonId The season id for which to search the named title.
1027 * \return The named title if found, otherwise empty.
1029 std::string GetTvShowNamedSeasonById(int tvshowId, int seasonId);
1031 bool GetTvShowSeasonArt(int mediaId, std::map<int, std::map<std::string, std::string> > &seasonArt);
1032 bool GetArtTypes(const MediaType &mediaType, std::vector<std::string> &artTypes);
1034 /*! \brief Fetch the distinct types of available-but-unassigned art held in the
1035 database for a specific media item.
1036 \param mediaId the id in the media table.
1037 \param mediaType the type of media, which corresponds to the table the item resides in.
1038 \return the types of art e.g. "thumb", "fanart", etc.
1040 std::vector<std::string> GetAvailableArtTypesForItem(int mediaId, const MediaType& mediaType);
1042 /*! \brief Fetch the list of available-but-unassigned art URLs held in the
1043 database for a specific media item and art type.
1044 \param mediaId the id in the media table.
1045 \param mediaType corresponds to the table the item resides in.
1046 \param artType e.g. "thumb", "fanart", etc.
1047 \return list of URLs
1049 std::vector<CScraperUrl::SUrlEntry> GetAvailableArtForItem(
1050 int mediaId, const MediaType& mediaType, const std::string& artType);
1052 int AddTag(const std::string &tag);
1053 void AddTagToItem(int idItem, int idTag, const std::string &type);
1054 void RemoveTagFromItem(int idItem, int idTag, const std::string &type);
1055 void RemoveTagsFromItem(int idItem, const std::string &type);
1057 bool GetFilter(CDbUrl &videoUrl, Filter &filter, SortDescription &sorting) override;
1059 /*! \brief Will check if the season exists and if that is not the case add it to the database.
1060 \param showID The id of the show in question.
1061 \param season The season number we want to add.
1062 \return The dbId of the season.
1064 int AddSeason(int showID, int season, const std::string& name = "");
1065 int AddSet(const std::string& strSet,
1066 const std::string& strOverview = "",
1067 const bool updateOverview = true);
1068 void ClearMovieSet(int idMovie);
1069 void SetMovieSet(int idMovie, int idSet);
1070 bool SetVideoUserRating(int dbId, int rating, const MediaType& mediaType);
1071 bool GetUseAllExternalAudioForVideo(const std::string& videoPath);
1073 std::string GetSetByNameLike(const std::string& nameLike) const;
1075 std::string GetVideoItemTitle(VideoDbContentType itemType, int dbId);
1076 std::string GetVideoVersionById(int id);
1077 void GetVideoVersions(VideoDbContentType itemType,
1078 int dbId,
1079 CFileItemList& items,
1080 VideoAssetType videoAssetType);
1081 void GetDefaultVideoVersion(VideoDbContentType itemType, int dbId, CFileItem& item);
1084 * \brief Remove a video from the library and transfer all of its assets to another video of the
1085 * same type.
1086 * \param itemType Type of the video being converted
1087 * \param dbIdSource id of the video being converted
1088 * \param dbIdTarget id that the video will be attached to
1089 * \param idVideoVersion new versiontype of the default version of the video
1090 * \param assetType new asset type of the default version of the video
1091 * \return true for success, false otherwise
1093 bool ConvertVideoToVersion(VideoDbContentType itemType,
1094 int dbIdSource,
1095 int dbIdTarget,
1096 int idVideoVersion,
1097 VideoAssetType assetType);
1098 void SetDefaultVideoVersion(VideoDbContentType itemType, int dbId, int idFile);
1099 void SetVideoVersion(int idFile, int idVideoVersion);
1100 int AddVideoVersionType(const std::string& typeVideoVersion,
1101 VideoAssetTypeOwner owner,
1102 VideoAssetType assetType);
1104 * \brief Create a new video asset from the provided item and type and attach it to an owner
1105 * A file record is created for items with a path new to the database.
1106 * \param[in] itemType Parent's type
1107 * \param[in] dbId Parent's id
1108 * \param[in] idVideoAsset Video asset identifier / name
1109 * \param[in] videoAssetType Type of the video asset
1110 * \param[in] item Item to be made into a video asset
1111 * \return Success status. true:success, false:failure
1113 bool AddVideoAsset(VideoDbContentType itemType,
1114 int dbId,
1115 int idVideoAsset,
1116 VideoAssetType videoAssetType,
1117 CFileItem& item);
1118 bool DeleteVideoAsset(int idFile);
1119 bool IsDefaultVideoVersion(int idFile);
1120 bool GetVideoVersionTypes(VideoDbContentType idContent,
1121 VideoAssetType asset,
1122 CFileItemList& items);
1123 bool SetVideoVersionDefaultArt(int dbId, int idFrom, VideoDbContentType type);
1124 void InitializeVideoVersionTypeTable(int schemaVersion);
1125 void UpdateVideoVersionTypeTable();
1126 bool GetVideoVersionsNav(const std::string& strBaseDir,
1127 CFileItemList& items,
1128 VideoDbContentType idContent = VideoDbContentType::UNKNOWN,
1129 const Filter& filter = Filter());
1130 VideoAssetInfo GetVideoVersionInfo(const std::string& filenameAndPath);
1131 bool GetAssetsForVideo(VideoDbContentType itemType,
1132 int mediaId,
1133 VideoAssetType assetType,
1134 CFileItemList& items);
1135 bool GetDefaultVersionForVideo(VideoDbContentType itemType, int mediaId, CFileItem& item);
1136 bool UpdateAssetsOwner(const std::string& mediaType, int dbIdSource, int dbIdTarget);
1138 int GetMovieId(const std::string& strFilenameAndPath);
1139 std::string GetMovieTitle(int idMovie);
1140 void GetSameVideoItems(const CFileItem& item, CFileItemList& items);
1141 int GetFileIdByMovie(int idMovie);
1142 std::string GetFileBasePathById(int idFile);
1145 * @brief Check the passed in list of images if used in this database. Used to clean the image cache.
1146 * @param imagesToCheck
1147 * @return a list of the passed in images used by this database.
1149 std::vector<std::string> GetUsedImages(const std::vector<std::string>& imagesToCheck);
1151 protected:
1152 int AddNewMovie(CVideoInfoTag& details);
1153 int AddNewMusicVideo(CVideoInfoTag& details);
1155 int GetMusicVideoId(const std::string& strFilenameAndPath);
1157 /*! \brief Get the id of this fileitem
1158 Works for both videodb:// items and normal fileitems
1159 \param item CFileItem to grab the fileid of
1160 \return id of the file, -1 if it is not in the db.
1162 int GetFileId(const CFileItem &item);
1163 int GetFileId(const CVideoInfoTag& details);
1165 /*! \brief Get the id of the file of this item and store it in the item
1166 \param details CVideoInfoTag for which to get and store the id of the file
1167 \return id of the file, -1 if it is not in the db.
1169 int GetAndFillFileId(CVideoInfoTag& details);
1171 /*! \brief Get the id of a file from path
1172 \param url full path to the file
1173 \return id of the file, -1 if it is not in the db.
1175 int GetFileId(const std::string& url);
1177 int AddToTable(const std::string& table, const std::string& firstField, const std::string& secondField, const std::string& value);
1178 int UpdateRatings(int mediaId, const char *mediaType, const RatingMap& values, const std::string& defaultRating);
1179 int AddRatings(int mediaId, const char *mediaType, const RatingMap& values, const std::string& defaultRating);
1180 int UpdateUniqueIDs(int mediaId, const char *mediaType, const CVideoInfoTag& details);
1181 int AddUniqueIDs(int mediaId, const char *mediaType, const CVideoInfoTag& details);
1182 int AddActor(const std::string& strActor, const std::string& thumbURL, const std::string &thumb = "");
1184 int AddTvShow();
1186 /*! \brief Adds a path to the tvshow link table.
1187 \param idShow the id of the show.
1188 \param path the path to add.
1189 \param parentPath the parent path of the path to add.
1190 \param dateAdded date/time when the path was added
1191 \return true if successfully added, false otherwise.
1193 bool AddPathToTvShow(int idShow, const std::string &path, const std::string &parentPath, const CDateTime& dateAdded = CDateTime());
1195 /*! \brief Check whether a show is already in the library.
1196 Matches on unique identifier or matching title and premiered date.
1197 \param show the details of the show to check for.
1198 \return the show id if found, else -1.
1200 int GetMatchingTvShow(const CVideoInfoTag &show);
1202 // link functions - these two do all the work
1203 void AddLinkToActor(int mediaId, const char *mediaType, int actorId, const std::string &role, int order);
1204 void AddToLinkTable(int mediaId, const std::string& mediaType, const std::string& table, int valueId, const char *foreignKey = NULL);
1205 void RemoveFromLinkTable(int mediaId, const std::string& mediaType, const std::string& table, int valueId, const char *foreignKey = NULL);
1207 void AddLinksToItem(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values);
1208 void UpdateLinksToItem(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values);
1209 void AddActorLinksToItem(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values);
1210 void UpdateActorLinksToItem(int mediaId, const std::string& mediaType, const std::string& field, const std::vector<std::string>& values);
1212 void AddCast(int mediaId, const char *mediaType, const std::vector<SActorInfo> &cast);
1214 CVideoInfoTag GetDetailsForMovie(std::unique_ptr<dbiplus::Dataset> &pDS, int getDetails = VideoDbDetailsNone);
1215 CVideoInfoTag GetDetailsForMovie(const dbiplus::sql_record* const record, int getDetails = VideoDbDetailsNone);
1216 CVideoInfoTag GetDetailsForTvShow(std::unique_ptr<dbiplus::Dataset> &pDS, int getDetails = VideoDbDetailsNone, CFileItem* item = NULL);
1217 CVideoInfoTag GetDetailsForTvShow(const dbiplus::sql_record* const record, int getDetails = VideoDbDetailsNone, CFileItem* item = NULL);
1218 CVideoInfoTag GetBasicDetailsForEpisode(std::unique_ptr<dbiplus::Dataset> &pDS);
1219 CVideoInfoTag GetBasicDetailsForEpisode(const dbiplus::sql_record* const record);
1220 CVideoInfoTag GetDetailsForEpisode(std::unique_ptr<dbiplus::Dataset> &pDS, int getDetails = VideoDbDetailsNone);
1221 CVideoInfoTag GetDetailsForEpisode(const dbiplus::sql_record* const record, int getDetails = VideoDbDetailsNone);
1222 CVideoInfoTag GetDetailsForMusicVideo(std::unique_ptr<dbiplus::Dataset> &pDS, int getDetails = VideoDbDetailsNone);
1223 CVideoInfoTag GetDetailsForMusicVideo(const dbiplus::sql_record* const record, int getDetails = VideoDbDetailsNone);
1224 bool GetPeopleNav(const std::string& strBaseDir,
1225 CFileItemList& items,
1226 const char* type,
1227 VideoDbContentType idContent = VideoDbContentType::UNKNOWN,
1228 const Filter& filter = Filter(),
1229 bool countOnly = false);
1230 bool GetNavCommon(const std::string& strBaseDir,
1231 CFileItemList& items,
1232 const char* type,
1233 VideoDbContentType idContent = VideoDbContentType::UNKNOWN,
1234 const Filter& filter = Filter(),
1235 bool countOnly = false);
1236 void GetCast(int media_id, const std::string &media_type, std::vector<SActorInfo> &cast);
1237 void GetTags(int media_id, const std::string &media_type, std::vector<std::string> &tags);
1238 void GetRatings(int media_id, const std::string &media_type, RatingMap &ratings);
1239 void GetUniqueIDs(int media_id, const std::string &media_type, CVideoInfoTag& details);
1241 void GetDetailsFromDB(std::unique_ptr<dbiplus::Dataset> &pDS, int min, int max, const SDbTableOffsets *offsets, CVideoInfoTag &details, int idxOffset = 2);
1242 void GetDetailsFromDB(const dbiplus::sql_record* const record, int min, int max, const SDbTableOffsets *offsets, CVideoInfoTag &details, int idxOffset = 2);
1243 std::string GetValueString(const CVideoInfoTag &details, int min, int max, const SDbTableOffsets *offsets) const;
1245 private:
1246 void CreateTables() override;
1247 void CreateAnalytics() override;
1248 void UpdateTables(int version) override;
1249 void CreateLinkIndex(const char *table);
1250 void CreateForeignLinkIndex(const char *table, const char *foreignkey);
1252 /*! \brief (Re)Create the generic database views for movies, tvshows,
1253 episodes and music videos
1255 virtual void CreateViews();
1257 /*! \brief Helper to get a database id given a query.
1258 Returns an integer, -1 if not found, and greater than 0 if found.
1259 \param query the SQL that will retrieve a database id.
1260 \return -1 if not found, else a valid database id (i.e. > 0)
1262 int GetDbId(const std::string &query);
1264 /*! \brief Run a query on the main dataset and return the number of rows
1265 If no rows are found we close the dataset and return 0.
1266 \param sql the sql query to run
1267 \return the number of rows, -1 for an error.
1269 int RunQuery(const std::string &sql);
1271 void AppendIdLinkFilter(const char* field, const char *table, const MediaType& mediaType, const char *view, const char *viewKey, const CUrlOptions::UrlOptions& options, Filter &filter);
1272 void AppendLinkFilter(const char* field, const char *table, const MediaType& mediaType, const char *view, const char *viewKey, const CUrlOptions::UrlOptions& options, Filter &filter);
1274 /*! \brief Determine whether the path is using lookup using folders
1275 \param path the path to check
1276 \param shows whether this path is from a tvshow (defaults to false)
1278 bool LookupByFolders(const std::string &path, bool shows = false);
1280 /*! \brief Get the playcount for a file id
1281 \param iFileId file id to get the playcount for
1282 \return the playcount of the item, or -1 on error
1283 \sa SetPlayCount, IncrementPlayCount, GetPlayCounts
1285 int GetPlayCount(int iFileId);
1287 /*! \brief Get the last played time of a filename and path
1288 \param iFileId file id to get the playcount for
1289 \return the last played time of the item, or an invalid CDateTime on error
1290 \sa UpdateLastPlayed
1292 CDateTime GetLastPlayed(int iFileId);
1294 bool GetSeasonInfo(int idSeason, CVideoInfoTag& details, bool allDetails, CFileItem* item);
1296 int GetMinSchemaVersion() const override { return 75; }
1297 int GetSchemaVersion() const override;
1298 virtual int GetExportVersion() const { return 1; }
1299 const char* GetBaseDBName() const override { return "MyVideos"; }
1301 void ConstructPath(std::string& strDest, const std::string& strPath, const std::string& strFileName);
1302 void SplitPath(const std::string& strFileNameAndPath, std::string& strPath, std::string& strFileName);
1303 void InvalidatePathHash(const std::string& strPath);
1305 /*! \brief Get a safe filename from a given string
1306 \param dir directory to use for the file
1307 \param name movie, show name, or actor to get a safe filename for
1308 \return safe filename based on this title
1310 std::string GetSafeFile(const std::string &dir, const std::string &name) const;
1312 std::vector<int> CleanMediaType(const std::string &mediaType, const std::string &cleanableFileIDs,
1313 std::map<int, bool> &pathsDeleteDecisions, std::string &deletedFileIDs, bool silent);
1315 static void AnnounceRemove(const std::string& content, int id, bool scanning = false);
1316 static void AnnounceUpdate(const std::string& content, int id);
1318 static CDateTime GetDateAdded(const std::string& filename, CDateTime dateAdded = CDateTime());
1320 bool FillMovieItem(std::unique_ptr<dbiplus::Dataset>& dataset, int movieId, CFileItem& item);