Merge pull request #3112 from koying/fixcurlopenssl
[vuplus_xbmc] / xbmc / video / VideoInfoTag.h
1 #pragma once
2 /*
3  *      Copyright (C) 2005-2013 Team XBMC
4  *      http://xbmc.org
5  *
6  *  This Program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2, or (at your option)
9  *  any later version.
10  *
11  *  This Program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with XBMC; see the file COPYING.  If not, see
18  *  <http://www.gnu.org/licenses/>.
19  *
20  */
21
22 #include <vector>
23 #include "XBDateTime.h"
24 #include "utils/ScraperUrl.h"
25 #include "utils/Fanart.h"
26 #include "utils/ISortable.h"
27 #include "utils/StreamDetails.h"
28 #include "video/Bookmark.h"
29
30 class CArchive;
31 class TiXmlNode;
32 class TiXmlElement;
33
34 struct SActorInfo
35 {
36   SActorInfo() : order(-1) {};
37   bool operator<(const SActorInfo &right) const
38   {
39     return order < right.order;
40   }
41   CStdString strName;
42   CStdString strRole;
43   CScraperUrl thumbUrl;
44   CStdString thumb;
45   int        order;
46 };
47
48 class CVideoInfoTag : public IArchivable, public ISerializable, public ISortable
49 {
50 public:
51   CVideoInfoTag() { Reset(); };
52   void Reset();
53   /* \brief Load information to a videoinfotag from an XML element
54    There are three types of tags supported:
55     1. Single-value tags, such as <title>.  These are set if available, else are left untouched.
56     2. Additive tags, such as <set> or <genre>.  These are appended to or replaced (if available) based on the value
57        of the prioritise parameter.  In addition, a clear attribute is available in the XML to clear the current value prior
58        to appending.
59     3. Image tags such as <thumb> and <fanart>.  If the prioritise value is specified, any additional values are prepended
60        to the existing values.
61
62    \param element    the root XML element to parse.
63    \param append     whether information should be added to the existing tag, or whether it should be reset first.
64    \param prioritise if appending, whether additive tags should be prioritised (i.e. replace or prepend) over existing values. Defaults to false.
65
66    \sa ParseNative
67    */
68   bool Load(const TiXmlElement *element, bool append = false, bool prioritise = false);
69   bool Save(TiXmlNode *node, const CStdString &tag, bool savePathInfo = true, const TiXmlElement *additionalNode = NULL);
70   virtual void Archive(CArchive& ar);
71   virtual void Serialize(CVariant& value) const;
72   virtual void ToSortable(SortItem& sortable, Field field) const;
73   const CStdString GetCast(bool bIncludeRole = false) const;
74   bool HasStreamDetails() const;
75   bool IsEmpty() const;
76
77   const CStdString& GetPath() const
78   {
79     if (m_strFileNameAndPath.empty())
80       return m_strPath;
81     return m_strFileNameAndPath;
82   };
83
84   /*! \brief retrieve the duration in seconds.
85    Prefers the duration from stream details if available.
86    */
87   unsigned int GetDuration() const;
88
89   /*! \brief get the duration in seconds from a minute string
90    \param runtime the runtime string from a scraper or similar
91    \return the time in seconds, if decipherable.
92    */
93   static unsigned int GetDurationFromMinuteString(const std::string &runtime);
94
95   CStdString m_basePath; // the base path of the video, for folder-based lookups
96   int m_parentPathID;      // the parent path id where the base path of the video lies
97   std::vector<std::string> m_director;
98   std::vector<std::string> m_writingCredits;
99   std::vector<std::string> m_genre;
100   std::vector<std::string> m_country;
101   CStdString m_strTagLine;
102   CStdString m_strPlotOutline;
103   CStdString m_strTrailer;
104   CStdString m_strPlot;
105   CScraperUrl m_strPictureURL;
106   CStdString m_strTitle;
107   CStdString m_strSortTitle;
108   CStdString m_strVotes;
109   std::vector<std::string> m_artist;
110   std::vector< SActorInfo > m_cast;
111   typedef std::vector< SActorInfo >::const_iterator iCast;
112   CStdString m_strSet;
113   int m_iSetId;
114   std::vector<std::string> m_tags;
115   CStdString m_strFile;
116   CStdString m_strPath;
117   CStdString m_strIMDBNumber;
118   CStdString m_strMPAARating;
119   CStdString m_strFileNameAndPath;
120   CStdString m_strOriginalTitle;
121   CStdString m_strEpisodeGuide;
122   CDateTime m_premiered;
123   CStdString m_strStatus;
124   CStdString m_strProductionCode;
125   CDateTime m_firstAired;
126   CStdString m_strShowTitle;
127   std::vector<std::string> m_studio;
128   CStdString m_strAlbum;
129   CDateTime m_lastPlayed;
130   std::vector<std::string> m_showLink;
131   CStdString m_strShowPath;
132   int m_playCount;
133   int m_iTop250;
134   int m_iYear;
135   int m_iSeason;
136   int m_iEpisode;
137   CStdString m_strUniqueId;
138   int m_iDbId;
139   int m_iFileId;
140   int m_iSpecialSortSeason;
141   int m_iSpecialSortEpisode;
142   int m_iTrack;
143   float m_fRating;
144   float m_fEpBookmark;
145   int m_iBookmarkId;
146   int m_iIdShow;
147   int m_iIdSeason;
148   CFanart m_fanart;
149   CStreamDetails m_streamDetails;
150   CBookmark m_resumePoint;
151   CDateTime m_dateAdded;
152   CStdString m_type;
153   int m_duration; ///< duration in seconds
154
155 private:
156   /* \brief Parse our native XML format for video info.
157    See Load for a description of the available tag types.
158
159    \param element    the root XML element to parse.
160    \param prioritise whether additive tags should be replaced (or prepended) by the content of the tags, or appended to.
161    \sa Load
162    */
163   void ParseNative(const TiXmlElement* element, bool prioritise);
164 };
165
166 typedef std::vector<CVideoInfoTag> VECMOVIES;