MythTV  master
videometadata.h
Go to the documentation of this file.
1 #ifndef VIDEOMETADATA_H_
2 #define VIDEOMETADATA_H_
3 
4 #include <utility> // for std::pair
5 #include <vector>
6 
7 #include <QString>
8 #include <QDate>
9 #include <QCoreApplication>
10 
11 #include "parentalcontrols.h"
12 #include "mythmetaexp.h"
13 #include "metadatacommon.h"
14 
15 class MSqlQuery;
17 
18 enum { VIDEO_YEAR_DEFAULT = 1895 };
19 
20 const QString VIDEO_SUBTITLE_DEFAULT = "";
21 
22 using MetadataMap = QHash<QString,QString>;
23 
25 {
26  Q_DECLARE_TR_FUNCTIONS(VideoMetadata);
27 
28  public:
29  using genre_entry = std::pair<int, QString>;
30  using country_entry = std::pair<int, QString>;
31  using cast_entry = std::pair<int, QString>;
32  using genre_list = std::vector<genre_entry>;
33  using country_list = std::vector<country_entry>;
34  using cast_list = std::vector<cast_entry>;
35 
36  public:
37  static int UpdateHashedDBRecord(const QString &hash, const QString &file_name,
38  const QString &host);
39  static QString VideoFileHash(const QString &file_name, const QString &host);
40  static QString FilenameToMeta(const QString &file_name, int position);
41  static QString TrimTitle(const QString &title, bool ignore_case);
42 
43  public:
44  explicit VideoMetadata(const QString &filename = QString(),
45  const QString &sortFilename = QString(),
46  const QString &hash = QString(),
47  const QString &trailer = QString(),
48  const QString &coverfile = QString(),
49  const QString &screenshot = QString(),
50  const QString &banner = QString(),
51  const QString &fanart = QString(),
52  const QString &title = QString(),
53  const QString &sortTitle = QString(),
54  const QString &subtitle = QString(),
55  const QString &sortSubtitle = QString(),
56  const QString &tagline = QString(),
57  int year = VIDEO_YEAR_DEFAULT,
58  QDate releasedate = QDate(),
59  const QString &inetref = QString(),
60  int collectionref = 0,
61  const QString &homepage = QString(),
62  const QString &director = QString(),
63  const QString &studio = QString(),
64  const QString &plot = QString(),
65  float userrating = 0.0,
66  const QString &rating = QString(),
67  int length = 0,
68  int playcount = 0,
69  int season = 0,
70  int episode = 0,
71  QDate insertdate = QDate(),
72  int id = 0,
74  int categoryID = 0,
75  int childID = -1,
76  bool browse = true,
77  bool watched = false,
78  const QString &playcommand = QString(),
79  const QString &category = QString(),
80  const genre_list &genres = genre_list(),
81  const country_list &countries = country_list(),
82  const cast_list &cast = cast_list(),
83  const QString &host = "",
84  bool processed = false,
85  VideoContentType contenttype = kContentUnknown);
86  ~VideoMetadata();
87  explicit VideoMetadata(MSqlQuery &query);
88  VideoMetadata(const VideoMetadata &rhs);
89  VideoMetadata &operator=(const VideoMetadata &rhs);
90  bool sortBefore(const VideoMetadata &rhs) const;
91 
92  void toMap(InfoMap &metadataMap);
93  QString GetText(const QString& name) const;
94  void GetStateMap(InfoMap &stateMap) const;
95  QString GetState(const QString& name) const;
96  void GetImageMap(InfoMap &imageMap);
97  QString GetImage(const QString& name) const;
98 
99  static QString MetadataGetTextCb(const QString& name, void *data);
100  static QString MetadataGetImageCb(const QString& name, void *data);
101  static QString MetadataGetStateCb(const QString& name, void *data);
102 
103  const QString &GetPrefix() const;
104  void SetPrefix(const QString &prefix);
105 
106  const QString &GetTitle() const;
107  const QString &GetSortTitle() const;
108  void SetTitle(const QString& title, const QString& sortTitle = "");
109 
110  const QString &GetSubtitle() const;
111  const QString &GetSortSubtitle() const;
112  void SetSubtitle(const QString &subtitle, const QString &sortSubtitle = "");
113 
114  const QString &GetTagline() const;
115  void SetTagline(const QString &tagline);
116 
117  int GetYear() const;
118  void SetYear(int year);
119 
120  QDate GetReleaseDate() const;
121  void SetReleaseDate(QDate releasedate);
122 
123  const QString &GetInetRef() const;
124  void SetInetRef(const QString &inetRef);
125 
126  int GetCollectionRef() const;
127  void SetCollectionRef(int collectionref);
128 
129  const QString &GetHomepage() const;
130  void SetHomepage(const QString &homepage);
131 
132  const QString &GetDirector() const;
133  void SetDirector(const QString &director);
134 
135  const QString &GetStudio() const;
136  void SetStudio(const QString &studio);
137 
138  const QString &GetPlot() const;
139  void SetPlot(const QString &plot);
140 
141  float GetUserRating() const;
142  void SetUserRating(float userRating);
143 
144  const QString &GetRating() const;
145  void SetRating(const QString &rating);
146 
147  std::chrono::minutes GetLength() const;
148  void SetLength(std::chrono::minutes length);
149 
150  int GetSeason() const;
151  void SetSeason(int season);
152 
153  int GetEpisode() const;
154  void SetEpisode(int episode);
155 
156  QDate GetInsertdate() const;
157  void SetInsertdate(QDate date);
158 
159  unsigned int GetID() const;
160  void SetID(int id);
161 
162  int GetChildID() const;
163  void SetChildID(int childID);
164 
165  bool GetBrowse() const;
166  void SetBrowse(bool browse);
167 
168  bool GetWatched() const;
169  void SetWatched(bool watched);
170 
171  bool GetProcessed() const;
172  void SetProcessed(bool processed);
173 
174  VideoContentType GetContentType() const;
175  void SetContentType(VideoContentType contenttype);
176 
177  const QString &GetPlayCommand() const;
178  void SetPlayCommand(const QString &playCommand);
179 
180  unsigned int GetPlayCount() const;
181  void SetPlayCount(int count);
182 
183  ParentalLevel::Level GetShowLevel() const;
184  void SetShowLevel(ParentalLevel::Level showLevel);
185 
186  const QString &GetHost() const;
187  void SetHost(const QString &host);
188 
189  const QString &GetFilename() const;
190  const QString &GetSortFilename() const;
191  void SetFilename(const QString &filename, const QString &sortFilename = "");
192 
193  const QString &GetHash() const;
194  void SetHash(const QString &hash);
195 
196  const QString &GetTrailer() const;
197  void SetTrailer(const QString &trailer);
198 
199  const QString &GetCoverFile() const;
200  void SetCoverFile(const QString &coverFile);
201 
202  const QString &GetScreenshot() const;
203  void SetScreenshot(const QString &screenshot);
204 
205  const QString &GetBanner() const;
206  void SetBanner(const QString &banner);
207 
208  const QString &GetFanart() const;
209  void SetFanart(const QString &fanart);
210 
211  const QString &GetCategory() const;
212 
213  const genre_list &GetGenres() const;
214  void SetGenres(const genre_list &genres);
215 
216  const cast_list &GetCast() const;
217  void SetCast(const cast_list &cast);
218 
219  const country_list &GetCountries() const;
220  void SetCountries(const country_list &countries);
221 
222  int GetCategoryID() const;
223  void SetCategoryID(int id);
224 
225  void SaveToDatabase();
226  void UpdateDatabase();
227  // drops the metadata from the DB
228  bool DeleteFromDatabase();
229 
230 // bool fillDataFromID(const VideoMetadataListManager &cache);
231  bool FillDataFromFilename(const VideoMetadataListManager &cache);
232 
233  // If you aren't VideoList don't call this
234  bool DeleteFile();
235 
237  void Reset();
238 
239  bool IsHostSet() const;
240 
241  private:
243 };
244 
245 META_PUBLIC void ClearMap(InfoMap &metadataMap);
246 
247 META_PUBLIC bool operator==(const VideoMetadata &a, const VideoMetadata &b);
248 META_PUBLIC bool operator!=(const VideoMetadata &a, const VideoMetadata &b);
249 
251 
252 #endif
MSqlQuery
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:125
VideoMetadata
Definition: videometadata.h:24
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(GrabberScript *)
ParentalLevel::plLowest
@ plLowest
Definition: parentalcontrols.h:12
VideoMetadataListManager
Definition: videometadatalistmanager.h:10
parentalcontrols.h
VideoMetadata::country_list
std::vector< country_entry > country_list
Definition: videometadata.h:33
VideoMetadata::cast_entry
std::pair< int, QString > cast_entry
Definition: videometadata.h:31
operator==
META_PUBLIC bool operator==(const VideoMetadata &a, const VideoMetadata &b)
Definition: videometadata.cpp:2015
VideoMetadata::genre_list
std::vector< genre_entry > genre_list
Definition: videometadata.h:32
mythmetaexp.h
VIDEO_SUBTITLE_DEFAULT
const QString VIDEO_SUBTITLE_DEFAULT
Definition: videometadata.h:20
hardwareprofile.distros.mythtv_data.data_mythtv.prefix
string prefix
Definition: data_mythtv.py:40
InfoMap
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
SetLength
static uint8_t * SetLength(uint8_t *Data, int Length)
Definition: dvbci.cpp:117
operator!=
META_PUBLIC bool operator!=(const VideoMetadata &a, const VideoMetadata &b)
Definition: videometadata.cpp:2020
ParentalLevel::Level
Level
Definition: parentalcontrols.h:12
ClearMap
META_PUBLIC void ClearMap(InfoMap &metadataMap)
Definition: videometadata.cpp:1458
hardwareprofile.scan.rating
def rating(profile, smoonURL, gate)
Definition: scan.py:39
MetadataMap
QHash< QString, QString > MetadataMap
Definition: videometadata.h:22
GetState
#define GetState(a, b)
Definition: audiooutputopensles.cpp:47
VideoContentType
VideoContentType
Definition: metadatacommon.h:60
VideoMetadata::genre_entry
std::pair< int, QString > genre_entry
Definition: videometadata.h:29
VideoMetadata::cast_list
std::vector< cast_entry > cast_list
Definition: videometadata.h:34
VideoMetadataImp
Definition: videometadata.cpp:28
VIDEO_YEAR_DEFAULT
@ VIDEO_YEAR_DEFAULT
Definition: videometadata.h:18
VideoMetadata::m_imp
class VideoMetadataImp * m_imp
Definition: videometadata.h:242
GetLength
static const uint8_t * GetLength(const uint8_t *Data, int &Length)
Definition: dvbci.cpp:95
kContentUnknown
@ kContentUnknown
Definition: metadatacommon.h:66
build_compdb.filename
filename
Definition: build_compdb.py:21
VideoMetadata::country_entry
std::pair< int, QString > country_entry
Definition: videometadata.h:30
META_PUBLIC
#define META_PUBLIC
Definition: mythmetaexp.h:9
metadatacommon.h