From 3bc370d04c94d823930fc0de618f0ef75613bccf Mon Sep 17 00:00:00 2001 From: WardPearce Date: Thu, 12 Feb 2026 19:21:26 +1300 Subject: [PATCH] Improved search URL input --- materialious/src/lib/components/ItemsList.svelte | 15 ++------------- materialious/src/lib/components/Thumbnail.svelte | 9 ++++----- materialious/src/lib/search.ts | 12 +++++++++++- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/materialious/src/lib/components/ItemsList.svelte b/materialious/src/lib/components/ItemsList.svelte index 9addbf77..a6372b00 100644 --- a/materialious/src/lib/components/ItemsList.svelte +++ b/materialious/src/lib/components/ItemsList.svelte @@ -2,28 +2,17 @@ import Thumbnail from '$lib/components/Thumbnail.svelte'; import { _ } from '$lib/i18n'; import { removePlaylistVideo } from '../api'; - import type { - Channel, - HashTag, - Playlist, - PlaylistPage, - PlaylistPageVideo, - Video, - VideoBase - } from '../api/model'; import { authStore, feedLastItemId, isAndroidTvStore } from '../store'; import ContentColumn from './ContentColumn.svelte'; import { onMount, onDestroy, tick } from 'svelte'; import Mousetrap from 'mousetrap'; - import { extractUniqueId } from '$lib/misc'; + import { extractUniqueId, type feedItems } from '$lib/misc'; import ChannelThumbnail from './ChannelThumbnail.svelte'; import PlaylistThumbnail from './PlaylistThumbnail.svelte'; import HashtagThumbnail from './HashtagThumbnail.svelte'; interface Props { - items?: - | (VideoBase | Video | PlaylistPageVideo | Channel | Playlist | HashTag)[] - | PlaylistPage[]; + items?: feedItems; playlistId?: string; playlistAuthor?: string; classes?: string; diff --git a/materialious/src/lib/components/Thumbnail.svelte b/materialious/src/lib/components/Thumbnail.svelte index 1fc7fa47..25d0ee35 100644 --- a/materialious/src/lib/components/Thumbnail.svelte +++ b/materialious/src/lib/components/Thumbnail.svelte @@ -8,7 +8,7 @@ import { get } from 'svelte/store'; import { getDeArrow, getThumbnail } from '../api'; import type { Notification, PlaylistPageVideo, Video, VideoBase } from '../api/model'; - import { createVideoUrl, insecureRequestImageHandler } from '../misc'; + import { createVideoUrl, insecureRequestImageHandler, isYTBackend } from '../misc'; import type { PlayerEvents } from '../player'; import { authStore, @@ -248,10 +248,9 @@ {#if 'published' in video}
- {video.viewCountText ?? cleanNumber(video.viewCount ?? 0)} • {relativeTimestamp( - video.published, - false - )} + {video.viewCountText ?? cleanNumber(video.viewCount ?? 0)} + • + {isYTBackend() ? relativeTimestamp(video.published, false) : video.publishedText}
{/if} diff --git a/materialious/src/lib/search.ts b/materialious/src/lib/search.ts index 3b32cabe..a655103a 100644 --- a/materialious/src/lib/search.ts +++ b/materialious/src/lib/search.ts @@ -6,7 +6,17 @@ import { isVideoID } from './misc'; function extractVideoId(url: string): string | null { const urlObj = new URL(url, 'http://example.com'); // Using a base URL in case searchValue is just a query parameter - const videoId = urlObj.searchParams.get('v'); + + let videoId: string | null = null; + if (urlObj.hostname === 'youtu.be') { + videoId = urlObj.pathname.replace('/', ''); + if (videoId === '') { + videoId = null; + } + } else { + videoId = urlObj.searchParams.get('v'); + } + return videoId; }