webtorrent updates

This commit is contained in:
Gabriel 2022-09-23 02:40:30 -04:00
parent 51d13fb078
commit e5e8d389f7
3 changed files with 43 additions and 8 deletions

View file

@ -1,5 +1,7 @@
<header> <header>
<img src="{{.Site.Params.default_img}}"> <a href="{{.Site.BaseURL}}">
<img src="{{.Site.Params.default_img}}">
</a>
<div> <div>
<h1>{{.Site.Title }}</h1> <h1>{{.Site.Title }}</h1>
<i>{{.Site.Params.subtitle}}</i> <i>{{.Site.Params.subtitle}}</i>

View file

@ -1,16 +1,40 @@
<style>
#wtmedia{
width:100%;
}
#wtmedia video{
width:100%;
}
</style>
<script src="/webtorrent.js"></script> <script src="/webtorrent.js"></script>
<div id="wtmedia"> <div class="webtorrent">
<noscript>
<video controls>
<source src={{.Get "source"}}>
</video>
</noscript>
<div id="wtmedia">
</div>
<div>
Peers:<span id="Peers"></span>
</div>
</div> </div>
<script> <script>
const client = new WebTorrent(tracker=false,dht=true,webSeeds=true); function updateData(torrent) {
const magnetURI = '{{.Get 0}}'; document.getElementById('Peers').text=torrent.numPeers;
}
const client = new WebTorrent();
const magnetURI = {{.Get "magnet"}};
client.add(magnetURI, function (torrent) { client.add(magnetURI, function (torrent) {
// Got torrent metadata! // Got torrent metadata!
console.log('Client is downloading:', torrent.infoHash) torrent.addWebSeed({{.Get "source"}});
console.log("Torrent Peers: "+torrent.numPeers);
console.log('Client is downloading:', torrent.infoHash);
torrent.files.forEach(function (file) { torrent.files.forEach(function (file) {
// Display the file by appending it to the DOM. Supports video, audio, images, and // Display the file by appending it to the DOM. Supports video, audio, images, and
// more. Specify a container element (CSS selector or reference to DOM node). // more. Specify a container element (CSS selector or reference to DOM node).
file.appendTo('#wtmedia') file.appendTo('#wtmedia');
}) })
}) window.setInterval
</script> });
</script>

View file

@ -37,6 +37,9 @@ body {
header{ header{
margin-top:1rem; margin-top:1rem;
} }
header img {
max-height: 10rem;
}
header,footer{ header,footer{
text-align: center; text-align: center;
@ -190,6 +193,12 @@ section {
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
} }
section div{
display:flex;
flex-direction: column;
align-items: center;
}
h1{ h1{
font-size:200%; font-size:200%;
} }