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 "libmythbase/mythconfig.h"
30 #if CONFIG_QTSCRIPT
31 #include <QScriptEngine>
32 #endif
33 
36 
37 class Video : public VideoServices
38 {
39  Q_OBJECT
40 
41  public:
42 
43  Q_INVOKABLE explicit Video( QObject */*parent*/ = nullptr ) {}
44 
45  public:
46 
47  /* Video Metadata Methods */
48 
49  DTC::VideoMetadataInfoList* GetVideoList ( const QString &Folder,
50  const QString &Sort,
51  bool Descending,
52  int StartIndex,
53  int Count ) override; // VideoServices
54 
55  DTC::VideoMetadataInfo* GetVideo ( int Id ) override; // VideoServices
56 
57  DTC::VideoMetadataInfo* GetVideoByFileName ( const QString &FileName ) override; // VideoServices
58 
59  DTC::VideoLookupList* LookupVideo ( const QString &Title,
60  const QString &Subtitle,
61  const QString &Inetref,
62  int Season,
63  int Episode,
64  const QString &GrabberType,
65  bool AllowGeneric ) override; // VideoServices
66 
67  bool RemoveVideoFromDB ( int Id ) override; // VideoServices
68 
69  bool AddVideo ( const QString &FileName,
70  const QString &HostName ) override; // VideoServices
71 
72  bool UpdateVideoWatchedStatus ( int Id,
73  bool Watched ) override; // VideoServices
74 
75  bool UpdateVideoMetadata ( int Id,
76  const QString &Title,
77  const QString &SubTitle,
78  const QString &TagLine,
79  const QString &Director,
80  const QString &Studio,
81  const QString &Plot,
82  const QString &Rating,
83  const QString &Inetref,
84  int CollectionRef,
85  const QString &HomePage,
86  int Year,
87  const QDate &ReleaseDate,
88  float UserRating,
89  int Length,
90  int PlayCount,
91  int Season,
92  int Episode,
93  int ShowLevel,
94  const QString &FileName,
95  const QString &Hash,
96  const QString &CoverFile,
97  int ChildID,
98  bool Browse,
99  bool Watched,
100  bool Processed,
101  const QString &PlayCommand,
102  int Category,
103  const QString &Trailer,
104  const QString &Host,
105  const QString &Screenshot,
106  const QString &Banner,
107  const QString &Fanart,
108  const QDate &InsertDate,
109  const QString &ContentType,
110  const QString &Genres,
111  const QString &Cast,
112  const QString &Countries
113  ) override; // VideoServices
114 
115  long GetSavedBookmark ( int Id ) override;
116 
117  bool SetSavedBookmark ( int Id,
118  long Offset ) override;
119 
120  /* Bluray Methods */
121 
122  DTC::BlurayInfo* GetBluray ( const QString &Path ) override; // VideoServices
123 
125  const QString &FileName ) override; // VideoServices
126 };
127 
128 // --------------------------------------------------------------------------
129 // The following class wrapper is due to a limitation in Qt Script Engine. It
130 // requires all methods that return pointers to user classes that are derived from
131 // QObject actually return QObject* (not the user class *). If the user class pointer
132 // is returned, the script engine treats it as a QVariant and doesn't create a
133 // javascript prototype wrapper for it.
134 //
135 // This class allows us to keep the rich return types in the main API class while
136 // offering the script engine a class it can work with.
137 //
138 // Only API Classes that return custom classes needs to implement these wrappers.
139 //
140 // We should continue to look for a cleaning solution to this problem.
141 // --------------------------------------------------------------------------
142 
143 #if CONFIG_QTSCRIPT
144 class ScriptableVideo : public QObject
145 {
146  Q_OBJECT
147 
148  private:
149 
150  Video m_obj;
151  QScriptEngine *m_pEngine;
152 
153  public:
154 
155  Q_INVOKABLE explicit ScriptableVideo( QScriptEngine *pEngine, QObject *parent = nullptr ) : QObject( parent )
156  {
157  m_pEngine = pEngine;
158  }
159 
160  public slots:
161 
162  QObject* GetVideoList( const QString &Folder,
163  const QString &Sort,
164  bool Descending,
165  int StartIndex,
166  int Count )
167  {
168  SCRIPT_CATCH_EXCEPTION( nullptr,
169  return m_obj.GetVideoList( Folder, Sort, Descending,
170  StartIndex, Count );
171  )
172  }
173 
174  QObject* GetVideo( int Id )
175  {
176  SCRIPT_CATCH_EXCEPTION( nullptr,
177  return m_obj.GetVideo( Id );
178  )
179  }
180 
181  QObject* GetVideoByFileName( const QString &FileName )
182  {
183  SCRIPT_CATCH_EXCEPTION( nullptr,
184  return m_obj.GetVideoByFileName( FileName );
185  )
186  }
187 
188  QObject* LookupVideo( const QString &Title,
189  const QString &Subtitle,
190  const QString &Inetref,
191  int Season,
192  int Episode,
193  const QString &GrabberType,
194  bool AllowGeneric )
195  {
196  SCRIPT_CATCH_EXCEPTION( nullptr,
197  return m_obj.LookupVideo( Title, Subtitle, Inetref,
198  Season, Episode, GrabberType,
199  AllowGeneric );
200  )
201  }
202 
203  bool RemoveVideoFromDB( int Id )
204  {
205  SCRIPT_CATCH_EXCEPTION( false,
206  return m_obj.RemoveVideoFromDB( Id );
207  )
208  }
209 
210  bool AddVideo( const QString &FileName,
211  const QString &HostName )
212  {
213  SCRIPT_CATCH_EXCEPTION( false,
214  return m_obj.AddVideo( FileName, HostName );
215  )
216  }
217 
218  bool UpdateVideoMetadata( int Id,
219  const QString &Title,
220  const QString &SubTitle,
221  const QString &TagLine,
222  const QString &Director,
223  const QString &Studio,
224  const QString &Plot,
225  const QString &Rating,
226  const QString &Inetref,
227  int CollectionRef,
228  const QString &HomePage,
229  int Year,
230  const QDate ReleaseDate,
231  float UserRating,
232  int Length,
233  int PlayCount,
234  int Season,
235  int Episode,
236  int ShowLevel,
237  const QString &FileName,
238  const QString &Hash,
239  const QString &CoverFile,
240  int ChildID,
241  bool Browse,
242  bool Watched,
243  bool Processed,
244  const QString &PlayCommand,
245  int Category,
246  const QString &Trailer,
247  const QString &Host,
248  const QString &Screenshot,
249  const QString &Banner,
250  const QString &Fanart,
251  const QDate InsertDate,
252  const QString &ContentType,
253  const QString &Genres,
254  const QString &Cast,
255  const QString &Countries
256  )
257  {
258  SCRIPT_CATCH_EXCEPTION( false,
259  return m_obj.UpdateVideoMetadata( Id,
260  Title,
261  SubTitle,
262  TagLine,
263  Director,
264  Studio,
265  Plot,
266  Rating,
267  Inetref,
268  CollectionRef,
269  HomePage,
270  Year,
271  ReleaseDate,
272  UserRating,
273  Length,
274  PlayCount,
275  Season,
276  Episode,
277  ShowLevel,
278  FileName,
279  Hash,
280  CoverFile,
281  ChildID,
282  Browse,
283  Watched,
284  Processed,
285  PlayCommand,
286  Category,
287  Trailer,
288  Host,
289  Screenshot,
290  Banner,
291  Fanart,
292  InsertDate,
293  ContentType,
294  Genres,
295  Cast,
296  Countries);
297  )
298  }
299 };
300 
301 // NOLINTNEXTLINE(modernize-use-auto)
302 Q_SCRIPT_DECLARE_QMETAOBJECT_MYTHTV( ScriptableVideo, QObject*);
303 #endif
304 
305 #endif
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:56
Video
Definition: video.h:37
VideoServices
Definition: videoServices.h:42
Video::GetStreamInfo
DTC::VideoStreamInfoList * GetStreamInfo(const QString &StorageGroup, const QString &FileName) override
Definition: video.cpp:786
DTC::VideoLookupList
Definition: videoLookupInfoList.h:24
DTC::VideoStreamInfoList
Definition: videoStreamInfoList.h:24
DTC::BlurayInfo
Definition: blurayInfo.h:24
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:184
Video::GetVideo
DTC::VideoMetadataInfo * GetVideo(int Id) override
Definition: video.cpp:143
Q_SCRIPT_DECLARE_QMETAOBJECT_MYTHTV
#define Q_SCRIPT_DECLARE_QMETAOBJECT_MYTHTV(T, _Arg1)
Definition: service.h:113
Video::GetVideoByFileName
DTC::VideoMetadataInfo * GetVideoByFileName(const QString &FileName) override
Definition: video.cpp:162
Video::GetSavedBookmark
long GetSavedBookmark(int Id) override
Definition: video.cpp:829
SCRIPT_CATCH_EXCEPTION
#define SCRIPT_CATCH_EXCEPTION(default, code)
Definition: service.h:85
videometadatalistmanager.h
Video::UpdateVideoWatchedStatus
bool UpdateVideoWatchedStatus(int Id, bool Watched) override
Definition: video.cpp:377
Video::RemoveVideoFromDB
bool RemoveVideoFromDB(int Id) override
Definition: video.cpp:301
Video::AddVideo
bool AddVideo(const QString &FileName, const QString &HostName) override
Definition: video.cpp:321
Video::SetSavedBookmark
bool SetSavedBookmark(int Id, long Offset) override
Definition: video.cpp:876
videoServices.h
DTC::VideoMetadataInfo
Definition: videoMetadataInfo.h:29
StorageGroup
Definition: storagegroup.h:11
Video::GetBluray
DTC::BlurayInfo * GetBluray(const QString &Path) override
Definition: video.cpp:399
Video::Video
Q_INVOKABLE Video(QObject *=nullptr)
Definition: video.h:43
DTC::VideoMetadataInfoList
Definition: videoMetadataInfoList.h:24
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:455