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  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  const 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  const 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  void GetStateMap(InfoMap &stateMap);
94  void GetImageMap(InfoMap &imageMap);
95 
96  const QString &GetPrefix() const;
97  void SetPrefix(const QString &prefix);
98 
99  const QString &GetTitle() const;
100  const QString &GetSortTitle() const;
101  void SetTitle(const QString& title, const QString& sortTitle = "");
102 
103  const QString &GetSubtitle() const;
104  const QString &GetSortSubtitle() const;
105  void SetSubtitle(const QString &subtitle, const QString &sortSubtitle = "");
106 
107  const QString &GetTagline() const;
108  void SetTagline(const QString &tagline);
109 
110  int GetYear() const;
111  void SetYear(int year);
112 
113  QDate GetReleaseDate() const;
114  void SetReleaseDate(QDate releasedate);
115 
116  const QString &GetInetRef() const;
117  void SetInetRef(const QString &inetRef);
118 
119  int GetCollectionRef() const;
120  void SetCollectionRef(int collectionref);
121 
122  const QString &GetHomepage() const;
123  void SetHomepage(const QString &homepage);
124 
125  const QString &GetDirector() const;
126  void SetDirector(const QString &director);
127 
128  const QString &GetStudio() const;
129  void SetStudio(const QString &studio);
130 
131  const QString &GetPlot() const;
132  void SetPlot(const QString &plot);
133 
134  float GetUserRating() const;
135  void SetUserRating(float userRating);
136 
137  const QString &GetRating() const;
138  void SetRating(const QString &rating);
139 
140  int GetLength() const;
141  void SetLength(int length);
142 
143  int GetSeason() const;
144  void SetSeason(int season);
145 
146  int GetEpisode() const;
147  void SetEpisode(int episode);
148 
149  QDate GetInsertdate() const;
150  void SetInsertdate(QDate date);
151 
152  unsigned int GetID() const;
153  void SetID(int id);
154 
155  int GetChildID() const;
156  void SetChildID(int childID);
157 
158  bool GetBrowse() const;
159  void SetBrowse(bool browse);
160 
161  bool GetWatched() const;
162  void SetWatched(bool watched);
163 
164  bool GetProcessed() const;
165  void SetProcessed(bool processed);
166 
167  VideoContentType GetContentType() const;
168  void SetContentType(VideoContentType contenttype);
169 
170  const QString &GetPlayCommand() const;
171  void SetPlayCommand(const QString &playCommand);
172 
173  unsigned int GetPlayCount() const;
174  void SetPlayCount(int count);
175 
176  ParentalLevel::Level GetShowLevel() const;
177  void SetShowLevel(ParentalLevel::Level showLevel);
178 
179  const QString &GetHost() const;
180  void SetHost(const QString &host);
181 
182  const QString &GetFilename() const;
183  const QString &GetSortFilename() const;
184  void SetFilename(const QString &filename, const QString &sortFilename = "");
185 
186  const QString &GetHash() const;
187  void SetHash(const QString &hash);
188 
189  const QString &GetTrailer() const;
190  void SetTrailer(const QString &trailer);
191 
192  const QString &GetCoverFile() const;
193  void SetCoverFile(const QString &coverFile);
194 
195  const QString &GetScreenshot() const;
196  void SetScreenshot(const QString &screenshot);
197 
198  const QString &GetBanner() const;
199  void SetBanner(const QString &banner);
200 
201  const QString &GetFanart() const;
202  void SetFanart(const QString &fanart);
203 
204  const QString &GetCategory() const;
205 
206  const genre_list &GetGenres() const;
207  void SetGenres(const genre_list &genres);
208 
209  const cast_list &GetCast() const;
210  void SetCast(const cast_list &cast);
211 
212  const country_list &GetCountries() const;
213  void SetCountries(const country_list &countries);
214 
215  int GetCategoryID() const;
216  void SetCategoryID(int id);
217 
218  void SaveToDatabase();
219  void UpdateDatabase();
220  // drops the metadata from the DB
221  bool DeleteFromDatabase();
222 
223 // bool fillDataFromID(const VideoMetadataListManager &cache);
224  bool FillDataFromFilename(const VideoMetadataListManager &cache);
225 
226  // If you aren't VideoList don't call this
227  bool DeleteFile();
228 
230  void Reset();
231 
232  bool IsHostSet() const;
233 
234  private:
236 };
237 
238 META_PUBLIC void ClearMap(InfoMap &metadataMap);
239 
240 META_PUBLIC bool operator==(const VideoMetadata &a, const VideoMetadata &b);
241 META_PUBLIC bool operator!=(const VideoMetadata &a, const VideoMetadata &b);
242 
244 
245 #endif
QHash< QString, QString > InfoMap
Definition: mythtypes.h:15
std::vector< country_entry > country_list
Definition: videometadata.h:33
class VideoMetadataImp * m_imp
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:125
std::pair< int, QString > genre_entry
Definition: videometadata.h:29
const QString VIDEO_SUBTITLE_DEFAULT
Definition: videometadata.h:20
std::vector< cast_entry > cast_list
Definition: videometadata.h:34
META_PUBLIC bool operator==(const VideoMetadata &a, const VideoMetadata &b)
std::pair< int, QString > cast_entry
Definition: videometadata.h:31
Q_DECLARE_METATYPE(GrabberScript *)
META_PUBLIC bool operator!=(const VideoMetadata &a, const VideoMetadata &b)
def rating(profile, smoonURL, gate)
Definition: scan.py:39
QHash< QString, QString > MetadataMap
Definition: videometadata.h:22
#define META_PUBLIC
Definition: mythmetaexp.h:9
META_PUBLIC void ClearMap(InfoMap &metadataMap)
static uint8_t * SetLength(uint8_t *Data, int Length)
Definition: dvbci.cpp:117
std::vector< genre_entry > genre_list
Definition: videometadata.h:32
static const uint8_t * GetLength(const uint8_t *Data, int &Length)
Definition: dvbci.cpp:95
VideoContentType
std::pair< int, QString > country_entry
Definition: videometadata.h:30