on cbbcfdd help sign in
unity8/Dash/Video/VideoInfo.qml
84 lines 3.3 kB history raw
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17import QtQuick 2.0
18import QtQuick.XmlListModel 2.0
20Item {
21 id: info
22 property string source
24 property bool ready: nfo.status == XmlListModel.Ready || nfoTV.status == XmlListModel.Ready
25 property bool isMovie: true
26 property variant video: null
27 property variant tvShow: null
29 function getActors() {
30 var c = []
31 if (video.actor1) c.push(video.actor1)
32 if (video.actor2) c.push(video.actor2)
33 if (video.actor3) c.push(video.actor3)
34 return c
35 }
37 onSourceChanged: isMovie = true
39 XmlListModel {
40 id: nfo
41 source: info.source
42 query: (isMovie) ? "/movie" : "/episodedetails"
44 XmlRole { name: "title"; query: "title/string()" }
45 XmlRole { name: "year"; query: "year/number()" }
46 XmlRole { name: "runtime"; query: "runtime/number()" }
47 XmlRole { name: "rating"; query: "rating/number()" }
48 XmlRole { name: "plot"; query: "plot/string()" }
49 XmlRole { name: "director"; query: "director[1]/string()" }
50 XmlRole { name: "actor1"; query: "actor[1]/name/string()" }
51 XmlRole { name: "actor2"; query: "actor[2]/name/string()" }
52 XmlRole { name: "actor3"; query: "actor[3]/name/string()" }
53 XmlRole { name: "author"; query: "author[1]/string()" }
54 XmlRole { name: "season"; query: "season/number()" }
55 XmlRole { name: "episode"; query: "episode/number()" }
57 XmlRole { name: "rentPrice"; query: "rent_price/string()" }
58 XmlRole { name: "buyPrice"; query: "buy_price/string()" }
59 XmlRole { name: "expires"; query: "expires/string()" }
61 onStatusChanged: if (status == XmlListModel.Ready) {
62 if (count > 0) info.video = nfo.get(0)
63 else info.isMovie = false
64 } else if (status == XmlListModel.Error) info.isMovie = false
65 }
67 XmlListModel {
68 id: nfoTV
69 source: (nfo.isMovie) ? "" : info.source.substring(0, info.source.lastIndexOf("/") + 1) + "tvshow.nfo"
70 query: "/tvshow"
72 XmlRole { name: "title"; query: "title/string()" }
74 onStatusChanged: if (status == XmlListModel.Ready) {
75 if (count > 0) info.tvShow = nfoTV.get(0)
76 } else if (status == XmlListModel.Error) {
77 // Search for tvshow.nfo in the directory above this one to cater
78 // for directory layout Show/Season
79 var path = info.source.split("/")
80 path.splice(-2, 2, "tvshow.nfo")
81 source = path.join("/")
82 }
83 }