Comments (11)
Are the trackers up? Are you able to use DHT? You should try using https://github.com/frostwire/frostwire-jlibtorrent directly to see if it works.
from torrentstream-android.
Hey,
@se-bastiaan There is a bug with magnet torrents, some trakers are just broken with frostwire it just pause the torrent or take more than 1min/2min to launch the download ( bug with the TorrenHandle who contains errors after the metadata alert ) and slow down the process or even stop the torrent).
To avoid such behavior you need to destroy the torrent if it download from magnet after receive metadata, create a torrent file from the metada and launch a new torrent from the torrent file you create.
With this method your download start after 10/15sec instead of 1/2min.
If you need some code ( it's not the best but it worked :) )
from torrentstream-android.
Is that a problem with jlibtorrent or Frostwire? Fetching of the magnet is entirely split from the download (TorrentStream.java#L185) what I understand now is that the magnet download inside the library doesn't work? Moreover, I can't find any issues mentioning this problem?
from torrentstream-android.
There is some issues on jlibtorrent's github about this and it's clearly not fixed yet. (even with last version)
issue on frostwire-jlibtorrent
So some people don't use download magnethe from jlibttorent library, they prefer to download metadata and create a torrent file.
from torrentstream-android.
So some people don't use download magnethe from jlibttorent library, they prefer to download metadata and create a torrent file.
That is exactly what happens in the code: https://github.com/TorrentStream/TorrentStream-Android/blob/develop/library/src/main/java/com/github/se_bastiaan/torrentstream/TorrentStream.java#L185
The issues mentions that the torrent is added but is paused. I cannot reproduce that, the sample app just doesn't receive any metadata at all.
from torrentstream-android.
I just add the alert.type METADATA_RECEIVED
in the TorrentAddedAlertListener class
case METADATA_RECEIVED:
MetadataReceivedAlert metadataAlert = ((MetadataReceivedAlert) alert);
byte[] bytes = null;
int size = metadataAlert.metadataSize();
int maxSize = 2 * 1024 * 1024;
if (0 < size && size <= maxSize)
bytes = metadataAlert.torrentData(true);
torrentMetadata(bytes, metadataAlert.handle().infoHash().toHex(), (MetadataReceivedAlert) alert);
break;
and to create the file i just check if i'ts a magnet and restart the process.
@Override
public void torrentMetadata(byte[] data, String hash, MetadataReceivedAlert alert) {
try {
if (isMagnet) {
File dataDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/torrents/");
if (!dataDir.exists()) {
if (!dataDir.mkdir()) {
throw new FileNotFoundException();
}
}
File torrentFile = new File(dataDir, hash);
if (!torrentFile.exists()) {
if (!torrentFile.createNewFile()) {
throw new FileNotFoundException();
}
try (FileOutputStream stream = new FileOutputStream(torrentFile)) {
stream.write(data);
}
}
String pathToTorrent = torrentFile.getAbsolutePath();
if (streamingThread != null)
streamingThread.interrupt();
if (streamingHandler != null)
streamingHandler.removeCallbacksAndMessages(null);
if (currentTorrent != null) {
currentTorrent.pause();
removeListener(currentTorrent);
remove(currentTorrent.getTorrentHandle());
currentTorrent = null;
}
startStream(pathToTorrent);
}
} catch(Exception e){
e.printStackTrace();
}
}
from torrentstream-android.
@se-bastiaan First of all, I'm very sorry for my late reply , and
Thank you very much for your reply!
I don't know more about magnet link, because this magnet link is from your demo。。。
from torrentstream-android.
I know that the magnet is from the example, but that doesn't mean that the trackers are up and more specifically: that DHT is working in your situation.
Alas, I do not think I'll be able to fix this. It seems to be something upstream. I could try using the download
method from TorrentSession
instead of fetchMagnet
but I don't have time for it.
from torrentstream-android.
@vonclutch I don't think I completely understand what you mean.
There is already different behaviour based on what kind of url is passed to getTorrentInfo.
If it's a magnet fetchMagnet
is called (which is blocking):
byte[] data = torrentSession.fetchMagnet(torrentUrl, 30000);
if (data != null)
try {
return TorrentInfo.bdecode(data);
} catch (IllegalArgumentException e) {
throw new TorrentInfoException(e);
}
This decodes the data array into TorrentInfo
which can be used to download the torrent. The METADATA_RECEIVED
should never be called based on this code iirc.
To compare this to a regular .torrent
file: bytes are read from the file into a data array which decodes in the same way.
from torrentstream-android.
@se-bastiaan I get it , thank you~~~~~~~~~
from torrentstream-android.
@se-bastiaan frostwire used the same for the SessionManager#fetchmagnet(), they just listen the METADATA_RECEIVED
and return the byte[] from this. I didn't want to rewrite the TorrentStream
class so i make it fast. I just bypass the fetchmagnet()
and make it by myself since you already use the AlertListener
here and re-start with a file.
Clearly something is wrong with the lib, delay or even no download at all for magnet ( which take 10-15sec max with a file). From what i saw on their issue it could come from TorrentHandle
but could come from anywhere rly :/
from torrentstream-android.
Related Issues (20)
- Download speed should be int HOT 1
- Question: Does it Seed as well as download? HOT 1
- bufferProgress does not finish HOT 2
- Resume and Pause function . HOT 1
- totrent streaming stops and further no video is streaming occurs HOT 6
- Error calling alert listener HOT 5
- Access to internal TorrentSessionManager HOT 2
- Doesn't work on Android 11 HOT 8
- Sample with working seekbar HOT 6
- How to get buffer progress when setInterestedBytes(long bytes) is used? HOT 1
- Stream via exo player HOT 3
- Need help regarding setInterestedBytes HOT 3
- some way to play video without download ? HOT 1
- Stream while downloading HOT 4
- How to get interested pieces first on seeking video player forward HOT 1
- ava.lang.UnsatisfiedLinkError: No implementation found for void com.frostwire.jlibtorrent.swig.libtorrent_jni.swig_module_init() HOT 1
- Please upgrade the library to jlibtorrent 1.2.16.0 HOT 3
- Progress stop in xx% and onStreamReady never come with some torrents HOT 3
- explore the files inside the torrent before downloading? HOT 6
- Seek to a particular position HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from torrentstream-android.