More lint fixing
This commit is contained in:
parent
4f32ed5683
commit
018cc2e786
|
@ -21,6 +21,7 @@ module.exports = {
|
|||
ignoreTemplateLiterals: true,
|
||||
},
|
||||
],
|
||||
|
||||
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
|
||||
|
|
|
@ -221,7 +221,10 @@
|
|||
v-if="Object.keys(getPlex.servers).length === 0"
|
||||
xs12
|
||||
>
|
||||
<h5>No Plex Media Servers found. Make sure your server owner has shared their libraries with you!</h5>
|
||||
<h5>
|
||||
No Plex Servers found.
|
||||
Make sure your server owner has shared libraries with you!
|
||||
</h5>
|
||||
</v-flex>
|
||||
<v-flex
|
||||
v-for="server in getPlex.servers"
|
||||
|
@ -302,6 +305,131 @@ export default {
|
|||
components: {
|
||||
plexthumb,
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
browsingServer: null,
|
||||
selectedItem: null,
|
||||
browsingContent: null,
|
||||
|
||||
results: [],
|
||||
onDeckOffset: 0,
|
||||
onDeck: null,
|
||||
searchWord: '',
|
||||
searchStatus: 'Search your available Plex Media Servers',
|
||||
searching: false,
|
||||
serversHeardBack: [],
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapGetters(['GET_LASTSERVER', 'getPlex']),
|
||||
onDeckItemsPer() {
|
||||
switch (this.$vuetify.breakpoint.name) {
|
||||
case 'xs':
|
||||
return 1;
|
||||
case 'sm':
|
||||
return 2;
|
||||
case 'md':
|
||||
return 4;
|
||||
case 'lg':
|
||||
return 4;
|
||||
case 'xl':
|
||||
return 4;
|
||||
default:
|
||||
return 4;
|
||||
}
|
||||
},
|
||||
|
||||
availableServers() {
|
||||
const servers = this.getPlex.servers.filter((server) => {
|
||||
if (server.chosenConnection) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return servers;
|
||||
},
|
||||
|
||||
onDeckUpStyle() {
|
||||
if (this.onDeckOffset + 3 >= this.onDeck.MediaContainer.Metadata.length) {
|
||||
return {
|
||||
opacity: 0.5,
|
||||
};
|
||||
}
|
||||
|
||||
return {};
|
||||
},
|
||||
|
||||
onDeckDownStyle() {
|
||||
if (this.onDeckOffset === 0) {
|
||||
return {
|
||||
opacity: 0.5,
|
||||
};
|
||||
}
|
||||
|
||||
return {};
|
||||
},
|
||||
|
||||
filteredShows() {
|
||||
return this.results.filter((item) => {
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
if (item.type === 'show') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
filteredEpisodes() {
|
||||
return this.results.filter((item) => {
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
if (item.type === 'episode') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
filteredMovies() {
|
||||
return this.results.filter((item) => {
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
if (item.type === 'movie') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
filteredSeasons() {
|
||||
return this.results.filter((item) => {
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
if (item.type === 'series') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
searchWord() {
|
||||
if (this.searchWord === '') {
|
||||
this.results = [];
|
||||
this.searchStatus = 'Search your available Plex Media Servers';
|
||||
return;
|
||||
}
|
||||
this.searchAllServers();
|
||||
},
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.updateOnDeck();
|
||||
},
|
||||
|
@ -324,7 +452,7 @@ export default {
|
|||
this.onDeck = await this.GET_LASTSERVER.getOnDeck(0, 10);
|
||||
}
|
||||
},
|
||||
subsetOnDeck(size) {
|
||||
subsetOnDeck() {
|
||||
if (
|
||||
!this.onDeck
|
||||
|| !this.onDeck.MediaContainer
|
||||
|
@ -347,44 +475,51 @@ export default {
|
|||
this.setBackground();
|
||||
// this.$store.commit('SET_BACKGROUND',null)
|
||||
},
|
||||
|
||||
onDeckDown() {
|
||||
if (
|
||||
!this.onDeck
|
||||
|| !this.onDeck.MediaContainer
|
||||
|| !this.onDeck.MediaContainer.Metadata
|
||||
) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.onDeckOffset - 4 < 0) {
|
||||
this.onDeckOffset = 0;
|
||||
} else {
|
||||
this.onDeckOffset -= 4;
|
||||
}
|
||||
},
|
||||
|
||||
onDeckUp() {
|
||||
if (
|
||||
!this.onDeck
|
||||
|| !this.onDeck.MediaContainer
|
||||
|| !this.onDeck.MediaContainer.Metadata
|
||||
) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.onDeckOffset + 4 >= this.onDeck.MediaContainer.Metadata.length) {
|
||||
// This would overflow!
|
||||
} else {
|
||||
this.onDeckOffset += 4;
|
||||
}
|
||||
},
|
||||
|
||||
ownerOfServer(server) {
|
||||
if (server.owned === '1') {
|
||||
return 'you';
|
||||
}
|
||||
return server.sourceTitle;
|
||||
},
|
||||
|
||||
setBackground() {
|
||||
// this.$store.commit('SET_RANDOMBACKROUND')
|
||||
// this.$store.commit('SET_BACKROUND',null)
|
||||
},
|
||||
|
||||
getThumb(object) {
|
||||
const w = Math.round(
|
||||
Math.max(document.documentElement.clientWidth, window.innerWidth || 0),
|
||||
|
@ -394,6 +529,7 @@ export default {
|
|||
);
|
||||
return object.server.getUrlForLibraryLoc(object.thumb, w / 4, h / 4);
|
||||
},
|
||||
|
||||
getArt(object) {
|
||||
const w = Math.round(
|
||||
Math.max(document.documentElement.clientWidth, window.innerWidth || 0),
|
||||
|
@ -403,164 +539,57 @@ export default {
|
|||
);
|
||||
return object.server.getUrlForLibraryLoc(object.art, w / 4, h / 4);
|
||||
},
|
||||
|
||||
getTitleMovie(movie) {
|
||||
if (movie.year) {
|
||||
return `${movie.title} (${movie.year})`;
|
||||
}
|
||||
return movie.title;
|
||||
},
|
||||
|
||||
heardBack(server) {
|
||||
for (let i = 0; i < this.serversHeardBack.length; i++) {
|
||||
const tempserver = this.serversHeardBack[i];
|
||||
if (tempserver.clientIdentifier === server.clientIdentifier) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return this.serversHeardBack
|
||||
.find((serv) => serv.clientIdentifier === server.clientIdentifier);
|
||||
},
|
||||
searchAllServers: _.debounce(function () {
|
||||
|
||||
searchAllServers: _.debounce(() => {
|
||||
if (this.searchWord === '') {
|
||||
this.results = [];
|
||||
this.searchStatus = 'Search your available Plex Media Servers';
|
||||
return;
|
||||
}
|
||||
|
||||
this.searching = true;
|
||||
this.results = [];
|
||||
this.serversResponded = 0;
|
||||
const storedWord = this.searchWord;
|
||||
for (const i in this.getPlex.servers) {
|
||||
const server = this.getPlex.servers[i];
|
||||
|
||||
this.getPlex.servers.forEach((server) => {
|
||||
server.search(this.searchWord).then((serverSearchResults) => {
|
||||
if (storedWord !== this.searchWord) {
|
||||
// Old data
|
||||
return;
|
||||
}
|
||||
this.serversResponded++;
|
||||
this.serversResponded += 1;
|
||||
this.serversHeardBack.push(server);
|
||||
|
||||
if (serverSearchResults) {
|
||||
for (let j = 0; j < serverSearchResults.length; j++) {
|
||||
serverSearchResults[j].server = server;
|
||||
}
|
||||
this.results = this.results.concat(serverSearchResults);
|
||||
this.results = this.results.concat(serverSearchResults.map((results) => ({
|
||||
...results,
|
||||
server,
|
||||
})));
|
||||
}
|
||||
|
||||
this.searchStatus = `Found ${this.results.length} results from ${
|
||||
this.serversResponded
|
||||
} servers`;
|
||||
|
||||
if (this.serversResponded === Object.keys(this.getPlex.servers).length) {
|
||||
this.searching = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 1000),
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
browsingServer: null,
|
||||
selectedItem: null,
|
||||
browsingContent: null,
|
||||
|
||||
results: [],
|
||||
onDeckOffset: 0,
|
||||
onDeck: null,
|
||||
searchWord: '',
|
||||
searchStatus: 'Search your available Plex Media Servers',
|
||||
searching: false,
|
||||
serversHeardBack: [],
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
searchWord() {
|
||||
if (this.searchWord === '') {
|
||||
this.results = [];
|
||||
this.searchStatus = 'Search your available Plex Media Servers';
|
||||
return;
|
||||
}
|
||||
this.searchAllServers();
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['GET_LASTSERVER', 'getPlex']),
|
||||
onDeckItemsPer() {
|
||||
switch (this.$vuetify.breakpoint.name) {
|
||||
case 'xs':
|
||||
return 1;
|
||||
case 'sm':
|
||||
return 2;
|
||||
case 'md':
|
||||
return 4;
|
||||
case 'lg':
|
||||
return 4;
|
||||
case 'xl':
|
||||
return 4;
|
||||
}
|
||||
},
|
||||
availableServers() {
|
||||
const servers = this.getPlex.servers.filter((server) => {
|
||||
if (server.chosenConnection) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return servers;
|
||||
},
|
||||
onDeckUpStyle() {
|
||||
if (this.onDeckOffset + 3 >= this.onDeck.MediaContainer.Metadata.length) {
|
||||
return {
|
||||
opacity: 0.5,
|
||||
};
|
||||
}
|
||||
},
|
||||
onDeckDownStyle() {
|
||||
if (this.onDeckOffset === 0) {
|
||||
return {
|
||||
opacity: 0.5,
|
||||
};
|
||||
}
|
||||
},
|
||||
filteredShows() {
|
||||
return this.results.filter((item) => {
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
if (item.type === 'show') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
},
|
||||
filteredEpisodes() {
|
||||
return this.results.filter((item) => {
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
if (item.type === 'episode') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
},
|
||||
filteredMovies() {
|
||||
return this.results.filter((item) => {
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
if (item.type === 'movie') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
},
|
||||
filteredSeasons() {
|
||||
return this.results.filter((item) => {
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
if (item.type === 'series') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -70,8 +70,8 @@
|
|||
wrap
|
||||
>
|
||||
<v-flex
|
||||
v-for="content in contents.MediaContainer.Metadata"
|
||||
:key="content"
|
||||
v-for="subContent in contents.MediaContainer.Metadata"
|
||||
:key="subContent"
|
||||
xs6
|
||||
md3
|
||||
xl1
|
||||
|
@ -79,11 +79,11 @@
|
|||
class="pb-3"
|
||||
>
|
||||
<plexthumb
|
||||
:content="content"
|
||||
:content="subContent"
|
||||
:server="server"
|
||||
type="thumb"
|
||||
full-title
|
||||
@contentSet="setContent(content)"
|
||||
@contentSet="setContent(subContent)"
|
||||
/>
|
||||
</v-flex>
|
||||
</v-layout>
|
||||
|
@ -105,8 +105,8 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import plexcontent from './plexcontent';
|
||||
import plexalbum from './plexalbum';
|
||||
import plexcontent from './plexcontent.vue';
|
||||
import plexalbum from './plexalbum.vue';
|
||||
import plexthumb from './plexthumb.vue';
|
||||
|
||||
export default {
|
||||
|
@ -115,7 +115,22 @@ export default {
|
|||
plexthumb,
|
||||
plexalbum,
|
||||
},
|
||||
props: ['library', 'server', 'content'],
|
||||
props: {
|
||||
library: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
|
||||
server: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
|
||||
content: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
browsingContent: null,
|
||||
|
@ -126,8 +141,10 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
getArtUrl() {
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth,
|
||||
window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight,
|
||||
window.innerHeight || 0));
|
||||
return this.server.getUrlForLibraryLoc(
|
||||
this.contents.MediaContainer.banner,
|
||||
w / 2,
|
||||
|
@ -136,8 +153,10 @@ export default {
|
|||
);
|
||||
},
|
||||
getThumb() {
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth,
|
||||
window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight,
|
||||
window.innerHeight || 0));
|
||||
return this.server.getUrlForLibraryLoc(
|
||||
this.contents.MediaContainer.thumb,
|
||||
w / 1,
|
||||
|
@ -170,8 +189,10 @@ export default {
|
|||
this.browsingContent = content;
|
||||
},
|
||||
setBackground() {
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth,
|
||||
window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight,
|
||||
window.innerHeight || 0));
|
||||
|
||||
this.$store.commit(
|
||||
'SET_BACKGROUND',
|
||||
|
|
|
@ -522,15 +522,18 @@ export default {
|
|||
if (this.hiddenOverride) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((this.contents && this.contents.viewCount === 0) || !this.contents.viewCount) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
largestRes() {
|
||||
let height = 0;
|
||||
for (let i = 0; i < this.contents.Media.length; i++) {
|
||||
if (parseInt(this.contents.Media[i].videoResolution) > height) {
|
||||
height = parseInt(this.contents.Media[i].videoResolution);
|
||||
for (let i = 0; i < this.contents.Media.length; i += 1) {
|
||||
if (parseInt(this.contents.Media[i].videoResolution, 10) > height) {
|
||||
height = parseInt(this.contents.Media[i].videoResolution, 10);
|
||||
}
|
||||
}
|
||||
return height;
|
||||
|
@ -564,7 +567,7 @@ export default {
|
|||
return [];
|
||||
}
|
||||
const items = [];
|
||||
this.related.MediaContainer.Hub[0].Metadata.map((item) => {
|
||||
this.related.MediaContainer.Hub[0].Metadata.forEach((item) => {
|
||||
items.push(item);
|
||||
});
|
||||
return items.slice(0, 7);
|
||||
|
@ -626,7 +629,7 @@ export default {
|
|||
getNewData() {
|
||||
this.server.getMediaByRatingKey(this.ratingKey).then(async (result) => {
|
||||
if (result) {
|
||||
this.contents = result.MediaContainer.Metadata[0];
|
||||
[this.contents] = result.MediaContainer.Metadata;
|
||||
if (this.contents.type === 'episode') {
|
||||
this.server
|
||||
.getSeriesChildren(`${this.contents.parentRatingKey}/children`, 0, 500, 1)
|
||||
|
@ -637,9 +640,7 @@ export default {
|
|||
});
|
||||
}
|
||||
if (this.contents.type === 'movie') {
|
||||
try {
|
||||
this.related = await this.server.getRelated(this.ratingKey, 12);
|
||||
} catch (e) {}
|
||||
this.related = await this.server.getRelated(this.ratingKey, 12).catch(() => {});
|
||||
}
|
||||
this.setBackground();
|
||||
} else {
|
||||
|
@ -690,7 +691,6 @@ export default {
|
|||
});
|
||||
},
|
||||
async playMedia(content, mediaIndex) {
|
||||
const callback = function () {};
|
||||
let offset = 0;
|
||||
if (this.resumeFrom) {
|
||||
offset = this.contents.viewOffset;
|
||||
|
@ -701,7 +701,7 @@ export default {
|
|||
mediaIndex,
|
||||
server: this.server,
|
||||
offset,
|
||||
callback,
|
||||
callback: () => {},
|
||||
});
|
||||
this.dialog = false;
|
||||
},
|
||||
|
@ -713,20 +713,20 @@ export default {
|
|||
});
|
||||
},
|
||||
pressStop() {
|
||||
this.chosenClient.pressStop((result) => {});
|
||||
this.chosenClient.pressStop(() => {});
|
||||
},
|
||||
getStreamCount(streams, type) {
|
||||
let count = 0;
|
||||
streams.forEach((stream) => {
|
||||
if (stream.streamType === type) {
|
||||
count++;
|
||||
count += 1;
|
||||
}
|
||||
});
|
||||
return count;
|
||||
},
|
||||
audioStreams(media) {
|
||||
let result = '';
|
||||
for (let i = 0; i < media.length; i++) {
|
||||
for (let i = 0; i < media.length; i += 1) {
|
||||
const stream = media[i];
|
||||
if (stream.streamType === 2 && stream.languageCode) {
|
||||
result = `${result} ${stream.languageCode || 'Unknown Lanugage'},`;
|
||||
|
@ -737,7 +737,7 @@ export default {
|
|||
},
|
||||
subtitleStreams(media) {
|
||||
let result = '';
|
||||
for (let i = 0; i < media.length; i++) {
|
||||
for (let i = 0; i < media.length; i += 1) {
|
||||
const stream = media[i];
|
||||
if (stream.streamType === 3 && stream.languageCode) {
|
||||
result = `${result} ${stream.languageCode || 'Unknown Lanugage'},`;
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
<template>
|
||||
<span ref="root" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import plexthumb from './plexthumb.vue';
|
||||
import plexseason from './plexseason.vue';
|
||||
import plexseries from './plexseries.vue';
|
||||
import plexcontent from './plexcontent.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
plexthumb,
|
||||
plexseason,
|
||||
plexseries,
|
||||
plexcontent,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
contents: null,
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
ratingKey() {
|
||||
return this.$route.params.ratingKey;
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.server.getMediaByRatingKey(this.content.ratingKey).then((result) => {
|
||||
if (result) {
|
||||
this.contents = result;
|
||||
if (result.type === 'episode') {
|
||||
this.server.getSeriesChildren(`${result.parentKey}/children`, 0, 500, 1).then((res) => {
|
||||
if (res) {
|
||||
this.parentData = res;
|
||||
}
|
||||
});
|
||||
}
|
||||
this.setBackground();
|
||||
} else {
|
||||
this.status = 'Error loading libraries!';
|
||||
}
|
||||
});
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
beforeDestroy() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
|
@ -61,23 +61,15 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import plexcontent from './plexcontent';
|
||||
import plexseries from './plexseries';
|
||||
import plexalbum from './plexalbum';
|
||||
import plexthumb from './plexthumb';
|
||||
import plexartist from './plexartist';
|
||||
import plexthumb from './plexthumb.vue';
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
export default {
|
||||
components: {
|
||||
plexcontent,
|
||||
plexseries,
|
||||
plexthumb,
|
||||
plexalbum,
|
||||
plexartist,
|
||||
},
|
||||
props: ['library'],
|
||||
|
||||
data() {
|
||||
return {
|
||||
browsingContent: null,
|
||||
|
@ -92,34 +84,35 @@ export default {
|
|||
searchPhrase: null,
|
||||
};
|
||||
},
|
||||
|
||||
computed: {
|
||||
server() {
|
||||
return this.plex.servers[this.$route.params.machineIdentifier];
|
||||
},
|
||||
},
|
||||
|
||||
created() {
|
||||
// Hit the PMS endpoing /library/sections
|
||||
this.getMoreContent();
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
beforeDestroy() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
setContent(content) {
|
||||
this.browsingContent = content;
|
||||
},
|
||||
handler(component) {
|
||||
},
|
||||
|
||||
getThumb(object) {
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth,
|
||||
window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight,
|
||||
window.innerHeight || 0));
|
||||
return this.server.getUrlForLibraryLoc(object.thumb, w / 6, h / 4);
|
||||
},
|
||||
setBackground() {
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth,
|
||||
window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight,
|
||||
window.innerHeight || 0));
|
||||
|
||||
const randomItem = _.sample(this.contents.MediaContainer.Metadata);
|
||||
let url = randomItem.thumb;
|
||||
|
@ -128,6 +121,7 @@ export default {
|
|||
}
|
||||
this.$store.commit('SET_BACKGROUND', this.server.getUrlForLibraryLoc(url, w / 4, h / 4, 8));
|
||||
},
|
||||
|
||||
isShown(item) {
|
||||
if (!item.active) {
|
||||
return {
|
||||
|
@ -136,61 +130,62 @@ export default {
|
|||
}
|
||||
return {};
|
||||
},
|
||||
|
||||
getTitleMovie(movie) {
|
||||
if (movie.year) {
|
||||
return `${movie.title} (${movie.year})`;
|
||||
}
|
||||
return movie.title;
|
||||
},
|
||||
filterItems: _.debounce(
|
||||
function () {
|
||||
for (let i = 0; i < this.contents.MediaContainer.Metadata.length; i++) {
|
||||
const item = this.contents.MediaContainer.Metadata[i];
|
||||
if (!this.searchPhrase) {
|
||||
item.active = true;
|
||||
continue;
|
||||
}
|
||||
if (item.title.toLowerCase().indexOf(this.searchPhrase.toLowerCase()) > -1) {
|
||||
item.active = true;
|
||||
} else {
|
||||
item.active = false;
|
||||
}
|
||||
|
||||
filterItems: _.debounce(() => {
|
||||
for (let i = 0; i < this.contents.MediaContainer.Metadata.length; i += 1) {
|
||||
const item = this.contents.MediaContainer.Metadata[i];
|
||||
if (!this.searchPhrase) {
|
||||
item.active = true;
|
||||
} else if (item.title.toLowerCase().indexOf(this.searchPhrase.toLowerCase()) > -1) {
|
||||
item.active = true;
|
||||
} else {
|
||||
item.active = false;
|
||||
}
|
||||
},
|
||||
500,
|
||||
),
|
||||
}
|
||||
}, 500),
|
||||
|
||||
getMoreContent() {
|
||||
if (this.stopNewContent || this.busy) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.busy = true;
|
||||
this.server.getLibraryContents(this.$route.params.sectionId, this.startingIndex, this.size).then((result) => {
|
||||
if (result && result.MediaContainer && result.MediaContainer.Metadata) {
|
||||
this.libraryTotalSize = result.MediaContainer.totalSize;
|
||||
this.startingIndex += 100;
|
||||
if (this.contents) {
|
||||
for (let i = 0; i < result.MediaContainer.Metadata.length; i++) {
|
||||
const media = result.MediaContainer.Metadata[i];
|
||||
media.active = true;
|
||||
this.contents.MediaContainer.Metadata.push(media);
|
||||
this.server.getLibraryContents(this.$route.params.sectionId, this.startingIndex, this.size)
|
||||
.then((result) => {
|
||||
if (result && result.MediaContainer && result.MediaContainer.Metadata) {
|
||||
this.libraryTotalSize = result.MediaContainer.totalSize;
|
||||
this.startingIndex += 100;
|
||||
if (this.contents) {
|
||||
for (let i = 0; i < result.MediaContainer.Metadata.length; i += 1) {
|
||||
const media = result.MediaContainer.Metadata[i];
|
||||
media.active = true;
|
||||
this.contents.MediaContainer.Metadata.push(media);
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < result.MediaContainer.Metadata.length; i += 1) {
|
||||
const media = result.MediaContainer.Metadata[i];
|
||||
media.active = true;
|
||||
}
|
||||
this.contents = result;
|
||||
this.setBackground();
|
||||
}
|
||||
if (result.MediaContainer.size < 100) {
|
||||
this.stopNewContent = true;
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < result.MediaContainer.Metadata.length; i++) {
|
||||
const media = result.MediaContainer.Metadata[i];
|
||||
media.active = true;
|
||||
}
|
||||
this.contents = result;
|
||||
this.setBackground();
|
||||
this.status = 'Error loading libraries!';
|
||||
}
|
||||
if (result.MediaContainer.size < 100) {
|
||||
this.stopNewContent = true;
|
||||
}
|
||||
} else {
|
||||
this.status = 'Error loading libraries!';
|
||||
}
|
||||
this.busy = false;
|
||||
});
|
||||
this.busy = false;
|
||||
});
|
||||
},
|
||||
|
||||
reset() {
|
||||
this.browsingContent = false;
|
||||
this.setBackground();
|
||||
|
|
|
@ -116,15 +116,12 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import plexcontent from './plexcontent';
|
||||
import plexthumb from './plexthumb.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
plexcontent,
|
||||
plexthumb,
|
||||
},
|
||||
props: ['library', 'server', 'content'],
|
||||
data() {
|
||||
return {
|
||||
browsingContent: null,
|
||||
|
@ -135,20 +132,28 @@ export default {
|
|||
},
|
||||
computed: {
|
||||
getArtUrl() {
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
|
||||
return this.plexserver.getUrlForLibraryLoc(this.contents.MediaContainer.banner, w / 2, h / 1, 2);
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth,
|
||||
window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight,
|
||||
window.innerHeight || 0));
|
||||
return this.plexserver.getUrlForLibraryLoc(this.contents.MediaContainer.banner,
|
||||
w / 2, h / 1, 2);
|
||||
},
|
||||
getThumb() {
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth,
|
||||
window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight,
|
||||
window.innerHeight || 0));
|
||||
|
||||
return this.plexserver.getUrlForLibraryLoc(
|
||||
this.contents.MediaContainer.thumb || this.contents.MediaContainer.grandparentThumb || this.contents.MediaContainer.parentThumb,
|
||||
this.contents.MediaContainer.thumb || this.contents.MediaContainer.grandparentThumb
|
||||
|| this.contents.MediaContainer.parentThumb,
|
||||
w / 1,
|
||||
h / 2,
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
browsingContent() {
|
||||
if (!this.browsingContent) {
|
||||
|
@ -158,7 +163,8 @@ export default {
|
|||
},
|
||||
created() {
|
||||
// Hit the PMS endpoing /library/sections
|
||||
this.plexserver.getSeriesChildren(this.$route.params.ratingKey, 0, 500, 1, this.$route.params.sectionId)
|
||||
this.plexserver.getSeriesChildren(this.$route.params.ratingKey,
|
||||
0, 500, 1, this.$route.params.sectionId)
|
||||
.then((result) => {
|
||||
if (result) {
|
||||
this.contents = result;
|
||||
|
@ -175,8 +181,10 @@ export default {
|
|||
this.browsingContent = content;
|
||||
},
|
||||
setBackground() {
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth,
|
||||
window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight,
|
||||
window.innerHeight || 0));
|
||||
|
||||
this.$store.commit('SET_BACKGROUND', this.plexserver.getUrlForLibraryLoc(this.contents.MediaContainer.art, w / 4, h / 4, 2));
|
||||
},
|
||||
|
|
|
@ -133,12 +133,10 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import plexseason from './plexseason.vue';
|
||||
import plexthumb from './plexthumb.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
plexseason,
|
||||
plexthumb,
|
||||
},
|
||||
props: [],
|
||||
|
@ -154,9 +152,11 @@ export default {
|
|||
};
|
||||
},
|
||||
computed: {
|
||||
getArtUrl(object) {
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
|
||||
getArtUrl() {
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth,
|
||||
window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight,
|
||||
window.innerHeight || 0));
|
||||
return this.plexserver.getUrlForLibraryLoc(this.contents.banner, w / 1, h / 1, 2);
|
||||
},
|
||||
getSeasons() {
|
||||
|
@ -178,28 +178,30 @@ export default {
|
|||
return this.seriesData.MediaContainer.Metadata[0].Genre.slice(0, 5);
|
||||
},
|
||||
thumb() {
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
|
||||
return this.plexserver.getUrlForLibraryLoc(this.contents.thumb || this.contents.parentThumb || this.contents.grandparentThumb, w / 1, h / 1);
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth,
|
||||
window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight,
|
||||
window.innerHeight || 0));
|
||||
return this.plexserver.getUrlForLibraryLoc(this.contents.thumb || this.contents.parentThumb
|
||||
|| this.contents.grandparentThumb, w / 1, h / 1);
|
||||
},
|
||||
},
|
||||
created() {
|
||||
// Hit the PMS endpoing /library/sections
|
||||
this.plexserver.getSeriesChildren(this.$route.params.ratingKey, this.startingIndex, this.size, 1, this.$route.params.sectionId).then((result) => {
|
||||
this.plexserver.getSeriesChildren(this.$route.params.ratingKey, this.startingIndex,
|
||||
this.size, 1, this.$route.params.sectionId).then((result) => {
|
||||
if (result) {
|
||||
this.contents = result.MediaContainer;
|
||||
this.setBackground();
|
||||
} else {
|
||||
this.status = 'Error loading libraries!';
|
||||
}
|
||||
}).catch((e, data) => {
|
||||
});
|
||||
}).catch(() => {});
|
||||
this.plexserver.getSeriesData(this.$route.params.ratingKey).then((res) => {
|
||||
if (res) {
|
||||
this.seriesData = res;
|
||||
}
|
||||
}).catch((e, data) => {
|
||||
});
|
||||
}).catch(() => {});
|
||||
},
|
||||
mounted() {
|
||||
|
||||
|
@ -209,8 +211,10 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
setBackground() {
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth,
|
||||
window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight,
|
||||
window.innerHeight || 0));
|
||||
this.$store.commit('SET_BACKGROUND', this.server.getUrlForLibraryLoc(this.contents.art, w / 4, h / 4, 2));
|
||||
},
|
||||
reset() {
|
||||
|
|
|
@ -206,8 +206,10 @@ export default {
|
|||
case 'md': return 12;
|
||||
case 'lg': return 12;
|
||||
case 'xl': return 12;
|
||||
default: return 12;
|
||||
}
|
||||
},
|
||||
|
||||
onDeckItemsPer() {
|
||||
switch (this.$vuetify.breakpoint.name) {
|
||||
case 'xs': return 1;
|
||||
|
@ -215,17 +217,22 @@ export default {
|
|||
case 'md': return 3;
|
||||
case 'lg': return 4;
|
||||
case 'xl': return 4;
|
||||
default: return 4;
|
||||
}
|
||||
},
|
||||
|
||||
clientIdentifier() {
|
||||
return this.$route.params.machineIdentifier;
|
||||
},
|
||||
|
||||
server() {
|
||||
return this.plex.servers[this.clientIdentifier];
|
||||
},
|
||||
|
||||
plex() {
|
||||
return this.$store.getters.getPlex;
|
||||
},
|
||||
|
||||
filteredLibraries() {
|
||||
const data = [];
|
||||
if (this.libraries) {
|
||||
|
@ -237,38 +244,49 @@ export default {
|
|||
}
|
||||
return data;
|
||||
},
|
||||
|
||||
onDeckUpStyle() {
|
||||
if ((this.onDeckOffset + this.onDeckItemsPer) >= this.onDeck.MediaContainer.Metadata.length) {
|
||||
return {
|
||||
opacity: 0.5,
|
||||
};
|
||||
}
|
||||
|
||||
return {};
|
||||
},
|
||||
|
||||
onDeckDownStyle() {
|
||||
if (this.onDeckOffset === 0) {
|
||||
return {
|
||||
opacity: 0.5,
|
||||
};
|
||||
}
|
||||
|
||||
return {};
|
||||
},
|
||||
|
||||
recentlyAddedDownStyle() {
|
||||
if (this.recentlyAddedOffset === 0) {
|
||||
return {
|
||||
opacity: 0.5,
|
||||
};
|
||||
}
|
||||
|
||||
return {};
|
||||
},
|
||||
|
||||
recentlyAddedUpStyle() {
|
||||
if ((this.recentlyAddedOffset + this.recentItemsPer) >= this.recentlyAdded.MediaContainer.Metadata.length) {
|
||||
if (this.recentlyAddedOffset + this.recentItemsPer
|
||||
>= this.recentlyAdded.MediaContainer.Metadata.length) {
|
||||
return {
|
||||
opacity: 0.5,
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
return {};
|
||||
},
|
||||
},
|
||||
created() {
|
||||
},
|
||||
|
||||
async mounted() {
|
||||
this.server.getAllLibraries().then((data) => {
|
||||
if (data) {
|
||||
|
@ -277,25 +295,27 @@ export default {
|
|||
this.status = 'Error loading libraries!';
|
||||
}
|
||||
});
|
||||
|
||||
this.server.getRecentlyAddedAll(0, 12).then((result) => {
|
||||
if (result) {
|
||||
this.recentlyAdded = result;
|
||||
this.setBackground();
|
||||
}
|
||||
});
|
||||
|
||||
this.updateOnDeck();
|
||||
},
|
||||
beforeDestroy() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
setContent(content) {
|
||||
this.selectedItem = content;
|
||||
},
|
||||
|
||||
setLibrary(library) {
|
||||
this.$router.push(`/browse/${this.server.clientIdentifier}/${library.key}`);
|
||||
// this.browsingLibrary = library
|
||||
},
|
||||
|
||||
updateOnDeck() {
|
||||
this.server.getOnDeck(0, 10).then((result) => {
|
||||
if (result) {
|
||||
|
@ -303,106 +323,140 @@ export default {
|
|||
}
|
||||
});
|
||||
},
|
||||
|
||||
onDeckDown() {
|
||||
if (!this.onDeck || !this.onDeck.MediaContainer || !this.onDeck.MediaContainer.Metadata) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.onDeckOffset - this.onDeckItemsPer < 0) {
|
||||
this.onDeckOffset = 0;
|
||||
} else {
|
||||
this.onDeckOffset -= 4;
|
||||
}
|
||||
},
|
||||
|
||||
onDeckUp() {
|
||||
if (!this.onDeck || !this.onDeck.MediaContainer || !this.onDeck.MediaContainer.Metadata) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.onDeckOffset + this.onDeckItemsPer >= this.onDeck.MediaContainer.Metadata.length) {
|
||||
// This would overflow!
|
||||
} else {
|
||||
this.onDeckOffset += this.onDeckItemsPer;
|
||||
}
|
||||
},
|
||||
|
||||
recentlyAddedUp() {
|
||||
if (!this.recentlyAdded || !this.recentlyAdded.MediaContainer || !this.recentlyAdded.MediaContainer.Metadata) {
|
||||
return false;
|
||||
if (!this.recentlyAdded || !this.recentlyAdded.MediaContainer
|
||||
|| !this.recentlyAdded.MediaContainer.Metadata) {
|
||||
return;
|
||||
}
|
||||
if (this.recentlyAddedOffset + this.recentItemsPer >= this.recentlyAdded.MediaContainer.Metadata.length) {
|
||||
|
||||
if (this.recentlyAddedOffset + this.recentItemsPer
|
||||
>= this.recentlyAdded.MediaContainer.Metadata.length) {
|
||||
// This would overflow!
|
||||
} else {
|
||||
this.recentlyAddedOffset += this.recentItemsPer;
|
||||
}
|
||||
},
|
||||
|
||||
recentlyAddedDown() {
|
||||
if (!this.recentlyAdded || !this.recentlyAdded.MediaContainer || !this.recentlyAdded.MediaContainer.Metadata) {
|
||||
return false;
|
||||
if (!this.recentlyAdded || !this.recentlyAdded.MediaContainer
|
||||
|| !this.recentlyAdded.MediaContainer.Metadata) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.recentlyAddedOffset - this.recentItemsPer < 0) {
|
||||
this.recentlyAddedOffset = 0;
|
||||
} else {
|
||||
this.recentlyAddedOffset -= this.recentItemsPer;
|
||||
}
|
||||
},
|
||||
|
||||
setBackground() {
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth,
|
||||
window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight,
|
||||
window.innerHeight || 0));
|
||||
|
||||
const randomItem = _.sample(this.recentlyAdded.MediaContainer.Metadata);
|
||||
const url = randomItem.art;
|
||||
this.$store.commit('SET_BACKGROUND', this.server.getUrlForLibraryLoc(url, w / 4, h / 1, 6));
|
||||
},
|
||||
|
||||
subsetOnDeck() {
|
||||
if (!this.onDeck || !this.onDeck.MediaContainer || !this.onDeck.MediaContainer.Metadata) {
|
||||
return [];
|
||||
}
|
||||
return this.onDeck.MediaContainer.Metadata.slice(this.onDeckOffset, this.onDeckOffset + this.onDeckItemsPer);
|
||||
return this.onDeck.MediaContainer.Metadata.slice(this.onDeckOffset,
|
||||
this.onDeckOffset + this.onDeckItemsPer);
|
||||
},
|
||||
|
||||
subsetRecentlyAdded() {
|
||||
if (!this.recentlyAdded || !this.recentlyAdded.MediaContainer || !this.recentlyAdded.MediaContainer.Metadata) {
|
||||
if (!this.recentlyAdded || !this.recentlyAdded.MediaContainer
|
||||
|| !this.recentlyAdded.MediaContainer.Metadata) {
|
||||
return [];
|
||||
}
|
||||
return this.recentlyAdded.MediaContainer.Metadata.slice(this.recentlyAddedOffset, this.recentlyAddedOffset + this.recentItemsPer);
|
||||
|
||||
return this.recentlyAdded.MediaContainer.Metadata.slice(this.recentlyAddedOffset,
|
||||
this.recentlyAddedOffset + this.recentItemsPer);
|
||||
},
|
||||
|
||||
progress(content) {
|
||||
let perc = (parseInt(content.viewOffset) / parseInt(content.duration)) * 100;
|
||||
if (isNaN(perc)) {
|
||||
let perc = (parseInt(content.viewOffset, 10) / parseInt(content.duration, 10)) * 100;
|
||||
if (Number.isNaN(perc)) {
|
||||
perc = 0;
|
||||
}
|
||||
return `${perc}%`;
|
||||
},
|
||||
|
||||
getArt(object) {
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth,
|
||||
window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight,
|
||||
window.innerHeight || 0));
|
||||
return this.server.getUrlForLibraryLoc(object.art, w / 1, h / 1);
|
||||
},
|
||||
|
||||
getArtLibrary(object) {
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth,
|
||||
window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight,
|
||||
window.innerHeight || 0));
|
||||
return this.server.getUrlForLibraryLoc(object.art, w / 1, h / 1, 15);
|
||||
},
|
||||
|
||||
getThumb(object) {
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth,
|
||||
window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight,
|
||||
window.innerHeight || 0));
|
||||
return this.server.getUrlForLibraryLoc(object.thumb, w / 4, h / 4);
|
||||
},
|
||||
|
||||
getTitleMovie(movie) {
|
||||
if (movie.year) {
|
||||
return `${movie.title} (${movie.year})`;
|
||||
}
|
||||
return movie.title;
|
||||
},
|
||||
|
||||
getGrandparentThumb(object) {
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth, window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight, window.innerHeight || 0));
|
||||
const w = Math.round(Math.max(document.documentElement.clientWidth,
|
||||
window.innerWidth || 0));
|
||||
const h = Math.round(Math.max(document.documentElement.clientHeight,
|
||||
window.innerHeight || 0));
|
||||
return this.server.getUrlForLibraryLoc(object.grandparentThumb, w / 3, h / 4);
|
||||
},
|
||||
|
||||
reset() {
|
||||
this.updateOnDeck();
|
||||
this.browsingLibrary = false;
|
||||
this.selectedItem = false;
|
||||
this.setBackground();
|
||||
},
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -120,21 +120,48 @@
|
|||
import VanillaTilt from 'vanilla-tilt';
|
||||
|
||||
export default {
|
||||
components: {},
|
||||
props: [
|
||||
'library',
|
||||
'showServer',
|
||||
'content',
|
||||
'type',
|
||||
'server',
|
||||
'height',
|
||||
'fullTitle',
|
||||
'search',
|
||||
'locked',
|
||||
'img',
|
||||
'bottomOnly',
|
||||
'spoilerFilter',
|
||||
],
|
||||
props: {
|
||||
showServer: {
|
||||
type: Boolean,
|
||||
},
|
||||
|
||||
content: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
|
||||
type: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
|
||||
server: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
|
||||
height: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
|
||||
fullTitle: {
|
||||
type: Boolean,
|
||||
},
|
||||
|
||||
img: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
|
||||
bottomOnly: {
|
||||
type: Boolean,
|
||||
},
|
||||
|
||||
spoilerFilter: {
|
||||
type: Boolean,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
fullheight: null,
|
||||
|
|
|
@ -23,7 +23,9 @@
|
|||
{{ label[0] }}
|
||||
</v-chip>
|
||||
</v-list-item-title>
|
||||
<v-list-item-subtitle>{{ object.product }} - last seen {{ lastSeenAgo }}</v-list-item-subtitle>
|
||||
<v-list-item-subtitle>
|
||||
{{ object.product }} - last seen {{ lastSeenAgo }}
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item-content>
|
||||
</v-list-item>
|
||||
</template>
|
||||
|
@ -33,7 +35,21 @@ const moment = require('moment');
|
|||
|
||||
export default {
|
||||
name: 'Plexclient',
|
||||
props: ['object', 'selected', 'startup', 'sidebar'],
|
||||
props: {
|
||||
object: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
|
||||
selected: {
|
||||
type: Boolean,
|
||||
},
|
||||
|
||||
sidebar: {
|
||||
type: Boolean,
|
||||
},
|
||||
},
|
||||
|
||||
data: () => ({
|
||||
platformMap: {
|
||||
android: 'android',
|
||||
|
@ -97,7 +113,7 @@ export default {
|
|||
},
|
||||
lastSeenAgo() {
|
||||
const now = moment(new Date().getTime());
|
||||
const end = moment.unix(parseInt(this.object.lastSeenAt));
|
||||
const end = moment.unix(parseInt(this.object.lastSeenAt, 10));
|
||||
const difference = moment.duration(now.diff(end));
|
||||
return `${difference.humanize()} ago`;
|
||||
},
|
||||
|
|
|
@ -4,8 +4,11 @@
|
|||
<h4 style="text-align:initial">
|
||||
Blocked Plex Servers
|
||||
</h4>
|
||||
<small>Used for autoplay functionality. Use this list to block SyncLounge from searching certain
|
||||
servers when attempting to autoplay content.</small>
|
||||
<small>
|
||||
Used for autoplay functionality.
|
||||
Use this list to block SyncLounge from searching certain servers when attempting to
|
||||
autoplay content.
|
||||
</small>
|
||||
<v-select
|
||||
v-model="BLOCKEDSERVERS"
|
||||
label="Select"
|
||||
|
@ -48,12 +51,14 @@ import { mapGetters, mapMutations } from 'vuex';
|
|||
|
||||
export default {
|
||||
name: 'Plexsettings',
|
||||
methods: {
|
||||
...mapMutations('settings', ['SET_HIDEUSERNAME', 'SET_ALTUSERNAME', 'SET_BLOCKEDSERVERS']),
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['getPlex']),
|
||||
...mapGetters('settings', ['GET_HIDEUSERNAME', 'GET_ALTUSERNAME', 'GET_BLOCKEDSERVERS']),
|
||||
...mapGetters('settings', [
|
||||
'GET_HIDEUSERNAME',
|
||||
'GET_ALTUSERNAME',
|
||||
'GET_BLOCKEDSERVERS',
|
||||
]),
|
||||
|
||||
BLOCKEDSERVERS: {
|
||||
get() {
|
||||
return this.GET_BLOCKEDSERVERS;
|
||||
|
@ -62,6 +67,7 @@ export default {
|
|||
this.SET_BLOCKEDSERVERS(value);
|
||||
},
|
||||
},
|
||||
|
||||
HIDEUSERNAME: {
|
||||
get() {
|
||||
return this.GET_HIDEUSERNAME;
|
||||
|
@ -70,28 +76,25 @@ export default {
|
|||
this.SET_HIDEUSERNAME(value);
|
||||
},
|
||||
},
|
||||
|
||||
localServersList() {
|
||||
// TODO: FIX THIS please
|
||||
const servers = [];
|
||||
if (!this.getPlex || !this.getPlex.servers) {
|
||||
return servers;
|
||||
return [];
|
||||
}
|
||||
for (const id in this.getPlex.servers) {
|
||||
const server = this.getPlex.servers[id];
|
||||
if (this.GET_BLOCKEDSERVERS[server]) {
|
||||
servers.push({
|
||||
name: server.name,
|
||||
id: server.clientIdentifier,
|
||||
});
|
||||
return;
|
||||
}
|
||||
servers.push({
|
||||
name: server.name,
|
||||
id: server.clientIdentifier,
|
||||
});
|
||||
}
|
||||
return servers;
|
||||
|
||||
return this.getPlex.servers.map((server) => ({
|
||||
server: server.name,
|
||||
id: server.clientIdentifier,
|
||||
}));
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
...mapMutations('settings', [
|
||||
'SET_HIDEUSERNAME',
|
||||
'SET_ALTUSERNAME',
|
||||
'SET_BLOCKEDSERVERS',
|
||||
]),
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -83,7 +83,9 @@
|
|||
:input-value="GET_SLPLAYERFORCETRANSCODE"
|
||||
@change="SET_SLPLAYERFORCETRANSCODE"
|
||||
/>
|
||||
<small>WARNING: EXPERIMENTAL SETTING! DO NOT CHANGE IF YOU DO NOT UNDERSTAND THE RAMIFICATIONS.</small>
|
||||
<small>
|
||||
WARNING: EXPERIMENTAL SETTING! DO NOT CHANGE IF YOU DO NOT UNDERSTAND THE RAMIFICATIONS.
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
@ -252,7 +252,7 @@ export default {
|
|||
components: {
|
||||
plexclient,
|
||||
},
|
||||
props: ['object'],
|
||||
|
||||
data() {
|
||||
return {
|
||||
testClient: null,
|
||||
|
@ -313,11 +313,11 @@ export default {
|
|||
}
|
||||
},
|
||||
isHttps() {
|
||||
return location.protocol === 'https:';
|
||||
return window.location.protocol === 'https:';
|
||||
},
|
||||
platform() {
|
||||
if (!this.testClient || !this.testClient.platform) {
|
||||
return;
|
||||
return '';
|
||||
}
|
||||
return (
|
||||
this.platformMap[this.testClient.platform.toLowerCase()]
|
||||
|
@ -392,7 +392,7 @@ export default {
|
|||
this.CHOOSE_CLIENT(client);
|
||||
this.gotResponse = true;
|
||||
})
|
||||
.catch((e) => {
|
||||
.catch(() => {
|
||||
if (client.clientIdentifier !== this.testClient.clientIdentifier) {
|
||||
return;
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ export default {
|
|||
},
|
||||
lastSeenAgo(clientTime) {
|
||||
const now = moment(new Date().getTime());
|
||||
const end = moment.unix(parseInt(clientTime));
|
||||
const end = moment.unix(parseInt(clientTime, 10));
|
||||
const difference = moment.duration(now.diff(end));
|
||||
return `${difference.humanize()} ago`;
|
||||
},
|
||||
|
|
|
@ -69,7 +69,9 @@
|
|||
style="opacity:0.7"
|
||||
class="text-center pt-3"
|
||||
>
|
||||
SyncLounge is a tool to sync Plex content with your family and friends. For more info click <a
|
||||
SyncLounge is a tool to sync Plex content with your family and friends.
|
||||
For more info click
|
||||
<a
|
||||
target="_blank"
|
||||
href="https://github.com/samcm/synclounge"
|
||||
> here</a>.
|
||||
|
@ -97,21 +99,7 @@ export default {
|
|||
owner: null,
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
gotDevices(to) {
|
||||
if (to) {
|
||||
if (this.$route.query.autojoin) {
|
||||
this.letsGo();
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.password = this.$route.query.password || '';
|
||||
this.room = this.$route.query.room;
|
||||
this.server = this.$route.query.server;
|
||||
this.owner = this.$route.query.owner;
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapGetters('settings', [
|
||||
'GET_PLEX_AUTH_TOKEN',
|
||||
|
@ -129,6 +117,22 @@ export default {
|
|||
return !this.$store.state.plex.gotDevices;
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
gotDevices(to) {
|
||||
if (to) {
|
||||
if (this.$route.query.autojoin) {
|
||||
this.letsGo();
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.password = this.$route.query.password || '';
|
||||
this.room = this.$route.query.room;
|
||||
this.server = this.$route.query.server;
|
||||
this.owner = this.$route.query.owner;
|
||||
},
|
||||
methods: {
|
||||
async letsGo() {
|
||||
this.$store.commit('SET_AUTOJOIN', true);
|
||||
|
|
|
@ -246,6 +246,7 @@ export default {
|
|||
let authToken = null;
|
||||
// Check for PlexToken set via SyncLounge or Plex
|
||||
if ($cookies.get('mpt')) {
|
||||
console.log('WTFFFFFFFFFFF');
|
||||
authToken = $cookies.get('mpt');
|
||||
}
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@
|
|||
>
|
||||
<donate
|
||||
:donate-dialog="donateDialog"
|
||||
:on-close="() => this.donateDialog = false"
|
||||
:on-close="donateDialog = false"
|
||||
/>
|
||||
</v-dialog>
|
||||
</v-navigation-drawer>
|
||||
|
@ -302,20 +302,20 @@ export default {
|
|||
return user.role === 'host';
|
||||
},
|
||||
percent(user) {
|
||||
let perc = (parseInt(user.time) / parseInt(user.maxTime)) * 100;
|
||||
if (isNaN(perc)) {
|
||||
let perc = (parseInt(user.time, 10) / parseInt(user.maxTime, 10)) * 100;
|
||||
if (Number.isNaN(perc)) {
|
||||
perc = 0;
|
||||
}
|
||||
return perc;
|
||||
},
|
||||
getCurrent(user) {
|
||||
if (isNaN(user.time)) {
|
||||
if (Number.isNaN(user.time)) {
|
||||
return this.getTimeFromMs(0);
|
||||
}
|
||||
return this.getTimeFromMs(user.time);
|
||||
},
|
||||
getMax(user) {
|
||||
if (isNaN(user.maxTime)) {
|
||||
if (Number.isNaN(user.maxTime)) {
|
||||
return this.getTimeFromMs(0);
|
||||
}
|
||||
return this.getTimeFromMs(user.maxTime);
|
||||
|
|
|
@ -152,9 +152,3 @@ new Vue({
|
|||
vuetify,
|
||||
render: (h) => h(App),
|
||||
}).$mount('#app');
|
||||
|
||||
global.waitFor = async (ms) => new Promise((resolve) => {
|
||||
setTimeout(() => resolve, ms);
|
||||
});
|
||||
|
||||
global.to = (promise) => promise.then((data) => [null, data]).catch((err) => [err]);
|
||||
|
|
|
@ -7,55 +7,59 @@ const _PlexAuth = require('./PlexAuth.js');
|
|||
const PlexAuth = new _PlexAuth();
|
||||
const stringSimilarity = require('string-similarity');
|
||||
|
||||
module.exports = function PlexClient() {
|
||||
this.commandId = 0;
|
||||
this.name = null;
|
||||
this.product = null;
|
||||
this.productVersion = null;
|
||||
this.platform = null;
|
||||
this.platformVersion = null;
|
||||
this.device = null;
|
||||
this.clientIdentifier = null;
|
||||
this.createdAt = null;
|
||||
this.lastSeenAt = null;
|
||||
this.provides = null;
|
||||
this.owned = null;
|
||||
this.publicAddressMatches = null;
|
||||
this.presence = null;
|
||||
this.plexConnections = null;
|
||||
this.chosenConnection = null;
|
||||
this.httpServer = null;
|
||||
this.tempId = null;
|
||||
this.events = new EventEmitter();
|
||||
this.labels = [];
|
||||
class PlexClient {
|
||||
constructor() {
|
||||
this.commandId = 0;
|
||||
this.name = null;
|
||||
this.product = null;
|
||||
this.productVersion = null;
|
||||
this.platform = null;
|
||||
this.platformVersion = null;
|
||||
this.device = null;
|
||||
this.clientIdentifier = null;
|
||||
this.createdAt = null;
|
||||
this.lastSeenAt = null;
|
||||
this.provides = null;
|
||||
this.owned = null;
|
||||
this.publicAddressMatches = null;
|
||||
this.presence = null;
|
||||
this.plexConnections = null;
|
||||
this.chosenConnection = null;
|
||||
this.httpServer = null;
|
||||
this.tempId = null;
|
||||
this.events = new EventEmitter();
|
||||
this.labels = [];
|
||||
|
||||
this.lastSyncCommand = 0;
|
||||
this.lastSyncCommand = 0;
|
||||
|
||||
this.userData = null;
|
||||
this.userData = null;
|
||||
|
||||
// Latest objects for reference in the future
|
||||
this.lastRatingKey = null;
|
||||
this.lastTimelineObject = null;
|
||||
this.oldTimelineObject = null;
|
||||
this.lastTimeline = null;
|
||||
this.oldTimeline = null;
|
||||
this.clientPlayingMetadata = null;
|
||||
this.lastSubscribe = 0;
|
||||
this.connectedstatus = 'fresh';
|
||||
// Latest objects for reference in the future
|
||||
this.lastRatingKey = null;
|
||||
this.lastTimelineObject = null;
|
||||
this.oldTimelineObject = null;
|
||||
this.lastTimeline = null;
|
||||
this.oldTimeline = null;
|
||||
this.clientPlayingMetadata = null;
|
||||
this.lastSubscribe = 0;
|
||||
this.connectedstatus = 'fresh';
|
||||
|
||||
this.eventbus = window.EventBus; // We will use this to communicate with the SLPlayer
|
||||
this.commit = null;
|
||||
this.dispatch = null;
|
||||
this.eventbus = window.EventBus; // We will use this to communicate with the SLPlayer
|
||||
this.commit = null;
|
||||
this.dispatch = null;
|
||||
|
||||
let previousTimeline = {};
|
||||
const differenceCache = [];
|
||||
let previousTimeline = {};
|
||||
const differenceCache = [];
|
||||
|
||||
this.setValue = function (key, value) {
|
||||
this.uuid = this.generateGuid();
|
||||
}
|
||||
|
||||
setValue (key, value) {
|
||||
this[key] = value;
|
||||
this.commit('PLEX_CLIENT_SET_VALUE', [this, key, value]);
|
||||
};
|
||||
|
||||
this.generateGuid = function () {
|
||||
generateGuid () {
|
||||
function s4() {
|
||||
return Math.floor((1 + Math.random()) * 0x10000)
|
||||
.toString(16)
|
||||
|
@ -64,9 +68,8 @@ module.exports = function PlexClient() {
|
|||
|
||||
return `${s4() + s4()}-${s4()}`;
|
||||
};
|
||||
this.uuid = this.generateGuid();
|
||||
|
||||
this.hitApi = async function (command, params, connection, needResponse, dontSub) {
|
||||
async hitApi (command, params, connection, needResponse, dontSub) {
|
||||
if (this.clientIdentifier === 'PTPLAYER9PLUS10') {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
// We are using the SyncLounge Player
|
||||
|
@ -110,7 +113,7 @@ module.exports = function PlexClient() {
|
|||
return true;
|
||||
};
|
||||
|
||||
this.getTimeline = function () {
|
||||
getTimeline () {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
let data;
|
||||
try {
|
||||
|
@ -126,7 +129,7 @@ module.exports = function PlexClient() {
|
|||
// Get the timeline object from the client
|
||||
};
|
||||
|
||||
this.updateTimelineObject = function (result) {
|
||||
updateTimelineObject (result) {
|
||||
// Check if we are the SLPlayer
|
||||
if (this.clientIdentifier === 'PTPLAYER9PLUS10') {
|
||||
// SLPLAYER
|
||||
|
@ -164,24 +167,28 @@ module.exports = function PlexClient() {
|
|||
// this.setValue('lastTimelineObject', videoTimeline)
|
||||
return videoTimeline;
|
||||
};
|
||||
this.pressPlay = function () {
|
||||
|
||||
pressPlay () {
|
||||
// Press play on the client
|
||||
return this.hitApi('/player/playback/play', { wait: 0 });
|
||||
};
|
||||
|
||||
this.pressPause = function () {
|
||||
pressPause () {
|
||||
// Press pause on the client
|
||||
return this.hitApi('/player/playback/pause', { wait: 0 });
|
||||
};
|
||||
this.pressStop = function () {
|
||||
|
||||
pressStop () {
|
||||
// Press pause on the client
|
||||
return this.hitApi('/player/playback/stop', { wait: 0 });
|
||||
};
|
||||
this.seekTo = function (time, params) {
|
||||
|
||||
seekTo (time, params) {
|
||||
// Seek to a time (in ms)
|
||||
return this.hitApi('/player/playback/seekTo', { wait: 0, offset: Math.round(time), ...params });
|
||||
};
|
||||
this.waitForMovement = function (startTime) {
|
||||
|
||||
waitForMovement (startTime) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let time = 500;
|
||||
if (this.clientIdentifier === 'PTPLAYER9PLUS10') {
|
||||
|
@ -197,7 +204,8 @@ module.exports = function PlexClient() {
|
|||
}, time);
|
||||
});
|
||||
};
|
||||
this.skipAhead = function (current, duration) {
|
||||
|
||||
skipAhead (current, duration) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const startedAt = new Date().getTime();
|
||||
const now = this.lastTimelineObject.time;
|
||||
|
@ -212,13 +220,15 @@ module.exports = function PlexClient() {
|
|||
resolve();
|
||||
});
|
||||
};
|
||||
this.cleanSeek = function (time, isSoft) {
|
||||
|
||||
cleanSeek (time, isSoft) {
|
||||
if (isSoft && this.clientIdentifier === 'PTPLAYER9PLUS10') {
|
||||
return this.seekTo(time, { softSeek: true });
|
||||
}
|
||||
return this.seekTo(time);
|
||||
};
|
||||
this.sync = function sync(hostTimeline, SYNCFLEXIBILITY, SYNCMODE, POLLINTERVAL) {
|
||||
|
||||
sync (hostTimeline, SYNCFLEXIBILITY, SYNCMODE, POLLINTERVAL) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
if (this.clientIdentifier === 'PTPLAYER9PLUS10') {
|
||||
await this.getTimeline();
|
||||
|
@ -268,7 +278,8 @@ module.exports = function PlexClient() {
|
|||
return resolve('No sync needed');
|
||||
});
|
||||
};
|
||||
this.playMedia = async function (data) {
|
||||
|
||||
async playMedia (data) {
|
||||
// Play a media item given a mediaId key and a server to play from
|
||||
// We need the following variables to build our paramaters:
|
||||
// MediaId Key, Offset, server MachineId,
|
||||
|
@ -309,7 +320,7 @@ module.exports = function PlexClient() {
|
|||
});
|
||||
};
|
||||
|
||||
this.playContentAutomatically = function (client, hostData, servers, offset) {
|
||||
playContentAutomatically (client, hostData, servers, offset) {
|
||||
// Automatically play content on the client searching all servers based on the title
|
||||
return new Promise(async (resolve, reject) => {
|
||||
// First lets find all of our playable items
|
||||
|
@ -387,9 +398,4 @@ module.exports = function PlexClient() {
|
|||
}
|
||||
});
|
||||
};
|
||||
const wait = (ms) => new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve(ms);
|
||||
}, ms);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -5,38 +5,40 @@ const _PlexAuth = require('./PlexAuth.js');
|
|||
const PlexAuth = new _PlexAuth();
|
||||
|
||||
|
||||
module.exports = function PlexServer() {
|
||||
this.name = '';
|
||||
this.product = '';
|
||||
this.productVersion = '';
|
||||
this.platform = '';
|
||||
this.platformVersion = '';
|
||||
this.device = '';
|
||||
this.clientIdentifier = '';
|
||||
this.createdAt = '';
|
||||
this.lastSeenAt = '';
|
||||
this.provides = '';
|
||||
this.owned = '';
|
||||
this.httpsRequired = '';
|
||||
this.ownerId = '';
|
||||
this.accessToken = '';
|
||||
this.sourceTitle = '';
|
||||
this.synced = '';
|
||||
this.relay = '';
|
||||
this.publicAddressMatches = '';
|
||||
this.presence = '';
|
||||
this.plexConnections = '';
|
||||
this.chosenConnection = null;
|
||||
class PlexServer {
|
||||
constructor() {
|
||||
this.name = '';
|
||||
this.product = '';
|
||||
this.productVersion = '';
|
||||
this.platform = '';
|
||||
this.platformVersion = '';
|
||||
this.device = '';
|
||||
this.clientIdentifier = '';
|
||||
this.createdAt = '';
|
||||
this.lastSeenAt = '';
|
||||
this.provides = '';
|
||||
this.owned = '';
|
||||
this.httpsRequired = '';
|
||||
this.ownerId = '';
|
||||
this.accessToken = '';
|
||||
this.sourceTitle = '';
|
||||
this.synced = '';
|
||||
this.relay = '';
|
||||
this.publicAddressMatches = '';
|
||||
this.presence = '';
|
||||
this.plexConnections = '';
|
||||
this.chosenConnection = null;
|
||||
|
||||
this.commit = null;
|
||||
this.commit = null;
|
||||
}
|
||||
|
||||
this.setValue = function (key, value) {
|
||||
setValue(key, value) {
|
||||
this[key] = value;
|
||||
this.commit('PLEX_SERVER_SET_VALUE', [this, key, value]);
|
||||
};
|
||||
}
|
||||
|
||||
// Functions
|
||||
this.hitApi = function (command, params) {
|
||||
hitApi(command, params) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
if (!this.chosenConnection) {
|
||||
|
@ -62,17 +64,20 @@ module.exports = function PlexServer() {
|
|||
reject(e);
|
||||
}
|
||||
});
|
||||
};
|
||||
this.hitApiTestConnection = async function (command, connection) {
|
||||
}
|
||||
|
||||
async hitApiTestConnection(command, connection) {
|
||||
const _url = connection.uri + command;
|
||||
const config = PlexAuth.getRequestConfig(this.accessToken, 7500);
|
||||
const { data } = await axios.get(_url, config);
|
||||
return data;
|
||||
};
|
||||
this.setChosenConnection = function (con) {
|
||||
}
|
||||
|
||||
setChosenConnection(con) {
|
||||
this.chosenConnection = con;
|
||||
};
|
||||
this.findConnection = function () {
|
||||
}
|
||||
|
||||
findConnection() {
|
||||
// This function iterates through all available connections and
|
||||
// if any of them return a valid response we'll set that connection
|
||||
// as the chosen connection for future use.
|
||||
|
@ -104,26 +109,26 @@ module.exports = function PlexServer() {
|
|||
reject(new Error('Unable to find a connection'));
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
// Functions for dealing with media
|
||||
this.search = async function (searchTerm) {
|
||||
async search(searchTerm) {
|
||||
// This function hits the PMS using the /search endpoint and returns what the server returns if valid
|
||||
return new Promise(async (resolve, reject) => {
|
||||
return new Promise(async (resolve) => {
|
||||
const result = await this.hitApi('/search', { query: searchTerm });
|
||||
const validResults = [];
|
||||
if (result && result.MediaContainer) {
|
||||
if (result.MediaContainer.Metadata) {
|
||||
for (let i = 0; i < result.MediaContainer.Metadata.length; i++) {
|
||||
for (let i = 0; i < result.MediaContainer.Metadata.length; i += 1) {
|
||||
validResults.push(result.MediaContainer.Metadata[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return resolve(validResults);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
this.getMediaByRatingKey = async function (ratingKey) {
|
||||
async getMediaByRatingKey(ratingKey) {
|
||||
// This function hits the PMS and returns the item at the ratingKey
|
||||
try {
|
||||
const data = await this.hitApi(`/library/metadata/${ratingKey}`, {});
|
||||
|
@ -140,19 +145,22 @@ module.exports = function PlexServer() {
|
|||
return false;
|
||||
}
|
||||
// return this.handleMetadata(data)
|
||||
};
|
||||
this.markWatchedByRatingKey = function (ratingKey) {
|
||||
}
|
||||
|
||||
markWatchedByRatingKey(ratingKey) {
|
||||
return this.hitApi('/:/scrobble', {
|
||||
identifier: 'com.plexapp.plugins.library',
|
||||
key: ratingKey,
|
||||
});
|
||||
};
|
||||
this.getPostplay = function (ratingKey) {
|
||||
}
|
||||
|
||||
getPostplay(ratingKey) {
|
||||
return this.hitApi(`/hubs/metadata/${ratingKey}/postplay`, {
|
||||
'X-Plex-Token': this.accessToken,
|
||||
});
|
||||
};
|
||||
this.getUrlForLibraryLoc = function (location, width, height, blur) {
|
||||
}
|
||||
|
||||
getUrlForLibraryLoc(location, width, height, blur) {
|
||||
if (!(blur > 0)) {
|
||||
blur = 0;
|
||||
}
|
||||
|
@ -162,8 +170,9 @@ module.exports = function PlexServer() {
|
|||
}&height=${Math.floor(height)}&width=${Math.floor(width)}&blur=${blur}`;
|
||||
}
|
||||
return '';
|
||||
};
|
||||
this.getRandomItem = async function () {
|
||||
}
|
||||
|
||||
async getRandomItem() {
|
||||
try {
|
||||
const data = await this.getAllLibraries();
|
||||
if (!data || !data.MediaContainer || !data.MediaContainer.Directory) {
|
||||
|
@ -182,8 +191,9 @@ module.exports = function PlexServer() {
|
|||
} catch (e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
};
|
||||
this.getAllLibraries = async function () {
|
||||
}
|
||||
|
||||
async getAllLibraries() {
|
||||
try {
|
||||
const data = await this.hitApi('/library/sections', {});
|
||||
if (data && data.MediaContainer) {
|
||||
|
@ -195,8 +205,9 @@ module.exports = function PlexServer() {
|
|||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
this.getLibraryContents = async function (key, start, size) {
|
||||
}
|
||||
|
||||
async getLibraryContents(key, start, size) {
|
||||
try {
|
||||
const data = await this.hitApi(`/library/sections/${key}/all`, {
|
||||
'X-Plex-Container-Start': start,
|
||||
|
@ -212,24 +223,28 @@ module.exports = function PlexServer() {
|
|||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
this.getRecentlyAddedAll = function (start, size) {
|
||||
}
|
||||
|
||||
getRecentlyAddedAll() {
|
||||
return this.hitApi('/library/recentlyAdded', {});
|
||||
};
|
||||
this.getOnDeck = function (start, size) {
|
||||
}
|
||||
|
||||
getOnDeck(start, size) {
|
||||
return this.hitApi('/library/onDeck', {
|
||||
'X-Plex-Container-Start': start,
|
||||
'X-Plex-Container-Size': size,
|
||||
});
|
||||
};
|
||||
this.getRelated = function (ratingKey, size) {
|
||||
}
|
||||
|
||||
getRelated(ratingKey, size) {
|
||||
ratingKey = ratingKey.replace('/library/metadata/', '');
|
||||
return this.hitApi(`/hubs/metadata/${ratingKey}/related`, {
|
||||
excludeFields: 'summary',
|
||||
count: size,
|
||||
});
|
||||
};
|
||||
this.getSeriesData = function (ratingKey) {
|
||||
}
|
||||
|
||||
getSeriesData(ratingKey) {
|
||||
return this.hitApi(`/library/metadata/${ratingKey}`, {
|
||||
includeConcerts: 1,
|
||||
includeExtras: 1,
|
||||
|
@ -239,9 +254,9 @@ module.exports = function PlexServer() {
|
|||
asyncRefreshAnalysis: 1,
|
||||
asyncRefreshLocalMediaAgent: 1,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
this.getSeriesChildren = async function (ratingKey, start, size, excludeAllLeaves, library) {
|
||||
async getSeriesChildren(ratingKey, start, size, excludeAllLeaves, library) {
|
||||
try {
|
||||
const data = await this.hitApi(`/library/metadata/${ratingKey}/children`, {
|
||||
'X-Plex-Container-Start': start,
|
||||
|
@ -249,7 +264,7 @@ module.exports = function PlexServer() {
|
|||
excludeAllLeaves,
|
||||
});
|
||||
if (library) {
|
||||
for (let i = 0; i < data.MediaContainer.Metadata.length; i++) {
|
||||
for (let i = 0; i < data.MediaContainer.Metadata.length; i += 1) {
|
||||
data.MediaContainer.Metadata[i].librarySectionID = library;
|
||||
// this.commit('SET_ITEMCACHE', [data.MediaContainer.Metadata[i].ratingKey,
|
||||
// data.MediaContainer.Metadata[i]])
|
||||
|
@ -259,9 +274,9 @@ module.exports = function PlexServer() {
|
|||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
this.handleMetadata = function (result) {
|
||||
handleMetadata(result) {
|
||||
// This data is used in our router breadcrumbs
|
||||
if (result) {
|
||||
if (
|
||||
|
@ -269,7 +284,7 @@ module.exports = function PlexServer() {
|
|||
&& result.MediaContainer.Metadata
|
||||
&& result.MediaContainer.Metadata.length > 0
|
||||
) {
|
||||
for (let i = 0; i < result.MediaContainer.Metadata.length; i++) {
|
||||
for (let i = 0; i < result.MediaContainer.Metadata.length; i += 1) {
|
||||
result.MediaContainer.Metadata[i].machineIdentifier = this.clientIdentifier;
|
||||
const item = result.MediaContainer.Metadata[i];
|
||||
if (result.MediaContainer.Metadata[i].ratingKey) {
|
||||
|
@ -313,5 +328,7 @@ module.exports = function PlexServer() {
|
|||
}
|
||||
return result.MediaContainer.Metadata;
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default PlexServer;
|
||||
|
|
Loading…
Reference in New Issue