Merge lp:~nik90/cliffhanger/add-watchlist-feature into lp:~flashback-dev/cliffhanger/trunk

Proposed by Nekhelesh Ramananthan
Status: Merged
Merged at revision: 30
Proposed branch: lp:~nik90/cliffhanger/add-watchlist-feature
Merge into: lp:~flashback-dev/cliffhanger/trunk
Diff against target: 410 lines (+163/-4)
13 files modified
Flashback.qml (+9/-0)
backend/backend.js (+8/-0)
components/TraktPopup.qml (+18/-0)
models/AiringShows.qml (+2/-0)
models/Show.qml (+2/-0)
models/TraktUserWatchlist.qml (+9/-0)
models/TraktWatchlist.qml (+15/-0)
ui/EpisodePage.qml (+1/-0)
ui/HomeTab.qml (+17/-3)
ui/MoviePage.qml (+36/-0)
ui/SeasonPage.qml (+1/-0)
ui/TvPage.qml (+38/-1)
ui/TvTab.qml (+7/-0)
To merge this branch: bzr merge lp:~nik90/cliffhanger/add-watchlist-feature
Reviewer Review Type Date Requested Status
Flashback Dev Pending
Review via email: mp+202374@code.launchpad.net

Commit message

Added user watchlist feature

Description of the change

Added user watchlist feature

To post a comment you must log in.
34. By Nekhelesh Ramananthan

Small fixes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Flashback.qml'
--- Flashback.qml 2014-01-03 14:01:43 +0000
+++ Flashback.qml 2014-01-20 22:13:50 +0000
@@ -117,6 +117,15 @@
117 }117 }
118 }118 }
119119
120 // Document to store the user's watchlist activity on Trakt
121 U1db.Document {
122 id: watchlistActivityDocument
123 database: db
124 docId: "traktWatchlistActivity"
125 create: true
126 defaults: { "movie": "default", "show": "default" }
127 }
128
120 Loader { id: userActivityLoader }129 Loader { id: userActivityLoader }
121130
122 Component {131 Component {
123132
=== modified file 'backend/backend.js'
--- backend/backend.js 2014-01-19 23:00:52 +0000
+++ backend/backend.js 2014-01-20 22:13:50 +0000
@@ -169,6 +169,14 @@
169 return credentials.trakt_baseUrl + "/user/calendar/shows.json/" + credentials.trakt_apiKey + "/" + username + "/" + startDate + "/" + noOfDays169 return credentials.trakt_baseUrl + "/user/calendar/shows.json/" + credentials.trakt_apiKey + "/" + username + "/" + startDate + "/" + noOfDays
170}170}
171171
172function traktWatchlistUrl(type) {
173 return credentials.trakt_baseUrl + "/" + type + "/watchlist/" + credentials.trakt_apiKey
174}
175
176function traktUnwatchlistUrl(type) {
177 return credentials.trakt_baseUrl + "/" + type + "/unwatchlist/" + credentials.trakt_apiKey
178}
179
172function userWatchlistMovies(username) {180function userWatchlistMovies(username) {
173 return credentials.trakt_baseUrl + "/user/watchlist/movies.json/" + credentials.trakt_apiKey + "/" + username181 return credentials.trakt_baseUrl + "/user/watchlist/movies.json/" + credentials.trakt_apiKey + "/" + username
174}182}
175183
=== modified file 'components/TraktPopup.qml'
--- components/TraktPopup.qml 2013-12-28 18:30:08 +0000
+++ components/TraktPopup.qml 2014-01-20 22:13:50 +0000
@@ -15,10 +15,14 @@
15 // Property to set the seen message15 // Property to set the seen message
16 property alias seenMessage: _seenAction.text16 property alias seenMessage: _seenAction.text
1717
18 // Property to set the watchlist message
19 property alias watchlistMessage: _watchlistAction.text
20
18 // Properties to set the visibility of the individual actions21 // Properties to set the visibility of the individual actions
19 property bool showConfigureAction: traktLogin.contents.status === "disabled"22 property bool showConfigureAction: traktLogin.contents.status === "disabled"
20 property bool showCheckInAction: traktLogin.contents.status !== "disabled"23 property bool showCheckInAction: traktLogin.contents.status !== "disabled"
21 property bool showSeenAction: traktLogin.contents.status !== "disabled"24 property bool showSeenAction: traktLogin.contents.status !== "disabled"
25 property bool showWatchlistAction: traktLogin.contents.status !== "disabled"
22 property bool showCommentAction: true26 property bool showCommentAction: true
2327
24 // Signal triggered when the checked-in action is triggered28 // Signal triggered when the checked-in action is triggered
@@ -30,6 +34,9 @@
30 // Signal triggered when the comments action is triggered34 // Signal triggered when the comments action is triggered
31 signal commented()35 signal commented()
3236
37 // Signal triggered when the watchlist action is triggered
38 signal watchlisted()
39
33 Column {40 Column {
34 id: containerLayout41 id: containerLayout
35 anchors {42 anchors {
@@ -61,6 +68,17 @@
61 }68 }
6269
63 Standard {70 Standard {
71 id: _watchlistAction
72 visible: showWatchlistAction
73 iconSource: Qt.resolvedUrl("../graphics/watchlist_black.png")
74 iconFrame: false
75 onClicked: {
76 popover.watchlisted()
77 PopupUtils.close(popover)
78 }
79 }
80
81 Standard {
64 id: _seenAction82 id: _seenAction
65 visible: showSeenAction83 visible: showSeenAction
66 iconSource: Qt.resolvedUrl("../graphics/watched_black.png")84 iconSource: Qt.resolvedUrl("../graphics/watched_black.png")
6785
=== added file 'graphics/watchlist_black.png'
68Binary files graphics/watchlist_black.png 1970-01-01 00:00:00 +0000 and graphics/watchlist_black.png 2014-01-20 22:13:50 +0000 differ86Binary files graphics/watchlist_black.png 1970-01-01 00:00:00 +0000 and graphics/watchlist_black.png 2014-01-20 22:13:50 +0000 differ
=== modified file 'models/AiringShows.qml'
--- models/AiringShows.qml 2014-01-02 14:31:26 +0000
+++ models/AiringShows.qml 2014-01-20 22:13:50 +0000
@@ -4,6 +4,8 @@
4BasePostModel {4BasePostModel {
5 id: airingShowsModel5 id: airingShowsModel
66
7 property string lastUpdated: "default"
8
7 function fetchData(username, password, date, days) {9 function fetchData(username, password, date, days) {
8 source = Backend.userShows(username, date, days)10 source = Backend.userShows(username, date, days)
9 createMessage(username, password)11 createMessage(username, password)
1012
=== modified file 'models/Show.qml'
--- models/Show.qml 2013-12-30 15:03:51 +0000
+++ models/Show.qml 2014-01-20 22:13:50 +0000
@@ -16,6 +16,7 @@
16 'voteUp': 0,16 'voteUp': 0,
17 'voteDown': 0,17 'voteDown': 0,
18 'userVote': 0,18 'userVote': 0,
19 'in_watchlist': '',
19 'number_of_seasons': 0,20 'number_of_seasons': 0,
20 'networks': '',21 'networks': '',
21 'genres': [],22 'genres': [],
@@ -38,6 +39,7 @@
38 'voteUp': parseInt(reply.ratings.loved),39 'voteUp': parseInt(reply.ratings.loved),
39 'voteDown': parseInt(reply.ratings.hated),40 'voteDown': parseInt(reply.ratings.hated),
40 'userVote': parseInt(reply.rating_advanced),41 'userVote': parseInt(reply.rating_advanced),
42 'in_watchlist': reply.in_watchlist ? reply.in_watchlist.toString() : "",
41 'in_production': reply.status,43 'in_production': reply.status,
42 'networks': reply.network,44 'networks': reply.network,
43 'genres': reply.genres,45 'genres': reply.genres,
4446
=== modified file 'models/TraktUserWatchlist.qml'
--- models/TraktUserWatchlist.qml 2014-01-02 21:25:37 +0000
+++ models/TraktUserWatchlist.qml 2014-01-20 22:13:50 +0000
@@ -1,8 +1,17 @@
1import QtQuick 2.01import QtQuick 2.0
2import "../backend/backend.js" as Backend
23
3BasePostModel {4BasePostModel {
4 id: traktUserWatchlist5 id: traktUserWatchlist
56
7 property string lastUpdated: "default"
8
9 function fetchData(username, password) {
10 source = Backend.userWatchlistMovies(username)
11 createMessage(username, password)
12 sendMessage()
13 }
14
6 function updateJSONModel() {15 function updateJSONModel() {
7 model.clear()16 model.clear()
8 for ( var key in reply ) {17 for ( var key in reply ) {
918
=== added file 'models/TraktWatchlist.qml'
--- models/TraktWatchlist.qml 1970-01-01 00:00:00 +0000
+++ models/TraktWatchlist.qml 2014-01-20 22:13:50 +0000
@@ -0,0 +1,15 @@
1import QtQuick 2.0
2
3BasePostModel {
4 id: traktWatchlist
5
6 // Function to create a JSON String with movie information
7 function createMovieMessage(username, password, imdb_id, title, year) {
8 message = JSON.stringify({username: username, password: password, movies: [{imdb_id: imdb_id, title: title, year: year}]})
9 }
10
11 // Function to create a JSON String with tv show information
12 function createShowMessage(username, password, tvdb_id, title, year) {
13 message = JSON.stringify({username: username, password: password, shows: [{tvdb_id: tvdb_id, title: title, year: year}]})
14 }
15}
016
=== modified file 'ui/EpisodePage.qml'
--- ui/EpisodePage.qml 2014-01-04 15:06:19 +0000
+++ ui/EpisodePage.qml 2014-01-20 22:13:50 +0000
@@ -127,6 +127,7 @@
127 Component {127 Component {
128 id: sharePopoverComponent128 id: sharePopoverComponent
129 TraktPopup {129 TraktPopup {
130 showWatchlistAction: false
130 checkInMessage: showActivityDocument.contents.name !== "default" ? i18n.tr("Cancel current episode check-in") : i18n.tr("Check-in episode into Trakt")131 checkInMessage: showActivityDocument.contents.name !== "default" ? i18n.tr("Cancel current episode check-in") : i18n.tr("Check-in episode into Trakt")
131 seenMessage: isEpisodeSeen ? i18n.tr("Mark episode an unseen") : i18n.tr("Mark episode as seen")132 seenMessage: isEpisodeSeen ? i18n.tr("Mark episode an unseen") : i18n.tr("Mark episode as seen")
132 onCheckedIn: {133 onCheckedIn: {
133134
=== modified file 'ui/HomeTab.qml'
--- ui/HomeTab.qml 2014-01-02 21:25:37 +0000
+++ ui/HomeTab.qml 2014-01-20 22:13:50 +0000
@@ -8,6 +8,8 @@
8Page {8Page {
9 id: homePage9 id: homePage
1010
11 flickable: null
12
11 Component.onCompleted: console.log("[LOG]: Home Tab Loaded")13 Component.onCompleted: console.log("[LOG]: Home Tab Loaded")
1214
13 actions: [15 actions: [
@@ -30,11 +32,16 @@
30 id: userWatchlistModel32 id: userWatchlistModel
31 username: traktLogin.contents.username33 username: traktLogin.contents.username
32 password: traktLogin.contents.password34 password: traktLogin.contents.password
35 lastUpdated: watchlistActivityDocument.contents.movie
33 onPasswordChanged: {36 onPasswordChanged: {
34 console.log("[LOG]: Retrieving user movie watchlist")37 console.log("[LOG]: Retrieving user movie watchlist")
35 source = Backend.userWatchlistMovies(username)38 fetchData(username, password)
36 createMessage(username, password)39 }
37 sendMessage()40 onLastUpdatedChanged: {
41 if(username !== "") {
42 console.log("[LOG]: Retrieving user movie watchlist")
43 fetchData(username, password)
44 }
38 }45 }
39 }46 }
4047
@@ -42,10 +49,17 @@
42 id: airingShowsModel49 id: airingShowsModel
43 username: traktLogin.contents.username50 username: traktLogin.contents.username
44 password: traktLogin.contents.password51 password: traktLogin.contents.password
52 lastUpdated: watchlistActivityDocument.contents.show
45 onPasswordChanged: {53 onPasswordChanged: {
46 console.log("[LOG]: Retrieving shows airing today")54 console.log("[LOG]: Retrieving shows airing today")
47 fetchData(username, password, Qt.formatDate(new Date(), "yyyyMMdd"), 1)55 fetchData(username, password, Qt.formatDate(new Date(), "yyyyMMdd"), 1)
48 }56 }
57 onLastUpdatedChanged: {
58 if(username !== "") {
59 console.log("[LOG]: Retrieving shows airing today")
60 fetchData(username, password, Qt.formatDate(new Date(), "yyyyMMdd"), 1)
61 }
62 }
49 }63 }
5064
51 LoadingIndicator {65 LoadingIndicator {
5266
=== modified file 'ui/MoviePage.qml'
--- ui/MoviePage.qml 2014-01-04 15:06:19 +0000
+++ ui/MoviePage.qml 2014-01-20 22:13:50 +0000
@@ -14,6 +14,7 @@
1414
15 property string movie_id15 property string movie_id
16 property bool isMovieSeen16 property bool isMovieSeen
17 property bool isMovieWatchlisted
1718
18 property int upVotes: 019 property int upVotes: 0
19 property int downVotes: 020 property int downVotes: 0
@@ -54,6 +55,7 @@
54 averageVote = reply.ratings.percentage55 averageVote = reply.ratings.percentage
55 if (traktLogin.contents.status !== "disabled") {56 if (traktLogin.contents.status !== "disabled") {
56 isMovieSeen = reply.watched57 isMovieSeen = reply.watched
58 isMovieWatchlisted = reply.in_watchlist
57 userVote = reply.rating_advanced59 userVote = reply.rating_advanced
58 }60 }
59 }61 }
@@ -109,10 +111,31 @@
109 }111 }
110 }112 }
111113
114 TraktWatchlist {
115 id: movieWatchlist
116 function updateJSONModel() {
117 if(reply.status === "success") {
118 loadingIndicator.visible = false
119 if(!isMovieWatchlisted) {
120 console.log("[LOG]: Movie watchlist success")
121 isMovieWatchlisted = true
122 }
123 else {
124 console.log("[LOG]: Movie Unwatchlist success")
125 isMovieWatchlisted = false
126 }
127 var tempData = watchlistActivityDocument.contents
128 tempData.movie = Qt.formatDateTime(new Date(), "yyyyMMdd hh:mm:ss")
129 watchlistActivityDocument.contents = tempData
130 }
131 }
132 }
133
112 Component {134 Component {
113 id: sharePopoverComponent135 id: sharePopoverComponent
114 TraktPopup {136 TraktPopup {
115 checkInMessage: movieActivityDocument.contents.name !== "default" ? i18n.tr("Cancel current movie check-in") : i18n.tr("Check-in movie into Trakt")137 checkInMessage: movieActivityDocument.contents.name !== "default" ? i18n.tr("Cancel current movie check-in") : i18n.tr("Check-in movie into Trakt")
138 watchlistMessage: isMovieWatchlisted ? i18n.tr("Remove movie from watchlist") : i18n.tr("Add movie to watchlist")
116 seenMessage: isMovieSeen ? i18n.tr("Mark movie as unseen") : i18n.tr("Mark movie as seen")139 seenMessage: isMovieSeen ? i18n.tr("Mark movie as unseen") : i18n.tr("Mark movie as seen")
117 onCheckedIn: {140 onCheckedIn: {
118 if(movieActivityDocument.contents.name !== "default") {141 if(movieActivityDocument.contents.name !== "default") {
@@ -137,6 +160,19 @@
137 movieUnsee.sendMessage()160 movieUnsee.sendMessage()
138 }161 }
139 }162 }
163 onWatchlisted: {
164 loadingIndicator.loadingText = !isMovieWatchlisted ? i18n.tr("Adding movie to watchlist") : i18n.tr("Removing movie from watchlist")
165 loadingIndicator.visible = true
166 if(!isMovieWatchlisted) {
167 movieWatchlist.source = Backend.traktWatchlistUrl("movie")
168 movieWatchlist.createMovieMessage(traktLogin.contents.username, traktLogin.contents.password, movie.attributes.imdb_id, movie.attributes.title, movie.attributes.releaseDate.split('-')[0])
169 }
170 else {
171 movieWatchlist.source = Backend.traktUnwatchlistUrl("movie")
172 movieWatchlist.createMovieMessage(traktLogin.contents.username, traktLogin.contents.password, movie.attributes.imdb_id, movie.attributes.title, movie.attributes.releaseDate.split('-')[0])
173 }
174 movieWatchlist.sendMessage()
175 }
140 onCommented: pagestack.push(Qt.resolvedUrl("CommentsPage.qml"), {id: movie_id, type: "Movie", name: movie.attributes.title, year: movie.attributes.releaseDate.split('-')[0]})176 onCommented: pagestack.push(Qt.resolvedUrl("CommentsPage.qml"), {id: movie_id, type: "Movie", name: movie.attributes.title, year: movie.attributes.releaseDate.split('-')[0]})
141 }177 }
142 }178 }
143179
=== modified file 'ui/SeasonPage.qml'
--- ui/SeasonPage.qml 2014-01-04 15:06:19 +0000
+++ ui/SeasonPage.qml 2014-01-20 22:13:50 +0000
@@ -74,6 +74,7 @@
74 TraktPopup {74 TraktPopup {
75 showCheckInAction: false75 showCheckInAction: false
76 showCommentAction: false76 showCommentAction: false
77 showWatchlistAction: false
77 seenMessage: !isSeasonSeen ? i18n.tr("Mark season as seen") : i18n.tr("Season has been watched!")78 seenMessage: !isSeasonSeen ? i18n.tr("Mark season as seen") : i18n.tr("Season has been watched!")
78 onWatched: {79 onWatched: {
79 if(!isSeasonSeen) {80 if(!isSeasonSeen) {
8081
=== modified file 'ui/TvPage.qml'
--- ui/TvPage.qml 2014-01-04 15:06:19 +0000
+++ ui/TvPage.qml 2014-01-20 22:13:50 +0000
@@ -14,6 +14,7 @@
1414
15 property string tv_id15 property string tv_id
16 property int userVote: 016 property int userVote: 0
17 property bool isShowWatchlisted
1718
18 actions: [19 actions: [
19 Action {20 Action {
@@ -41,6 +42,26 @@
41 }42 }
42 }43 }
4344
45 TraktWatchlist {
46 id: showWatchlist
47 function updateJSONModel() {
48 if(reply.status === "success") {
49 loadingIndicator.visible = false
50 if(!isShowWatchlisted) {
51 console.log("[LOG]: Show watchlist success")
52 isShowWatchlisted = true
53 }
54 else {
55 console.log("[LOG]: Show Unwatchlist success")
56 isShowWatchlisted = false
57 }
58 var tempData = watchlistActivityDocument.contents
59 tempData.show = Qt.formatDateTime(new Date(), "yyyyMMdd hh:mm:ss")
60 watchlistActivityDocument.contents = tempData
61 }
62 }
63 }
64
44 LoadingIndicator {65 LoadingIndicator {
45 id: loadingIndicator66 id: loadingIndicator
46 visible: false67 visible: false
@@ -51,6 +72,7 @@
51 TraktPopup {72 TraktPopup {
52 showCheckInAction: false73 showCheckInAction: false
53 seenMessage: i18n.tr("Mark show as seen")74 seenMessage: i18n.tr("Mark show as seen")
75 watchlistMessage: isShowWatchlisted ? i18n.tr("Remove show from watchlist") : i18n.tr("Add show to watchlist")
54 onWatched: {76 onWatched: {
55 loadingIndicator.loadingText = i18n.tr("Marking show as seen")77 loadingIndicator.loadingText = i18n.tr("Marking show as seen")
56 loadingIndicator.visible = true78 loadingIndicator.visible = true
@@ -58,6 +80,19 @@
58 showSee.createShowMessage(traktLogin.contents.username, traktLogin.contents.password, tv_id, show.imdb_id, show.name, show.year)80 showSee.createShowMessage(traktLogin.contents.username, traktLogin.contents.password, tv_id, show.imdb_id, show.name, show.year)
59 showSee.sendMessage()81 showSee.sendMessage()
60 }82 }
83 onWatchlisted: {
84 loadingIndicator.loadingText = !isShowWatchlisted ? i18n.tr("Adding show to watchlist") : i18n.tr("Removing show from watchlist")
85 loadingIndicator.visible = true
86 if(!isShowWatchlisted) {
87 showWatchlist.source = Backend.traktWatchlistUrl("show")
88 showWatchlist.createShowMessage(traktLogin.contents.username, traktLogin.contents.password, tv_id, show.name, show.year)
89 }
90 else {
91 showWatchlist.source = Backend.traktUnwatchlistUrl("show")
92 showWatchlist.createShowMessage(traktLogin.contents.username, traktLogin.contents.password, tv_id, show.name, show.year)
93 }
94 showWatchlist.sendMessage()
95 }
61 onCommented: pagestack.push(Qt.resolvedUrl("CommentsPage.qml"), {id: tv_id, type: "Show", name: show.name, year: show.year})96 onCommented: pagestack.push(Qt.resolvedUrl("CommentsPage.qml"), {id: tv_id, type: "Show", name: show.name, year: show.year})
62 }97 }
63 }98 }
@@ -80,8 +115,10 @@
80 }115 }
81 onUpdated: {116 onUpdated: {
82 tvCast.json = show.attributes.creditsJson;117 tvCast.json = show.attributes.creditsJson;
83 if(traktLogin.contents.status !== "disabled")118 if(traktLogin.contents.status !== "disabled") {
84 userVote = show.attributes.userVote119 userVote = show.attributes.userVote
120 isShowWatchlisted = show.attributes.in_watchlist
121 }
85 }122 }
86 }123 }
87124
88125
=== modified file 'ui/TvTab.qml'
--- ui/TvTab.qml 2014-01-18 20:35:22 +0000
+++ ui/TvTab.qml 2014-01-20 22:13:50 +0000
@@ -35,10 +35,17 @@
35 id: airingShowsModel35 id: airingShowsModel
36 username: traktLogin.contents.username36 username: traktLogin.contents.username
37 password: traktLogin.contents.password37 password: traktLogin.contents.password
38 lastUpdated: watchlistActivityDocument.contents.show
38 onPasswordChanged: {39 onPasswordChanged: {
39 console.log("[LOG]: Retrieving upcoming shows")40 console.log("[LOG]: Retrieving upcoming shows")
40 fetchData(username, password, Qt.formatDate(new Date(), "yyyyMMdd"), 7)41 fetchData(username, password, Qt.formatDate(new Date(), "yyyyMMdd"), 7)
41 }42 }
43 onLastUpdatedChanged: {
44 if(username !== "") {
45 console.log("[LOG]: Retrieving upcoming shows")
46 fetchData(username, password, Qt.formatDate(new Date(), "yyyyMMdd"), 7)
47 }
48 }
42 }49 }
4350
44 LoadingIndicator {51 LoadingIndicator {

Subscribers

People subscribed via source and target branches