parent
8e2300bf53
commit
9938dcc3bc
@ -1,52 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import MediaScroller from './MediaScroller.vue'
|
||||
import { ContinueWatching } from '@/feed'
|
||||
import type { FeedItem } from '@/feed'
|
||||
|
||||
const Items = (): FeedItem[] => {
|
||||
// const feed = []
|
||||
// jfapi
|
||||
// .GetNextUp('http://192.168.0.63:30013')
|
||||
// .then((data) => {
|
||||
// for (const item of data.Items) {
|
||||
// const thumbtag = item.ImageTags.Thumb ? item.ImageTags.Thumb : ''
|
||||
// let summary = ''
|
||||
// jfapi.GetItem('http://192.168.0.63:30013', '', item.Id).then((item) => {
|
||||
// summary = item.Overview !== undefined ? item.Overview : ''
|
||||
// })
|
||||
// feed.push({
|
||||
// title: item.SeriesName,
|
||||
// subtext: `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`,
|
||||
// image: jfapi.ThumbImageUrl('http://192.168.0.63:30013', item.Id, thumbtag),
|
||||
// summary: summary,
|
||||
// infoSubtext: `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`,
|
||||
// imdbRating: item.CommunityRating,
|
||||
// runtime: getDisplayDuration(item.RunTimeTicks),
|
||||
// date: item.ProductionYear,
|
||||
// MPAA: item.OfficialRating,
|
||||
// })
|
||||
// }
|
||||
// return feed
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// return err
|
||||
// })
|
||||
return ContinueWatching
|
||||
}
|
||||
|
||||
// function getDisplayDuration(ticks: number) {
|
||||
// const totalMinutes = Math.round(ticks / 600000000) || 1
|
||||
// const totalHours = Math.floor(totalMinutes / 60)
|
||||
// const remainderMinutes = totalMinutes % 60
|
||||
// const result = []
|
||||
// if (totalHours > 0) {
|
||||
// result.push(`${totalHours}h`)
|
||||
// }
|
||||
// result.push(`${remainderMinutes}m`)
|
||||
// return result.join(' ')
|
||||
// }
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<MediaScroller title="Continue Watching" landscape :items="Items()" />
|
||||
</template>
|
||||
@ -0,0 +1,87 @@
|
||||
<script setup lang="ts">
|
||||
import jfapi from '@/jfapi'
|
||||
import MediaScroller from './MediaScroller.vue'
|
||||
import type { FeedItem } from '@/feed'
|
||||
import type { Item, View } from '@/jfapi'
|
||||
|
||||
const props = defineProps<{
|
||||
view: View
|
||||
}>()
|
||||
|
||||
const Items = async (): Promise<FeedItem[]> => {
|
||||
return new Promise(async (resolve) => {
|
||||
const feed: FeedItem[] = []
|
||||
const userid = localStorage.getItem('jf_userid')
|
||||
const data = await jfapi.GetLatest(userid ? userid : '', props.view)
|
||||
if (data !== null) {
|
||||
console.log(data)
|
||||
for (const item of data) {
|
||||
const summary = ''
|
||||
if (userid === null) {
|
||||
window.location.href = '/login'
|
||||
}
|
||||
// const fullitem = await jfapi.GetItem(userid, item.Id)
|
||||
// if (fullitem === null) {
|
||||
// continue
|
||||
// } else {
|
||||
// summary = fullitem.Overview
|
||||
// }
|
||||
feed.push({
|
||||
title: item.SeriesName || item.Name,
|
||||
subtext: item.SeriesName
|
||||
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||
: String(item.ProductionYear),
|
||||
image: getImageLink(item),
|
||||
summary: summary,
|
||||
// infoSubtext: item.SeriesName
|
||||
// ? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||
// : fullitem.OriginalTitle != item.Name
|
||||
// ? fullitem.OriginalTitle
|
||||
// : '',
|
||||
infoSubtext: '',
|
||||
imdbRating: String(item.CommunityRating),
|
||||
runtime: getDisplayDuration(item.RunTimeTicks),
|
||||
date: String(item.ProductionYear),
|
||||
MPAA: item.OfficialRating,
|
||||
tag:
|
||||
item.UserData?.UnplayedItemCount !== undefined
|
||||
? String(item.UserData.UnplayedItemCount)
|
||||
: '',
|
||||
itemId: item.Id,
|
||||
})
|
||||
}
|
||||
console.log('LatestMedia.vue =>', feed)
|
||||
resolve(feed)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function getImageLink(item: Item): string {
|
||||
if (item.SeriesId === undefined) {
|
||||
// using movie primary
|
||||
return jfapi.PrimaryImageUrl(item.Id, item.ImageTags.Primary ? item.ImageTags.Primary : '')
|
||||
} else {
|
||||
// using series primary
|
||||
return jfapi.PrimaryImageUrl(
|
||||
item.SeriesId,
|
||||
item.SeriesPrimaryImageTag ? item.SeriesPrimaryImageTag[0] : '',
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function getDisplayDuration(ticks: number) {
|
||||
const totalMinutes = Math.round(ticks / 600000000) || 1
|
||||
const totalHours = Math.floor(totalMinutes / 60)
|
||||
const remainderMinutes = totalMinutes % 60
|
||||
const result = []
|
||||
if (totalHours > 0) {
|
||||
result.push(`${totalHours}h`)
|
||||
}
|
||||
result.push(`${remainderMinutes}m`)
|
||||
return result.join(' ')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<MediaScroller :title="`Latest ${view?.Name}`" :feed-items="Items()" />
|
||||
</template>
|
||||
@ -0,0 +1,75 @@
|
||||
<script setup lang="ts">
|
||||
import jfapi from '@/jfapi'
|
||||
import MediaScroller from './MediaScroller.vue'
|
||||
import type { FeedItem } from '@/feed'
|
||||
import type { Item } from '@/jfapi'
|
||||
|
||||
const Items = async (): Promise<FeedItem[]> => {
|
||||
return new Promise(async (resolve) => {
|
||||
const feed: FeedItem[] = []
|
||||
const data = await jfapi.GetNextUp()
|
||||
if (data !== null) {
|
||||
for (const item of data.Items) {
|
||||
const summary = ''
|
||||
const userid = localStorage.getItem('jf_userid')
|
||||
if (userid === null) {
|
||||
window.location.href = '/login'
|
||||
}
|
||||
// const fullitem = await jfapi.GetItem(userid ? userid : '', item.Id)
|
||||
// if (fullitem === null) {
|
||||
// summary = 'Failed to fetch content.'
|
||||
// } else {
|
||||
// summary = fullitem.Overview
|
||||
// }
|
||||
feed.push({
|
||||
title: item.SeriesName !== undefined ? item.SeriesName : '',
|
||||
subtext: `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`,
|
||||
image: getImageLink(item),
|
||||
summary: summary,
|
||||
infoSubtext: `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`,
|
||||
imdbRating: String(item.CommunityRating),
|
||||
runtime: getDisplayDuration(item.RunTimeTicks),
|
||||
date: String(item.ProductionYear),
|
||||
MPAA: item.OfficialRating,
|
||||
itemId: item.Id,
|
||||
tag: '',
|
||||
})
|
||||
}
|
||||
console.log('NextUp.vue =>', feed)
|
||||
resolve(feed)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function getImageLink(item: Item): string {
|
||||
if (item.ParentThumbItemId === undefined) {
|
||||
// using backdrop
|
||||
return jfapi.BackdropImageUrl(
|
||||
item.ParentBackdropItemId ? item.ParentBackdropItemId : '',
|
||||
item.ParentBackdropImageTags ? item.ParentBackdropImageTags[0] : '',
|
||||
)
|
||||
} else {
|
||||
// using thumb
|
||||
return jfapi.ThumbImageUrl(
|
||||
item.ParentThumbItemId,
|
||||
item.ParentThumbImageTag ? item.ParentThumbImageTag : '',
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function getDisplayDuration(ticks: number) {
|
||||
const totalMinutes = Math.round(ticks / 600000000) || 1
|
||||
const totalHours = Math.floor(totalMinutes / 60)
|
||||
const remainderMinutes = totalMinutes % 60
|
||||
const result = []
|
||||
if (totalHours > 0) {
|
||||
result.push(`${totalHours}h`)
|
||||
}
|
||||
result.push(`${remainderMinutes}m`)
|
||||
return result.join(' ')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<MediaScroller title="Next Up" landscape :feed-items="Items()" />
|
||||
</template>
|
||||
@ -1,29 +1,22 @@
|
||||
import { ref } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
type UserData = {
|
||||
host?: string
|
||||
id?: string
|
||||
name?: string
|
||||
views?: [View]
|
||||
}
|
||||
type View = {
|
||||
name: string
|
||||
mediaType: string
|
||||
id: string
|
||||
}
|
||||
import type { User, View } from '@/jfapi'
|
||||
|
||||
export const useDataStore = defineStore('data', () => {
|
||||
const data = ref<UserData>({})
|
||||
function setServerHost(host: string) {
|
||||
data.value.host = host
|
||||
}
|
||||
function setViews(views: [View]) {
|
||||
data.value.views = views
|
||||
}
|
||||
function setUser(id: string, name: string) {
|
||||
data.value.id = id
|
||||
data.value.name = name
|
||||
const data = ref<User>({
|
||||
Name: '',
|
||||
Host: '',
|
||||
Id: '',
|
||||
})
|
||||
// function setServerHost(host: string) {
|
||||
// data.value.Host = host
|
||||
// }
|
||||
function setViews(views: View[]) {
|
||||
data.value.Views = views
|
||||
}
|
||||
return { data, setServerHost, setViews, setUser }
|
||||
// function setUser(id: string, name: string) {
|
||||
// data.value.Id = id
|
||||
// data.value.Name = name
|
||||
// }
|
||||
return { setViews }
|
||||
})
|
||||
|
||||
Loading…
Reference in new issue