Added download options
This commit is contained in:
@@ -47,7 +47,8 @@
|
||||
{#each subscriptions as sub}
|
||||
<article>
|
||||
<nav>
|
||||
<h6 class="max">{sub.author}</h6>
|
||||
<a href={`/channel/${sub.authorId}`} class="link"><h6>{sub.author}</h6></a>
|
||||
<div class="max"></div>
|
||||
<button on:click={async () => unsubscribe(sub.authorId)} class="inverse-surface">
|
||||
Unsubscribe
|
||||
</button>
|
||||
|
||||
@@ -227,7 +227,7 @@
|
||||
<h5>{data.video.title}</h5>
|
||||
|
||||
<div class="grid no-padding">
|
||||
<div class="s12 m12 l4">
|
||||
<div class="s12 m12 l5">
|
||||
<nav>
|
||||
<a href={`/channel/${data.video.authorId}`}>
|
||||
<nav>
|
||||
@@ -277,17 +277,16 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="s12 m12 l4 video-actions">
|
||||
<div class="s12 m12 l3 video-actions">
|
||||
<button
|
||||
class="no-margin"
|
||||
on:click={() => (audioMode = !audioMode)}
|
||||
class:border={!audioMode}
|
||||
>
|
||||
<i>headphones</i>
|
||||
<span>Audio only </span>
|
||||
</button>
|
||||
<button class="border"
|
||||
><i>share</i> Share
|
||||
<button class="border" style="margin-right: 0;"
|
||||
><i>share</i>
|
||||
<menu class="no-wrap">
|
||||
<a
|
||||
class="row"
|
||||
@@ -319,10 +318,21 @@
|
||||
></menu
|
||||
></button
|
||||
>
|
||||
{#if data.downloadOptions}
|
||||
<button class="border"
|
||||
><i>download</i>
|
||||
<menu class="no-wrap">
|
||||
{#each data.downloadOptions as download}
|
||||
<a class="row" href={download.url} target="_blank" rel="noopener noreferrer"
|
||||
>{download.title}</a
|
||||
>
|
||||
{/each}
|
||||
</menu></button
|
||||
>
|
||||
{/if}
|
||||
{#if data.personalPlaylists}
|
||||
<button class="border no-margin">
|
||||
<i>add</i>
|
||||
<span>Playlist</span>
|
||||
<menu>
|
||||
{#each data.personalPlaylists as personalPlaylist}
|
||||
<a
|
||||
@@ -336,7 +346,6 @@
|
||||
{:else}
|
||||
<button disabled class="border no-margin">
|
||||
<i>add</i>
|
||||
<span>Playlist</span>
|
||||
<div class="tooltip">
|
||||
{#if $auth}
|
||||
No playlists
|
||||
|
||||
@@ -13,6 +13,24 @@ export async function load({ params, url }) {
|
||||
error(500, errorMessage);
|
||||
}
|
||||
|
||||
let downloadOptions: { title: string; url: string; }[] = [];
|
||||
|
||||
if (!video.hlsUrl) {
|
||||
video.formatStreams.forEach(format => {
|
||||
downloadOptions.push({
|
||||
title: `${format.type.split(';')[0].trim()} - ${format.qualityLabel} (With audio)`,
|
||||
url: format.url
|
||||
});
|
||||
});
|
||||
|
||||
video.adaptiveFormats.forEach(format => {
|
||||
downloadOptions.push({
|
||||
title: `${format.type.split(';')[0].trim()} - ${format.qualityLabel || format.bitrate + ' bitrate'}`,
|
||||
url: format.url
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
let personalPlaylists: PlaylistPage[] | null;
|
||||
|
||||
if (get(auth)) {
|
||||
@@ -47,6 +65,7 @@ export async function load({ params, url }) {
|
||||
subscribed: await amSubscribed(video.authorId),
|
||||
content: phaseDescription(video.descriptionHtml),
|
||||
playlistId: url.searchParams.get('playlist'),
|
||||
personalPlaylists: personalPlaylists
|
||||
personalPlaylists: personalPlaylists,
|
||||
downloadOptions: downloadOptions
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user