MythTV  master
video.h
Go to the documentation of this file.
1 // Program Name: video.h
3 // Created : Apr. 21, 2011
4 //
5 // Copyright (c) 2011 Robert McNamara <rmcnamara@mythtv.org>
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //
25 
26 #ifndef VIDEO_H
27 #define VIDEO_H
28 
29 #include <QScriptEngine>
30 
32 
33 #include "services/videoServices.h"
34 
35 class Video : public VideoServices
36 {
37  Q_OBJECT
38 
39  public:
40 
41  Q_INVOKABLE explicit Video( QObject */*parent*/ = nullptr ) {}
42 
43  public:
44 
45  /* Video Metadata Methods */
46 
47  DTC::VideoMetadataInfoList* GetVideoList ( const QString &Folder,
48  const QString &Sort,
49  bool Descending,
50  int StartIndex,
51  int Count ) override; // VideoServices
52 
53  DTC::VideoMetadataInfo* GetVideo ( int Id ) override; // VideoServices
54 
55  DTC::VideoMetadataInfo* GetVideoByFileName ( const QString &FileName ) override; // VideoServices
56 
57  DTC::VideoLookupList* LookupVideo ( const QString &Title,
58  const QString &Subtitle,
59  const QString &Inetref,
60  int Season,
61  int Episode,
62  const QString &GrabberType,
63  bool AllowGeneric ) override; // VideoServices
64 
65  bool RemoveVideoFromDB ( int Id ) override; // VideoServices
66 
67  bool AddVideo ( const QString &FileName,
68  const QString &HostName ) override; // VideoServices
69 
70  bool UpdateVideoWatchedStatus ( int Id,
71  bool Watched ) override; // VideoServices
72 
73  bool UpdateVideoMetadata ( int Id,
74  const QString &Title,
75  const QString &SubTitle,
76  const QString &TagLine,
77  const QString &Director,
78  const QString &Studio,
79  const QString &Plot,
80  const QString &Rating,
81  const QString &Inetref,
82  int CollectionRef,
83  const QString &HomePage,
84  int Year,
85  const QDate &ReleaseDate,
86  float UserRating,
87  int Length,
88  int PlayCount,
89  int Season,
90  int Episode,
91  int ShowLevel,
92  const QString &FileName,
93  const QString &Hash,
94  const QString &CoverFile,
95  int ChildID,
96  bool Browse,
97  bool Watched,
98  bool Processed,
99  const QString &PlayCommand,
100  int Category,
101  const QString &Trailer,
102  const QString &Host,
103  const QString &Screenshot,
104  const QString &Banner,
105  const QString &Fanart,
106  const QDate &InsertDate,
107  const QString &ContentType,
108  const QString &Genres,
109  const QString &Cast,
110  const QString &Countries
111  ) override; // VideoServices
112 
113  /* Bluray Methods */
114 
115  DTC::BlurayInfo* GetBluray ( const QString &Path ) override; // VideoServices
116 
117 };
118 
119 // --------------------------------------------------------------------------
120 // The following class wrapper is due to a limitation in Qt Script Engine. It
121 // requires all methods that return pointers to user classes that are derived from
122 // QObject actually return QObject* (not the user class *). If the user class pointer
123 // is returned, the script engine treats it as a QVariant and doesn't create a
124 // javascript prototype wrapper for it.
125 //
126 // This class allows us to keep the rich return types in the main API class while
127 // offering the script engine a class it can work with.
128 //
129 // Only API Classes that return custom classes needs to implement these wrappers.
130 //
131 // We should continue to look for a cleaning solution to this problem.
132 // --------------------------------------------------------------------------
133 
134 class ScriptableVideo : public QObject
135 {
136  Q_OBJECT
137 
138  private:
139 
141  QScriptEngine *m_pEngine;
142 
143  public:
144 
145  Q_INVOKABLE ScriptableVideo( QScriptEngine *pEngine, QObject *parent = nullptr ) : QObject( parent )
146  {
147  m_pEngine = pEngine;
148  }
149 
150  public slots:
151 
152  QObject* GetVideoList( const QString &Folder,
153  const QString &Sort,
154  bool Descending,
155  int StartIndex,
156  int Count )
157  {
158  SCRIPT_CATCH_EXCEPTION( nullptr,
159  return m_obj.GetVideoList( Folder, Sort, Descending,
160  StartIndex, Count );
161  )
162  }
163 
164  QObject* GetVideo( int Id )
165  {
166  SCRIPT_CATCH_EXCEPTION( nullptr,
167  return m_obj.GetVideo( Id );
168  )
169  }
170 
171  QObject* GetVideoByFileName( const QString &FileName )
172  {
173  SCRIPT_CATCH_EXCEPTION( nullptr,
174  return m_obj.GetVideoByFileName( FileName );
175  )
176  }
177 
178  QObject* LookupVideo( const QString &Title,
179  const QString &Subtitle,
180  const QString &Inetref,
181  int Season,
182  int Episode,
183  const QString &GrabberType,
184  bool AllowGeneric )
185  {
186  SCRIPT_CATCH_EXCEPTION( nullptr,
187  return m_obj.LookupVideo( Title, Subtitle, Inetref,
188  Season, Episode, GrabberType,
189  AllowGeneric );
190  )
191  }
192 
193  bool RemoveVideoFromDB( int Id )
194  {
195  SCRIPT_CATCH_EXCEPTION( false,
196  return m_obj.RemoveVideoFromDB( Id );
197  )
198  }
199 
200  bool AddVideo( const QString &FileName,
201  const QString &HostName )
202  {
203  SCRIPT_CATCH_EXCEPTION( false,
204  return m_obj.AddVideo( FileName, HostName );
205  )
206  }
207 
208  bool UpdateVideoMetadata( int Id,
209  const QString &Title,
210  const QString &SubTitle,
211  const QString &TagLine,
212  const QString &Director,
213  const QString &Studio,
214  const QString &Plot,
215  const QString &Rating,
216  const QString &Inetref,
217  int CollectionRef,
218  const QString &HomePage,
219  int Year,
220  const QDate &ReleaseDate,
221  float UserRating,
222  int Length,
223  int PlayCount,
224  int Season,
225  int Episode,
226  int ShowLevel,
227  const QString &FileName,
228  const QString &Hash,
229  const QString &CoverFile,
230  int ChildID,
231  bool Browse,
232  bool Watched,
233  bool Processed,
234  const QString &PlayCommand,
235  int Category,
236  const QString &Trailer,
237  const QString &Host,
238  const QString &Screenshot,
239  const QString &Banner,
240  const QString &Fanart,
241  const QDate &InsertDate,
242  const QString &ContentType,
243  const QString &Genres,
244  const QString &Cast,
245  const QString &Countries
246  )
247  {
248  SCRIPT_CATCH_EXCEPTION( false,
249  return m_obj.UpdateVideoMetadata( Id,
250  Title,
251  SubTitle,
252  TagLine,
253  Director,
254  Studio,
255  Plot,
256  Rating,
257  Inetref,
258  CollectionRef,
259  HomePage,
260  Year,
261  ReleaseDate,
262  UserRating,
263  Length,
264  PlayCount,
265  Season,
266  Episode,
267  ShowLevel,
268  FileName,
269  Hash,
270  CoverFile,
271  ChildID,
272  Browse,
273  Watched,
274  Processed,
275  PlayCommand,
276  Category,
277  Trailer,
278  Host,
279  Screenshot,
280  Banner,
281  Fanart,
282  InsertDate,
283  ContentType,
284  Genres,
285  Cast,
286  Countries);
287  )
288  }
289 };
290 
292 
293 #endif
bool AddVideo(const QString &FileName, const QString &HostName)
Definition: video.h:200
unsigned int slots[4]
Definition: element.c:38
bool UpdateVideoMetadata(int Id, const QString &Title, const QString &SubTitle, const QString &TagLine, const QString &Director, const QString &Studio, const QString &Plot, const QString &Rating, const QString &Inetref, int CollectionRef, const QString &HomePage, int Year, const QDate &ReleaseDate, float UserRating, int Length, int PlayCount, int Season, int Episode, int ShowLevel, const QString &FileName, const QString &Hash, const QString &CoverFile, int ChildID, bool Browse, bool Watched, bool Processed, const QString &PlayCommand, int Category, const QString &Trailer, const QString &Host, const QString &Screenshot, const QString &Banner, const QString &Fanart, const QDate &InsertDate, const QString &ContentType, const QString &Genres, const QString &Cast, const QString &Countries)
Definition: video.h:208
bool UpdateVideoMetadata(int Id, const QString &Title, const QString &SubTitle, const QString &TagLine, const QString &Director, const QString &Studio, const QString &Plot, const QString &Rating, const QString &Inetref, int CollectionRef, const QString &HomePage, int Year, const QDate &ReleaseDate, float UserRating, int Length, int PlayCount, int Season, int Episode, int ShowLevel, const QString &FileName, const QString &Hash, const QString &CoverFile, int ChildID, bool Browse, bool Watched, bool Processed, const QString &PlayCommand, int Category, const QString &Trailer, const QString &Host, const QString &Screenshot, const QString &Banner, const QString &Fanart, const QDate &InsertDate, const QString &ContentType, const QString &Genres, const QString &Cast, const QString &Countries) override
Definition: video.cpp:450
DTC::VideoMetadataInfoList * GetVideoList(const QString &Folder, const QString &Sort, bool Descending, int StartIndex, int Count) override
Definition: video.cpp:52
bool RemoveVideoFromDB(int Id)
Definition: video.h:193
GrabberType
DTC::VideoMetadataInfo * GetVideo(int Id) override
Definition: video.cpp:138
Q_SCRIPT_DECLARE_QMETAOBJECT_MYTHTV(ScriptableVideo, QObject *)
DTC::VideoMetadataInfo * GetVideoByFileName(const QString &FileName) override
Definition: video.cpp:157
#define SCRIPT_CATCH_EXCEPTION(default, code)
Definition: service.h:83
QObject * LookupVideo(const QString &Title, const QString &Subtitle, const QString &Inetref, int Season, int Episode, const QString &GrabberType, bool AllowGeneric)
Definition: video.h:178
QObject * GetVideoByFileName(const QString &FileName)
Definition: video.h:171
DTC::VideoLookupList * LookupVideo(const QString &Title, const QString &Subtitle, const QString &Inetref, int Season, int Episode, const QString &GrabberType, bool AllowGeneric) override
Definition: video.cpp:179
Definition: video.h:35
bool AddVideo(const QString &FileName, const QString &HostName) override
Definition: video.cpp:316
QScriptEngine * m_pEngine
Definition: video.h:141
bool UpdateVideoWatchedStatus(int Id, bool Watched) override
Definition: video.cpp:372
bool RemoveVideoFromDB(int Id) override
Definition: video.cpp:296
QObject * GetVideoList(const QString &Folder, const QString &Sort, bool Descending, int StartIndex, int Count)
Definition: video.h:152
Video m_obj
Definition: video.h:140
QObject * GetVideo(int Id)
Definition: video.h:164
DTC::BlurayInfo * GetBluray(const QString &Path) override
Definition: video.cpp:394
Q_INVOKABLE Video(QObject *=nullptr)
Definition: video.h:41
Q_INVOKABLE ScriptableVideo(QScriptEngine *pEngine, QObject *parent=nullptr)
Definition: video.h:145