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  long GetSavedBookmark ( int Id ) override;
114 
115  bool SetSavedBookmark ( int Id,
116  long Offset ) override;
117 
118  /* Bluray Methods */
119 
120  DTC::BlurayInfo* GetBluray ( const QString &Path ) override; // VideoServices
121 
123  const QString &FileName ) override; // VideoServices
124 };
125 
126 // --------------------------------------------------------------------------
127 // The following class wrapper is due to a limitation in Qt Script Engine. It
128 // requires all methods that return pointers to user classes that are derived from
129 // QObject actually return QObject* (not the user class *). If the user class pointer
130 // is returned, the script engine treats it as a QVariant and doesn't create a
131 // javascript prototype wrapper for it.
132 //
133 // This class allows us to keep the rich return types in the main API class while
134 // offering the script engine a class it can work with.
135 //
136 // Only API Classes that return custom classes needs to implement these wrappers.
137 //
138 // We should continue to look for a cleaning solution to this problem.
139 // --------------------------------------------------------------------------
140 
141 class ScriptableVideo : public QObject
142 {
143  Q_OBJECT
144 
145  private:
146 
148  QScriptEngine *m_pEngine;
149 
150  public:
151 
152  Q_INVOKABLE explicit ScriptableVideo( QScriptEngine *pEngine, QObject *parent = nullptr ) : QObject( parent )
153  {
154  m_pEngine = pEngine;
155  }
156 
157  public slots:
158 
159  QObject* GetVideoList( const QString &Folder,
160  const QString &Sort,
161  bool Descending,
162  int StartIndex,
163  int Count )
164  {
165  SCRIPT_CATCH_EXCEPTION( nullptr,
166  return m_obj.GetVideoList( Folder, Sort, Descending,
167  StartIndex, Count );
168  )
169  }
170 
171  QObject* GetVideo( int Id )
172  {
173  SCRIPT_CATCH_EXCEPTION( nullptr,
174  return m_obj.GetVideo( Id );
175  )
176  }
177 
178  QObject* GetVideoByFileName( const QString &FileName )
179  {
180  SCRIPT_CATCH_EXCEPTION( nullptr,
181  return m_obj.GetVideoByFileName( FileName );
182  )
183  }
184 
185  QObject* LookupVideo( const QString &Title,
186  const QString &Subtitle,
187  const QString &Inetref,
188  int Season,
189  int Episode,
190  const QString &GrabberType,
191  bool AllowGeneric )
192  {
193  SCRIPT_CATCH_EXCEPTION( nullptr,
194  return m_obj.LookupVideo( Title, Subtitle, Inetref,
195  Season, Episode, GrabberType,
196  AllowGeneric );
197  )
198  }
199 
200  bool RemoveVideoFromDB( int Id )
201  {
202  SCRIPT_CATCH_EXCEPTION( false,
203  return m_obj.RemoveVideoFromDB( Id );
204  )
205  }
206 
207  bool AddVideo( const QString &FileName,
208  const QString &HostName )
209  {
210  SCRIPT_CATCH_EXCEPTION( false,
211  return m_obj.AddVideo( FileName, HostName );
212  )
213  }
214 
215  bool UpdateVideoMetadata( int Id,
216  const QString &Title,
217  const QString &SubTitle,
218  const QString &TagLine,
219  const QString &Director,
220  const QString &Studio,
221  const QString &Plot,
222  const QString &Rating,
223  const QString &Inetref,
224  int CollectionRef,
225  const QString &HomePage,
226  int Year,
227  const QDate &ReleaseDate,
228  float UserRating,
229  int Length,
230  int PlayCount,
231  int Season,
232  int Episode,
233  int ShowLevel,
234  const QString &FileName,
235  const QString &Hash,
236  const QString &CoverFile,
237  int ChildID,
238  bool Browse,
239  bool Watched,
240  bool Processed,
241  const QString &PlayCommand,
242  int Category,
243  const QString &Trailer,
244  const QString &Host,
245  const QString &Screenshot,
246  const QString &Banner,
247  const QString &Fanart,
248  const QDate &InsertDate,
249  const QString &ContentType,
250  const QString &Genres,
251  const QString &Cast,
252  const QString &Countries
253  )
254  {
255  SCRIPT_CATCH_EXCEPTION( false,
256  return m_obj.UpdateVideoMetadata( Id,
257  Title,
258  SubTitle,
259  TagLine,
260  Director,
261  Studio,
262  Plot,
263  Rating,
264  Inetref,
265  CollectionRef,
266  HomePage,
267  Year,
268  ReleaseDate,
269  UserRating,
270  Length,
271  PlayCount,
272  Season,
273  Episode,
274  ShowLevel,
275  FileName,
276  Hash,
277  CoverFile,
278  ChildID,
279  Browse,
280  Watched,
281  Processed,
282  PlayCommand,
283  Category,
284  Trailer,
285  Host,
286  Screenshot,
287  Banner,
288  Fanart,
289  InsertDate,
290  ContentType,
291  Genres,
292  Cast,
293  Countries);
294  )
295  }
296 };
297 
298 // NOLINTNEXTLINE(modernize-use-auto)
300 
301 #endif
ScriptableVideo::GetVideo
QObject * GetVideo(int Id)
Definition: video.h:171
GrabberType
GrabberType
Definition: metadatagrabber.h:20
Video::GetVideoList
DTC::VideoMetadataInfoList * GetVideoList(const QString &Folder, const QString &Sort, bool Descending, int StartIndex, int Count) override
Definition: video.cpp:53
Video
Definition: video.h:36
slots
std::array< unsigned int, 4 > slots
Definition: element.cpp:38
VideoServices
Definition: videoServices.h:43
ScriptableVideo::RemoveVideoFromDB
bool RemoveVideoFromDB(int Id)
Definition: video.h:200
Video::GetStreamInfo
DTC::VideoStreamInfoList * GetStreamInfo(const QString &StorageGroup, const QString &FileName) override
Definition: video.cpp:806
DTC::VideoLookupList
Definition: videoLookupInfoList.h:25
ScriptableVideo
Definition: video.h:142
DTC::VideoStreamInfoList
Definition: videoStreamInfoList.h:25
ScriptableVideo::LookupVideo
QObject * LookupVideo(const QString &Title, const QString &Subtitle, const QString &Inetref, int Season, int Episode, const QString &GrabberType, bool AllowGeneric)
Definition: video.h:185
DTC::BlurayInfo
Definition: blurayInfo.h:25
ScriptableVideo::GetVideoList
QObject * GetVideoList(const QString &Folder, const QString &Sort, bool Descending, int StartIndex, int Count)
Definition: video.h:159
Video::LookupVideo
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:181
Video::GetVideo
DTC::VideoMetadataInfo * GetVideo(int Id) override
Definition: video.cpp:140
ScriptableVideo::GetVideoByFileName
QObject * GetVideoByFileName(const QString &FileName)
Definition: video.h:178
Video::GetVideoByFileName
DTC::VideoMetadataInfo * GetVideoByFileName(const QString &FileName) override
Definition: video.cpp:159
Video::GetSavedBookmark
long GetSavedBookmark(int Id) override
Definition: video.cpp:849
SCRIPT_CATCH_EXCEPTION
#define SCRIPT_CATCH_EXCEPTION(default, code)
Definition: service.h:83
videometadatalistmanager.h
Video::UpdateVideoWatchedStatus
bool UpdateVideoWatchedStatus(int Id, bool Watched) override
Definition: video.cpp:376
Video::RemoveVideoFromDB
bool RemoveVideoFromDB(int Id) override
Definition: video.cpp:300
Video::AddVideo
bool AddVideo(const QString &FileName, const QString &HostName) override
Definition: video.cpp:320
ScriptableVideo::ScriptableVideo
Q_INVOKABLE ScriptableVideo(QScriptEngine *pEngine, QObject *parent=nullptr)
Definition: video.h:152
Q_SCRIPT_DECLARE_QMETAOBJECT_MYTHTV
Q_SCRIPT_DECLARE_QMETAOBJECT_MYTHTV(ScriptableVideo, QObject *)
ScriptableVideo::m_obj
Video m_obj
Definition: video.h:147
ScriptableVideo::UpdateVideoMetadata
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:215
Video::SetSavedBookmark
bool SetSavedBookmark(int Id, long Offset) override
Definition: video.cpp:896
videoServices.h
DTC::VideoMetadataInfo
Definition: videoMetadataInfo.h:30
ScriptableVideo::m_pEngine
QScriptEngine * m_pEngine
Definition: video.h:148
StorageGroup
Definition: storagegroup.h:12
Video::GetBluray
DTC::BlurayInfo * GetBluray(const QString &Path) override
Definition: video.cpp:398
Video::Video
Q_INVOKABLE Video(QObject *=nullptr)
Definition: video.h:41
DTC::VideoMetadataInfoList
Definition: videoMetadataInfoList.h:25
ScriptableVideo::AddVideo
bool AddVideo(const QString &FileName, const QString &HostName)
Definition: video.h:207
Video::UpdateVideoMetadata
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:454