diff --git a/src/api.js b/src/api.js index 0043889..275202c 100644 --- a/src/api.js +++ b/src/api.js @@ -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, diff --git a/src/components/Movie.vue b/src/components/Movie.vue index 5f4d35f..71575ae 100644 --- a/src/components/Movie.vue +++ b/src/components/Movie.vue @@ -30,6 +30,11 @@ Request to be downloaded? + + + Watch in plex now! + + @@ -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 diff --git a/src/components/ui/sidebarListElem.vue b/src/components/ui/sidebarListElem.vue index c91e894..cddee5e 100644 --- a/src/components/ui/sidebarListElem.vue +++ b/src/components/ui/sidebarListElem.vue @@ -2,7 +2,7 @@
  • -
    +
    @@ -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); } diff --git a/src/modules/userModule.js b/src/modules/userModule.js index dfa47bf..c5114fe 100644 --- a/src/modules/userModule.js +++ b/src/modules/userModule.js @@ -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: {