Is a simple BitTorrent client that generates images from the videos in Torrent files.
To know the content of a torrent there are usually those approaches:
The problem with images inside the torrent is that you cannot download the images if there are no seeders at the moment. The images do not necessary need to match with the video content or quality. The problem with links to image of screenshots is that those links can be broken and thus unusable. We can do better.
Generate the screenshot from the videos inside the Torrent using TorrentPreview. - Jan Carreras, bored, one random Tuesday
So, that is that. Torrent Preview receives a Magnet link, unmagnetizes it converting it to a Torrent file, and downloads the first 8MB of each video of the torrent to extract a Screenshot at the frame corresponding to the second 5 of the video. It stores the screenshot and removes the video.
Then it exposes via an HTTP API all the information about the torrent itself, the files and it's corresponding images.
This software is not meant to be used locally, but as a service. Simple example:
magnet:?xt=urn:btih:3F8F219568B8B229581DDDD7BC5A5E889E906A9B&dn=Pulp%20Fiction%20%281994%29%201080p%20BrRip%20x264%20-%201.4GB%20-%20YIFY
in the "Magnet / TorrentID" and hit PreviewThis website is in (at best) beta phase. Demo purposes only. Do not try to feed read magnets. It should identify them, but the images are not going to be extracted.
Two paths:
If you just want to try the project and see how it works, go to the Docker Section since it's easier for you.
docker-compose build
.
docker-compose up
and you'll the HTTP listening on :8080docker-compose run cli /go/bin/torrentprev magnet "magnet:?xt=urn:btih:c92f656155d0d8e87d21471d7ea43e3ad0d42723"
DEBU[0000] not found in db. about to resolve the magnet using network magnet="magnet:?xt=urn:btih:C92F656155D0D8E87D21471D7EA43E3AD0D42723" magnetID=c92f656155d0d8e87d21471d7ea43e3ad0d42723
2021-02-25T10:45:27+0000 NONE portfwd.go:30: discovered 0 upnp devices
From the previous command, get the ID from "magnetID=c92f656155d0d8e87d21471d7ea43e3ad0d42723" and use it to download it. Like this:
docker-compose run cli /go/bin/torrentprev download c92f656155d0d8e87d21471d7ea43e3ad0d42723
magnet:?xt=urn:btih:c92f656155d0d8e87d21471d7ea43e3ad0d42723
root@86637674da0f:/go/src/github.com/jan-carreras/torrentpreviewer# /go/bin/torrentprev download c92f656155d0d8e87d21471d7ea43e3ad0d42723
DEBU[0000] torrent to be processed name="----REDACTED---" torrentID=c92f656155d0d8e87d21471d7ea43e3ad0d42723
DEBU[0000] images that we already have for the torrent imagesTorrentCount=0 name="----REDACTED---" torrentID=c92f656155d0d8e87d21471d7ea43e3ad0d42723
DEBU[0000] pieces to download downloadPlanSize=8388608 name="----REDACTED---" pieceCount=4 pieceLength=2097152 torrentID=c92f656155d0d8e87d21471d7ea43e3ad0d42723
2021-02-25T10:46:47+0000 NONE portfwd.go:30: discovered 0 upnp devices
INFO[0012] piece download completed complete=true pieceIdx=1 torrent="----REDACTED---" waitingFor=3
DEBU[0012] part added to registry piece=1 torrentID=c92f656155d0d8e87d21471d7ea43e3ad0d42723
INFO[0012] piece download completed complete=true pieceIdx=0 torrent="----REDACTED---" waitingFor=2
DEBU[0012] part added to registry piece=0 torrentID=c92f656155d0d8e87d21471d7ea43e3ad0d42723
INFO[0013] piece download completed complete=true pieceIdx=3 torrent="----REDACTED---" waitingFor=1
DEBU[0013] part added to registry piece=3 torrentID=c92f656155d0d8e87d21471d7ea43e3ad0d42723
INFO[0015] piece download completed complete=true pieceIdx=2 torrent="----REDACTED---" waitingFor=0
DEBU[0015] part added to registry piece=2 torrentID=c92f656155d0d8e87d21471d7ea43e3ad0d42723
DEBU[0015] download completed name=c92f656155d0d8e87d21471d7ea43e3ad0d42723.0.0-3.REDACTED.mp4.jpg pieceCount=4 torrentID=c92f656155d0d8e87d21471d7ea43e3ad0d42723
DEBU[0015] no more input. Seems that those were all the pieces
DEBU[0016] image extracted successfully name=c92f656155d0d8e87d21471d7ea43e3ad0d42723.0.0-3.REDACTED.mp4.jpg torrentID=c92f656155d0d8e87d21471d7ea43e3ad0d42723
DEBU[0016] image persisted successfully name=c92f656155d0d8e87d21471d7ea43e3ad0d42723.0.0-3.REDACTED.mp4.jpg torrentID=c92f656155d0d8e87d21471d7ea43e3ad0d42723
Warning! You're actually downloading a torrent that might contain Copyrighted material. See LICENSE.
Note: You're actually using bitTorrent. Your current network might be filtering ports, dropping traffic, might be slow, or you won't find seeders at this moment. The videos might not download.
You can see the very same result at TorrentPreview
See file in docs/http/api.postman_collection.json
and you'll find the requests and descriptions of what they do.
See it online as well.
docker-compose run cli make generate
Commands:
docker-compose run cli make test # Generates mocks
docker-compose run cli make test-cover # Generates mocks and coverage
docker-compose run cli make test-fast # Without mock generation
You can run the tests from your IDE or CLI once the mocks are generated.
You want to start the project locally? You'll need to:
We must generate 2 binaries:
make build
make build-linux
You'll find the binaries in ./bin
prefixed with your architecture like: darwin-http
or linux-torrentprev
Create an empty sqlite3 database on the root of the project: Then create the schema by issuing:
touch prevtorrent.sqlite
sqlite3 prevtorrent.sqlite < infrastructure/database/sqlite.schema.sql