Improved search URL input
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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}
|
||||
<div class="max">
|
||||
{video.viewCountText ?? cleanNumber(video.viewCount ?? 0)} • {relativeTimestamp(
|
||||
video.published,
|
||||
false
|
||||
)}
|
||||
{video.viewCountText ?? cleanNumber(video.viewCount ?? 0)}
|
||||
•
|
||||
{isYTBackend() ? relativeTimestamp(video.published, false) : video.publishedText}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user