Playlist go to last item in watch history
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||||
|
const CapacitorNodejs = require('../../../node_modules/capacitor-nodejs/electron/dist/plugin.js');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
CapacitorNodejs,
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,6 @@ import { Helpers, YTNodes } from 'youtubei.js';
|
|||||||
export function invidiousItemSchema(item: Helpers.YTNode): Video | Channel | Playlist | undefined {
|
export function invidiousItemSchema(item: Helpers.YTNode): Video | Channel | Playlist | undefined {
|
||||||
if (item.is(YTNodes.Video)) {
|
if (item.is(YTNodes.Video)) {
|
||||||
const views = extractNumber(item.view_count?.toString() || '');
|
const views = extractNumber(item.view_count?.toString() || '');
|
||||||
console.log(item);
|
|
||||||
return {
|
return {
|
||||||
type: 'video',
|
type: 'video',
|
||||||
title: item.title.toString(),
|
title: item.title.toString(),
|
||||||
|
|||||||
@@ -51,7 +51,6 @@ const zFilterRootSchema = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export function isItemFiltered(item: FeedItem): boolean {
|
export function isItemFiltered(item: FeedItem): boolean {
|
||||||
console.log(item);
|
|
||||||
const filteredContent = get(filterContentListStore);
|
const filteredContent = get(filterContentListStore);
|
||||||
if (!filteredContent) return false;
|
if (!filteredContent) return false;
|
||||||
|
|
||||||
|
|||||||
@@ -7,29 +7,63 @@
|
|||||||
import ItemsList from '$lib/components/layout/ItemsList.svelte';
|
import ItemsList from '$lib/components/layout/ItemsList.svelte';
|
||||||
import Share from '$lib/components/Share.svelte';
|
import Share from '$lib/components/Share.svelte';
|
||||||
import { page } from '$app/state';
|
import { page } from '$app/state';
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
import type { VideoWatchHistory } from '$lib/api/model.js';
|
||||||
|
import { getWatchHistory } from '$lib/api/index.js';
|
||||||
|
|
||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
|
|
||||||
|
async function loadLastWatched() {
|
||||||
|
const videoIds = data.playlist.videos.map((video) => video.videoId);
|
||||||
|
|
||||||
|
let lastHistory: VideoWatchHistory[] = [];
|
||||||
|
|
||||||
|
let page = 0;
|
||||||
|
while (true) {
|
||||||
|
const historyPage = await getWatchHistory({ page, videoIds });
|
||||||
|
|
||||||
|
if (historyPage.length === 0) break;
|
||||||
|
|
||||||
|
lastHistory = historyPage;
|
||||||
|
|
||||||
|
page++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lastHistory.length > 0) {
|
||||||
|
goto(
|
||||||
|
resolve(
|
||||||
|
$isAndroidTvStore
|
||||||
|
? `/tv/[videoId]?playlist=${data.playlist.info.playlistId}`
|
||||||
|
: `/watch/[videoId]?playlist=${data.playlist.info.playlistId}`,
|
||||||
|
{
|
||||||
|
videoId: lastHistory[0].videoId
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
goto(
|
||||||
|
resolve(
|
||||||
|
$isAndroidTvStore
|
||||||
|
? `/tv/[videoId]?playlist=${data.playlist.info.playlistId}`
|
||||||
|
: `/watch/[videoId]?playlist=${data.playlist.info.playlistId}`,
|
||||||
|
{
|
||||||
|
videoId: data.playlist.videos[0].videoId
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<article class="border padding">
|
<article class="border padding">
|
||||||
{#if data.playlist.videos.length > 0}
|
{#if data.playlist.videos.length > 0}
|
||||||
<nav>
|
<nav>
|
||||||
<a
|
<button onclick={loadLastWatched} class="button circle extra no-margin">
|
||||||
href={resolve(
|
|
||||||
$isAndroidTvStore
|
|
||||||
? `/tv/[playlistId]?playlist=${data.playlist.info.playlistId}`
|
|
||||||
: `/watch/[playlistId]?playlist=${data.playlist.info.playlistId}`,
|
|
||||||
{
|
|
||||||
playlistId: data.playlist.videos[0].videoId
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
class="button circle extra no-margin"
|
|
||||||
>
|
|
||||||
<i>play_arrow</i>
|
<i>play_arrow</i>
|
||||||
<div class="tooltip bottom">
|
<div class="tooltip bottom">
|
||||||
{$_('playlist.playVideos')}
|
{$_('playlist.playVideos')}
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</button>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
href={resolve(
|
href={resolve(
|
||||||
|
|||||||
Reference in New Issue
Block a user