Compare commits

...

8 Commits

10 changed files with 79 additions and 55 deletions

View File

@ -56,7 +56,7 @@ onMounted(async () => {
<h3 class="text-2xl font-semibold tracking-tight">
{{ props.item.title }}
</h3>
<p class="text-sm">
<p class="text-sm line-clamp-5">
{{ props.item.material_data?.description }}
</p>
<div class="flex items-center pt-2">

View File

@ -1,15 +1,29 @@
<script setup lang="ts">
import { Icon } from '@iconify/vue'
import type { RouteLocationNormalized } from 'vue-router'
import { updateUrlParameter } from '~/components/util/route'
const props = defineProps<Props>();
const route = useRoute()
const currentEpisode = computed(() => Number(route.query.episode as string))
</script>
<script lang="ts">
function changeEpisode(route: RouteLocationNormalized, props: Props, currentEpisode: number) {
let episodeOffset = 0
if (props.type == EpisodeChangeType.NEXT) {
episodeOffset = 1
}
if (props.type == EpisodeChangeType.PREVIOUS) {
episodeOffset = -1
}
updateUrlParameter(route, 'episode', String(currentEpisode + episodeOffset))
}
interface Props {
type: EpisodeChangeType;
}
const props = defineProps<Props>();
</script>
<script lang="ts">
export enum EpisodeChangeType {
NEXT = "mage:next-fill",
PREVIOUS = "mage:previous-fill",
@ -17,7 +31,7 @@ export enum EpisodeChangeType {
</script>
<template>
<UiButton variant="borderless" size="icon">
<UiButton v-on:click="changeEpisode(route, props, currentEpisode)" variant="borderless" size="icon">
<Icon :icon="props.type" class="size-5" />
</UiButton>
</template>

View File

@ -6,8 +6,7 @@ import { EpisodeChangeType } from "./ChangeEpisodeButton.vue";
import { UiPlayerChangeEpisodeButton } from "#components";
interface Props {
urls: any;
id: string;
urls: any[];
episodeButton: boolean;
}
@ -17,36 +16,12 @@ const props = withDefaults(defineProps<Props>(), {
const emit = defineEmits(['get-instance'])
const options = computed(() => {
const controls = []
if (props.episodeButton) {
controls.push(
createVueControlSmart(UiPlayerChangeEpisodeButton, {
name: "next-episode",
index: 50,
tooltip: "Next episode",
type: EpisodeChangeType.NEXT
}, {
click: () => console.log("NEXT")
})
)
controls.push(
createVueControlSmart(UiPlayerChangeEpisodeButton, {
name: "previous-episode",
index: 50,
tooltip: "Previous episode",
type: EpisodeChangeType.PREVIOUS
}, {
click: () => console.log("Previous")
})
)
}
return {
url: props.urls[0].url || '',
type: 'm3u8',
customType: {
m3u8: playM3u8,
},
quality: props.urls,
autoSize: true,
autoMini: true,
playbackRate: true,
@ -56,8 +31,6 @@ const options = computed(() => {
lock: true,
autoOrientation: true,
autoPlayback: true,
id: props.id,
controls: controls,
}
})
const artplayerRef = ref();
@ -83,6 +56,24 @@ onMounted(() => {
container: artplayerRef.value,
...options.value,
})
if (props.episodeButton) {
instance.value.controls.add(
createVueControlSmart(UiPlayerChangeEpisodeButton, {
name: "next-episode",
index: 50,
tooltip: "Next episode",
type: EpisodeChangeType.NEXT,
})
)
instance.value.controls.add(
createVueControlSmart(UiPlayerChangeEpisodeButton, {
name: "previous-episode",
index: 50,
tooltip: "Previous episode",
type: EpisodeChangeType.PREVIOUS,
})
)
}
nextTick(() => {
emit('get-instance')
})
@ -93,6 +84,14 @@ onBeforeUnmount(() => {
instance.value.destroy(false)
}
})
watch([instance, () => props.urls], async ([artplayer, urls]) => {
if (!artplayer) return;
urls = urls.reverse()
artplayer.quality = urls;
artplayer.switch = urls[0].url;
instance.value = artplayer;
})
</script>
<template>

View File

@ -14,8 +14,6 @@ export function createVueControlSmart(component, props = {}, events = {}) {
const container = $control.querySelector('.vue-control-wrapper')
if (container && !vueApp) {
console.log("111")
vueApp = createApp({
render() {
return h(component, {

View File

@ -0,0 +1,9 @@
export const updateUrlParameter = async (route, paramName, newValue) => {
await navigateTo({
path: route.path,
query: {
...route.query,
[paramName]: newValue
}
}, { replace: true })
}

View File

@ -8,8 +8,7 @@
<p>Episode: {{ episode }}</p>
<div v-if="hlsUrls">
<Player :id="mediaId.toString().concat(episode?.toString() || '')" :urls="hlsUrls" :episode="episode"
:episodeButton="true" />
<Player :urls="hlsUrls" :episode="episode" :episodeButton="true" />
</div>
<!-- Loading and Error States -->
@ -28,10 +27,10 @@ import { Player } from '~/components/ui/player'
import { video, type KodikVideoLinks } from '~/openapi/extractor'
const route = useRoute()
const mediaType = route.query.mediaType
const mediaId = route.query.mediaId
const mediaHash = route.query.mediaHash
const episode = route.query.episode
const mediaType = computed(() => route.query.mediaType as string)
const mediaId = computed(() => route.query.mediaId as string)
const mediaHash = computed(() => route.query.mediaHash as string)
const episode = computed(() => Number(route.query.episode as string))
const results = ref<KodikVideoLinks | null>(null)
const isLoading = ref(false)
@ -39,17 +38,15 @@ const error = ref<unknown>(null)
const hlsUrls = ref<any>(null)
watchEffect(async () => {
if (!mediaType || !mediaId || !mediaHash || !episode) return
try {
isLoading.value = true
error.value = null
const videoParams: any = {
mediaType: mediaType as string,
mediaId: mediaId as string,
mediaHash: mediaHash as string,
episode: Number(episode as string),
mediaType: mediaType.value,
mediaId: mediaId.value,
mediaHash: mediaHash.value,
episode: episode.value,
quality: '360',
}
@ -57,11 +54,13 @@ watchEffect(async () => {
results.value = response?.data || null
if (results.value?.links) {
hlsUrls.value = Object.entries(results.value.links).map(([quality, links], index) => {
console.log(results.value.links)
hlsUrls.value = Object.entries(results.value.links).map(([quality, links], index, arr) => {
const isLatest = index === arr.length - 1
return {
html: quality,
url: links.find(link => link.src?.includes('.m3u8') || link.type?.includes('hls'))?.src,
default: index === 0
default: isLatest
}
})

View File

@ -29,6 +29,7 @@
},
"devDependencies": {
"@iconify-json/heroicons": "^1.2.2",
"@iconify-json/mage": "^1.2.4",
"@nuxtjs/color-mode": "^3.5.2",
"orval": "^7.10.0",
},
@ -227,6 +228,8 @@
"@iconify-json/heroicons": ["@iconify-json/heroicons@1.2.2", "", { "dependencies": { "@iconify/types": "*" } }, "sha512-qoW4pXr5kTTL6juEjgTs83OJIwpePu7q1tdtKVEdj+i0zyyVHgg/dd9grsXJQnpTpBt6/VwNjrXBvFjRsKPENg=="],
"@iconify-json/mage": ["@iconify-json/mage@1.2.4", "", { "dependencies": { "@iconify/types": "*" } }, "sha512-QZnjHtV/RP9/bF6n7bHSnXMPX/MW5dpHqOH2pEHiEytUx76OKrUZ55YBFwrAxPz5f3BoCeWMY1wyEQQD36Bkkw=="],
"@iconify/collections": ["@iconify/collections@1.0.569", "", { "dependencies": { "@iconify/types": "*" } }, "sha512-PclOVcAlvv55Fv5kRJmxk/KMoFLNBMLh0q9LDMlonIPJMUu958VsNw7F7CVurfyEbCf/54i7eF+q6LHqJxeQvg=="],
"@iconify/types": ["@iconify/types@2.0.0", "", {}, "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg=="],

View File

@ -4,7 +4,8 @@ services:
ports:
- 3000:3000
networks:
- anyame
- anyame-shared
networks:
anyame:
driver: bridge
anyame-shared:
external: true

View File

@ -1,6 +1,6 @@
// @ts-check
import withNuxt from '.nuxt/eslint.config.mjs'
import withNuxt from './.nuxt/eslint.config.mjs'
export default withNuxt(
// Your custom configs here
// Your custom configs here
)

View File

@ -35,6 +35,7 @@
},
"devDependencies": {
"@iconify-json/heroicons": "^1.2.2",
"@iconify-json/mage": "^1.2.4",
"@nuxtjs/color-mode": "^3.5.2",
"orval": "^7.10.0"
}