Merge pull request #54 from barnardb/add-mark-unwatched-button

Add "mark unwatched" button
This commit is contained in:
samcm 2017-11-12 18:09:01 -08:00 committed by GitHub
commit c6d070a173
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 20 deletions

View File

@ -157,6 +157,13 @@ module.exports = function PlexServer () {
return handleMetadata(result, that, callback)
})
}
this.markWatchedByRatingKey = function (ratingKey, callback) {
console.log('Marking ' + ratingKey + ' as watched')
this.hitApi('/:/scrobble', {
identifier: 'com.plexapp.plugins.library',
key: ratingKey
}, callback)
}
this.getUrlForLibraryLoc = function (location, width, height, blur) {
if (!(blur > 0)) {
blur = 0

View File

@ -161,15 +161,7 @@
},
name: 'plexbrowser',
mounted () {
if (this.lastServer){
this.lastServer.getOnDeck(0, 10, (result) => {
if (result) {
this.onDeck = result
}
})
}
this.updateOnDeck()
},
methods: {
setContent (content) {
@ -183,7 +175,16 @@
return true
}
return false
},
},
updateOnDeck () {
if (this.lastServer){
this.lastServer.getOnDeck(0, 10, (result) => {
if (result) {
this.onDeck = result
}
})
}
},
subsetOnDeck (size) {
if (!this.onDeck || !this.onDeck.MediaContainer || !this.onDeck.MediaContainer.Metadata){
return []
@ -191,6 +192,7 @@
return this.onDeck.MediaContainer.Metadata.slice(this.onDeckOffset, this.onDeckOffset + size)
},
reset () {
this.updateOnDeck()
this.browsingServer = false
this.selectedItem = false
this.results = []

View File

@ -115,6 +115,9 @@
<v-card-actions class="pa-4" >
<v-spacer></v-spacer>
<div v-if="playable">
<v-btn v-on:click.native="markWatched(content)">
Mark Watched
</v-btn>
<v-btn v-if="playable && content.Media.length == 1 && (content.viewOffset == 0 || !content.viewOffset)" v-on:click.native="playMedia(content)" class="primary white--text">
<v-icon>play_arrow</v-icon> Play
</v-btn>
@ -334,6 +337,12 @@
}
return this.parentData.MediaContainer.Metadata.slice(this.contents.index - 1,this.contents.index + size -1)
},
markWatched (content, mediaIndex) {
var that = this;
this.server.markWatchedByRatingKey(content.ratingKey, function () {
that.$parent.reset()
})
},
playMedia (content, mediaIndex) {
var callback = function(result){
console.log(result)
@ -351,9 +360,6 @@
callback: callback
}
)
},
getDuration (dur){
return humanizeDuration(dur, {

View File

@ -118,12 +118,7 @@
this.setBackground()
}
})
this.server.getOnDeck(0, 10, (result) => {
if (result) {
this.onDeck = result
}
})
this.updateOnDeck()
},
beforeDestroy () {
@ -171,7 +166,14 @@
},
setLibrary (library) {
this.browsingLibrary = library
},
},
updateOnDeck() {
this.server.getOnDeck(0, 10, (result) => {
if (result) {
this.onDeck = result
}
})
},
onDeckDown (){
if (!this.onDeck || !this.onDeck.MediaContainer || !this.onDeck.MediaContainer.Metadata){
return false
@ -268,6 +270,7 @@
return this.server.getUrlForLibraryLoc(object.grandparentThumb, w / 3, h / 4)
},
reset () {
this.updateOnDeck()
this.browsingLibrary = false
this.selectedItem = false
this.setBackground()