Merge branch 'master' of github.com:KevinMidboe/seasoned

This commit is contained in:
2020-02-25 12:09:45 +01:00
4 changed files with 41 additions and 7 deletions

View File

@@ -252,6 +252,21 @@ const getRequestStatus = (id, type, authorization_token=undefined) => {
.catch(err => Promise.reject(err))
}
const watchLink = (title, year, authorization_token=undefined) => {
const url = new URL('v1/plex/watch-link', SEASONED_URL)
url.searchParams.append('title', title)
url.searchParams.append('year', year)
const headers = {
'Authorization': authorization_token,
'Content-Type': 'application/json'
}
return fetch(url.href, { headers })
.then(resp => resp.json())
.then(response => response.link)
}
// - - - Seasoned user endpoints - - -
const register = (username, password) => {
@@ -458,6 +473,7 @@ export {
searchTorrents,
addMagnet,
request,
watchLink,
getRequestStatus,
linkPlexAccount,
unlinkPlexAccount,

View File

@@ -30,6 +30,11 @@
Request to be downloaded?
</sidebar-list-element>
<sidebar-list-element v-if="isPlexAuthenticated && matched" @click="openInPlex" :iconString="'⏯ '">
Watch in plex now!
</sidebar-list-element>
<sidebar-list-element v-if="admin" @click="showTorrents=!showTorrents"
:iconRef="'#icon_torrents'" :active="showTorrents"
:supplementaryText="numberOfTorrentResults">
@@ -126,7 +131,12 @@ import SidebarListElement from './ui/sidebarListElem'
import store from '@/store'
import LoadingPlaceholder from './ui/LoadingPlaceholder'
import { getMovie, getPerson, getShow, request, getRequestStatus } from '@/api'
import { getMovie,
getPerson,
getShow,
request,
getRequestStatus,
watchLink } from '@/api'
export default {
// props: ['id', 'type'],
@@ -222,6 +232,10 @@ export default {
}
})
},
openInPlex() {
watchLink(this.title, this.movie.year, storage.token)
.then(watchLink => window.location = watchLink)
},
openTmdb(){
const tmdbType = this.type === 'show' ? 'tv' : this.type
window.location.href = 'https://www.themoviedb.org/' + tmdbType + '/' + this.id

View File

@@ -2,7 +2,7 @@
<div>
<a @click="$emit('click')">
<li>
<figure :class="activeClassIfActive">
<figure v-if="iconRef" :class="activeClassIfActive">
<svg class="icon"><use :xlink:href="iconRefNameIfActive"/></svg>
</figure>
@@ -23,7 +23,7 @@ export default {
props: {
iconRef: {
type: String,
required: true
required: false
},
iconRefActive: {
type: String,
@@ -85,11 +85,11 @@ li {
border-bottom: 1px solid $text-color-5;
&:hover {
color: $text-color-70;
color: $text-color;
cursor: pointer;
.icon {
fill: $text-color-70;
fill: $text-color;
cursor: pointer;
transform: scale(1.1, 1.1);
}

View File

@@ -71,8 +71,12 @@ export default {
return undefined
},
isPlexAuthenticated: (state) => {
let hasPlexId = state.settings['plex_userid']
return hasPlexId != undefined
const settings = state.settings || getLocalStorageByKey('settings')
if (settings == null)
return false
const hasPlexId = settings['plex_userid']
return hasPlexId != null ? true : false
}
},
mutations: {