2022-01-11 18:53:01 +01:00
|
|
|
<script>
|
|
|
|
import { createEventDispatcher } from "svelte";
|
|
|
|
import Magnet from "../../icons/Magnet.svelte";
|
|
|
|
import { formatDate } from "../../util/Formatting.svelte"
|
2023-01-17 19:03:14 +01:00
|
|
|
import IconBlock from "./IconBlock.svelte";
|
2022-02-08 11:32:36 +01:00
|
|
|
import TextBlock from "./TextBlock.svelte";
|
2022-01-11 18:53:01 +01:00
|
|
|
import TorrentItem from "./TorrentItem.svelte"
|
2024-01-24 14:13:26 +01:00
|
|
|
import FileTitle from "./FileTitle.svelte";
|
2024-02-20 17:33:15 +01:00
|
|
|
import CopyButton from "../../layout/CopyButton.svelte";
|
2022-01-11 18:53:01 +01:00
|
|
|
|
|
|
|
let dispatch = createEventDispatcher()
|
|
|
|
|
|
|
|
let status = "loading"
|
|
|
|
export const set_file = async f => {
|
|
|
|
file = f
|
|
|
|
|
|
|
|
dispatch("loading", true)
|
|
|
|
|
|
|
|
try {
|
|
|
|
let resp = await fetch(f.info_href+"/torrent")
|
|
|
|
|
|
|
|
if (resp.status >= 400) {
|
|
|
|
let json = await resp.json()
|
|
|
|
|
|
|
|
if (json.value === "torrent_too_large") {
|
|
|
|
status = "too_large"
|
|
|
|
return
|
|
|
|
} else {
|
|
|
|
status = "parse_failed"
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
torrent = await resp.json()
|
|
|
|
|
|
|
|
// Generate magnet link
|
|
|
|
magnet = "magnet:?xt=urn:btih:" + torrent.info_hash +
|
|
|
|
"&dn=" + encodeURIComponent(Object.keys(torrent.files.children)[0])
|
|
|
|
|
|
|
|
torrent.trackers.forEach(tracker => {
|
|
|
|
magnet += "&tr="+encodeURIComponent(tracker)
|
|
|
|
})
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err)
|
|
|
|
} finally {
|
|
|
|
dispatch("loading", false)
|
|
|
|
}
|
|
|
|
|
|
|
|
status = "finished"
|
|
|
|
}
|
|
|
|
let file = {
|
|
|
|
id: "",
|
|
|
|
size: 0,
|
|
|
|
name: "",
|
|
|
|
mime_type: "",
|
|
|
|
icon_href: "",
|
|
|
|
show_ads: false,
|
|
|
|
}
|
|
|
|
let torrent = {
|
|
|
|
trackers: [],
|
|
|
|
comment: "",
|
|
|
|
created_by: "",
|
|
|
|
created_at: "",
|
|
|
|
info_hash: "",
|
|
|
|
files: null,
|
|
|
|
}
|
|
|
|
|
|
|
|
let magnet = ""
|
|
|
|
</script>
|
|
|
|
|
2024-01-24 14:13:26 +01:00
|
|
|
<FileTitle title={file.name}/>
|
2023-01-17 22:53:41 +01:00
|
|
|
|
2023-01-17 19:03:14 +01:00
|
|
|
<IconBlock icon_href={file.icon_href}>
|
2022-01-11 18:53:01 +01:00
|
|
|
{#if status === "finished"}
|
2022-01-17 14:10:50 +01:00
|
|
|
Created by: {torrent.created_by}<br/>
|
|
|
|
Comment: {torrent.comment}<br/>
|
|
|
|
Created at: {formatDate(new Date(torrent.created_at), true, true, true)}<br/>
|
|
|
|
Info hash: {torrent.info_hash}<br/>
|
|
|
|
<a href={magnet} class="button button_highlight">
|
2024-02-05 15:07:25 +01:00
|
|
|
<Magnet/>
|
2022-01-17 14:10:50 +01:00
|
|
|
<span>Open magnet link</span>
|
|
|
|
</a>
|
2024-02-20 17:33:15 +01:00
|
|
|
<CopyButton text={magnet}>Copy magnet link</CopyButton>
|
2022-01-17 14:10:50 +01:00
|
|
|
{:else if status === "too_large"}
|
|
|
|
<p>
|
|
|
|
Torrent file is too large to parse. Please download the file and
|
|
|
|
add it to your torrent client locally.
|
|
|
|
</p>
|
|
|
|
{:else if status === "parse_failed"}
|
|
|
|
<p>
|
|
|
|
Torrent file could not be parsed. It may be corrupted.
|
|
|
|
</p>
|
2022-01-11 18:53:01 +01:00
|
|
|
{/if}
|
2022-01-17 14:10:50 +01:00
|
|
|
<button on:click={() => {dispatch("download")}} class="button">
|
|
|
|
<i class="icon">download</i>
|
|
|
|
<span>Download torrent file</span>
|
|
|
|
</button>
|
2023-01-17 19:03:14 +01:00
|
|
|
</IconBlock>
|
2023-01-17 22:53:41 +01:00
|
|
|
|
2024-02-05 15:07:25 +01:00
|
|
|
<TextBlock>
|
|
|
|
<details>
|
|
|
|
<summary>How do I download this? (expand for more information)</summary>
|
|
|
|
<p>
|
|
|
|
This is a torrent file, which means you will need a torrent client to
|
|
|
|
download it. Here are some good torrent clients for various platforms:
|
|
|
|
</p>
|
|
|
|
<ul>
|
|
|
|
<li><a href="https://transmissionbt.com/download">Transmission</a> (Linux, Mac, Windows)</li>
|
|
|
|
<li><a href="https://www.qbittorrent.org/download">qBittorrent</a> (Linux, Mac, Windows)</li>
|
|
|
|
<li><a href="https://play.google.com/store/apps/details?id=org.proninyaroslav.libretorrent">LibreTorrent</a> (Android)</li>
|
|
|
|
</ul>
|
|
|
|
<p>
|
|
|
|
After installing your torrent client you will be able to use the
|
|
|
|
<a href={magnet}><Magnet/> Open magnet link</a>
|
|
|
|
button to download the files in your torrent client.
|
|
|
|
</p>
|
|
|
|
<h3>What is a torrent?</h3>
|
|
|
|
<p>
|
|
|
|
<a href="https://wikipedia.org/wiki/BitTorrent">BitTorrent</a> is a
|
|
|
|
peer-to-peer network for sharing files. This torrent file does not
|
|
|
|
actually contain the files listed below, instead it contains
|
|
|
|
instructions for your torrent client to download the files from
|
|
|
|
other people who happen to be downloading the same files currently.
|
|
|
|
This means that instead of connecting to a single server (like
|
|
|
|
pixeldrain), you will be connecting to other people on the internet
|
|
|
|
to download these files.
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
Torrents are a highly efficient and free method of transferring
|
|
|
|
files over the internet. Since the bandwidth is shared directly
|
|
|
|
between users there is no need for expensive servers to host the
|
|
|
|
files for you.
|
|
|
|
</p>
|
|
|
|
<h3>Is this safe?</h3>
|
|
|
|
<p>
|
|
|
|
Your torrent client will make sure that the files you receive from
|
|
|
|
your peers are actually what they say it is. This makes it just as
|
2024-02-05 16:54:16 +01:00
|
|
|
safe as any other form of downloading. Like always when downloading
|
|
|
|
files you still need to be aware of what you are downloading. Don't
|
|
|
|
just blindly trust any file anyone sends you.
|
2024-02-05 15:07:25 +01:00
|
|
|
</p>
|
2024-02-05 16:54:16 +01:00
|
|
|
<h3>Is it private?</h3>
|
2024-02-05 15:07:25 +01:00
|
|
|
<p>
|
|
|
|
When downloading a torrent file you will be part of the so-called
|
|
|
|
'torrent swarm'. Anyone in the swarm can see each other's IP
|
|
|
|
addresses. This is not a bad thing on its own, but there a few cases
|
2024-02-05 16:54:16 +01:00
|
|
|
in which this can be abused.
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
Anyone in the swarm will be able to see what you are downloading,
|
|
|
|
even across different torrents. This is something to keep in mind
|
|
|
|
when downloading torrents. If someone can link your IP address to
|
|
|
|
your identity then there are ways to find out which files you have
|
|
|
|
downloaded in the past (provided that your IP address has not
|
|
|
|
changed since then).
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
If you are downloading copyrighted material (which I do not condone)
|
|
|
|
then rightsholders will be able to see your IP address. In most
|
|
|
|
cases this is not a problem because your ISP will still protect your
|
|
|
|
identity. But there are some countries (notably the USA) where your
|
|
|
|
ISP will not respect your right to privacy and the rightsholder will
|
|
|
|
be able to contact you. If this worries you then you should look
|
|
|
|
into VPN services to protect your privacy, like <a
|
2024-02-05 15:07:25 +01:00
|
|
|
href="https://mullvad.net">Mullvad</a>.
|
|
|
|
</p>
|
|
|
|
</details>
|
|
|
|
</TextBlock>
|
|
|
|
|
2022-01-17 14:10:50 +01:00
|
|
|
{#if status === "finished"}
|
2023-01-17 19:03:14 +01:00
|
|
|
<TextBlock>
|
2022-01-17 14:10:50 +01:00
|
|
|
<h2>Files in this torrent</h2>
|
|
|
|
<TorrentItem item={torrent.files} />
|
2022-02-08 11:32:36 +01:00
|
|
|
</TextBlock>
|
2022-01-17 14:10:50 +01:00
|
|
|
{/if}
|
2024-02-05 15:07:25 +01:00
|
|
|
|
|
|
|
<style>
|
|
|
|
summary {
|
|
|
|
cursor: pointer;
|
|
|
|
border-bottom: 1px solid var(--separator);
|
|
|
|
}
|
|
|
|
</style>
|