com.xunlei.downloadlib.parameter.TorrentInfo Java Examples
The following examples show how to use
com.xunlei.downloadlib.parameter.TorrentInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DownLoadModelImp.java From AndroidDownload with Apache License 2.0 | 6 votes |
@Override public List<TorrentInfoEntity> getTorrentInfo(String btpath) { TorrentInfo torrentInfo= XLTaskHelper.instance(x.app().getApplicationContext()).getTorrentInfo(btpath); List<TorrentInfoEntity> list=new ArrayList<>(); for(TorrentFileInfo torrent:torrentInfo.mSubFileInfo){ TorrentInfoEntity tie=new TorrentInfoEntity(); tie.setHash(torrent.hash); tie.setmFileIndex(torrent.mFileIndex); tie.setmFileName(torrent.mFileName); tie.setmFileSize(torrent.mFileSize); tie.setmSubPath(torrent.mSubPath); tie.setmRealIndex(torrent.mRealIndex); tie.setPath(AppSettingUtil.getInstance().getFileSavePath()+ File.separator+torrentInfo.mMultiFileBaseFolder+ File.separator+torrent.mSubPath+File.separator+torrent.mFileName); list.add(tie); } return list; }
Example #2
Source File: TorrentInfoPresenterImp.java From AndroidDownload with Apache License 2.0 | 6 votes |
@Override public void startTask(List<TorrentInfoEntity> checkList) { //String path=task.getLocalPath()+ File.separator+task.getmFileName(); TorrentInfo torrentInfo= XLTaskHelper.instance(x.app().getApplicationContext()).getTorrentInfo(torrentPath); List<DownloadTaskEntity> tasks=taskModel.findTaskByHash(torrentInfo.mInfoHash); if(tasks!=null && tasks.size()>0){ DownloadTaskEntity task=tasks.get(0); if(!FileTools.exists(task.getLocalPath()+ File.separator+task.getmFileName())) { downLoadModel.startTorrentTask(task); torrentInfoView.startTaskSuccess(); }else if(task.getmTaskStatus()== Const.DOWNLOAD_CONNECTION || task.getmTaskStatus()== Const.DOWNLOAD_LOADING || task.getmTaskStatus()== Const.DOWNLOAD_FAIL || task.getmTaskStatus()== Const.DOWNLOAD_STOP || task.getmTaskStatus()== Const.DOWNLOAD_WAIT){ torrentInfoView.startTaskFail(x.app().getString(R.string.task_earlier_has)); }else if(task.getmTaskStatus()== Const.DOWNLOAD_SUCCESS){ torrentInfoView.startTaskFail(x.app().getString(R.string.task_earlier_success)); } }else{ downLoadModel.startTorrentTask(torrentPath); torrentInfoView.startTaskSuccess(); } }
Example #3
Source File: XLTaskHelper.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
/** * 添加种子下载任务,如果是磁力链需要先通过addMagentTask将种子下载下来 * @param torrentPath 种子地址 * @param savePath 保存路径 * @param deselectIndexs 不需要下载的文件索引 * @return * @throws Exception */ public synchronized long addTorrentTask(String torrentPath,String savePath,int []deselectIndexs) throws Exception { TorrentInfo torrentInfo = new TorrentInfo(); XLDownloadManager.getInstance().getTorrentInfo(torrentPath,torrentInfo); TorrentFileInfo[] fileInfos = torrentInfo.mSubFileInfo; BtTaskParam taskParam = new BtTaskParam(); taskParam.setCreateMode(1); taskParam.setFilePath(savePath); taskParam.setMaxConcurrent(3); taskParam.setSeqId(seq.incrementAndGet()); taskParam.setTorrentPath(torrentPath); GetTaskId getTaskId = new GetTaskId(); XLDownloadManager.getInstance().createBtTask(taskParam,getTaskId); if(fileInfos.length > 1 && deselectIndexs != null && deselectIndexs.length > 0) { BtIndexSet btIndexSet = new BtIndexSet(deselectIndexs.length); int i = 0; for(int index : deselectIndexs) { btIndexSet.mIndexSet[i++] = index; } long r = XLDownloadManager.getInstance().deselectBtSubTask(getTaskId.getTaskId(),btIndexSet); Log.d(TAG, "selectBtSubTask return = " + r); } XLDownloadManager.getInstance().setTaskLxState(getTaskId.getTaskId(), 0, 1); // XLDownloadManager.getInstance().startDcdn(getTaskId.getTaskId(), currentFileInfo.mRealIndex, "", "", ""); XLDownloadManager.getInstance().startTask(getTaskId.getTaskId(), false); // XLDownloadManager.getInstance().setBtPriorSubTask(getTaskId.getTaskId(),currentFileInfo.mRealIndex); // XLTaskLocalUrl localUrl = new XLTaskLocalUrl(); // XLDownloadManager.getInstance().getLocalUrl(savePath+"/" +(TextUtils.isEmpty(currentFileInfo.mSubPath) ? "" : currentFileInfo.mSubPath+"/")+ currentFileInfo.mFileName,localUrl); // currentFileInfo.playUrl = localUrl.mStrUrl; // currentFileInfo.hash = torrentInfo.mInfoHash; // return currentFileInfo; return getTaskId.getTaskId(); }
Example #4
Source File: XLDownloadManager.java From MiniThunder with Apache License 2.0 | 5 votes |
public int getTorrentInfo(String str, TorrentInfo torrentInfo) { int i = 9900; increRefCount(); if (!(this.mLoader == null || str == null || torrentInfo == null)) { i = this.mLoader.getTorrentInfo(str, torrentInfo); } decreRefCount(); return i; }
Example #5
Source File: XLTaskHelper.java From MiniThunder with Apache License 2.0 | 5 votes |
/** * 添加种子下载任务,如果是磁力链需要先通过addMagentTask将种子下载下来 * @param torrentPath 种子地址 * @param savePath 保存路径 * @param indexs 需要下载的文件索引 * @return * @throws Exception */ public synchronized long addTorrentTask(String torrentPath,String savePath,int []indexs) throws Exception { TorrentInfo torrentInfo = new TorrentInfo(); XLDownloadManager.getInstance().getTorrentInfo(torrentPath,torrentInfo); TorrentFileInfo[] fileInfos = torrentInfo.mSubFileInfo; BtTaskParam taskParam = new BtTaskParam(); taskParam.setCreateMode(1); taskParam.setFilePath(savePath); taskParam.setMaxConcurrent(3); taskParam.setSeqId(seq.incrementAndGet()); taskParam.setTorrentPath(torrentPath); GetTaskId getTaskId = new GetTaskId(); XLDownloadManager.getInstance().createBtTask(taskParam,getTaskId); if(fileInfos.length > 1 && indexs != null && indexs.length > 0) { BtIndexSet btIndexSet = new BtIndexSet(indexs.length); int i = 0; for(int index : indexs) { btIndexSet.mIndexSet[i++] = index; } XLDownloadManager.getInstance().selectBtSubTask(getTaskId.getTaskId(),btIndexSet); } XLDownloadManager.getInstance().setTaskLxState(getTaskId.getTaskId(), 0, 1); // XLDownloadManager.getInstance().startDcdn(getTaskId.getTaskId(), currentFileInfo.mRealIndex, "", "", ""); XLDownloadManager.getInstance().startTask(getTaskId.getTaskId(), false); // XLDownloadManager.getInstance().setBtPriorSubTask(getTaskId.getTaskId(),currentFileInfo.mRealIndex); // XLTaskLocalUrl localUrl = new XLTaskLocalUrl(); // XLDownloadManager.getInstance().getLocalUrl(savePath+"/" +(TextUtils.isEmpty(currentFileInfo.mSubPath) ? "" : currentFileInfo.mSubPath+"/")+ currentFileInfo.mFileName,localUrl); // currentFileInfo.playUrl = localUrl.mStrUrl; // currentFileInfo.hash = torrentInfo.mInfoHash; // return currentFileInfo; return getTaskId.getTaskId(); }
Example #6
Source File: XLDownloadManager.java From AndroidDownload with Apache License 2.0 | 5 votes |
public int getTorrentInfo(String str, TorrentInfo torrentInfo) { int i = 9900; increRefCount(); if (!(this.mLoader == null || str == null || torrentInfo == null)) { i = this.mLoader.getTorrentInfo(str, torrentInfo); } decreRefCount(); return i; }
Example #7
Source File: XLTaskHelper.java From AndroidDownload with Apache License 2.0 | 5 votes |
/** * 添加种子下载任务,如果是磁力链需要先通过addMagentTask将种子下载下来 * @param torrentPath 种子地址 * @param savePath 保存路径 * @param indexs 需要下载的文件索引 * @return * @throws Exception */ public synchronized long addTorrentTask(String torrentPath,String savePath,int []indexs) throws Exception { TorrentInfo torrentInfo = new TorrentInfo(); XLDownloadManager.getInstance().getTorrentInfo(torrentPath,torrentInfo); TorrentFileInfo[] fileInfos = torrentInfo.mSubFileInfo; BtTaskParam taskParam = new BtTaskParam(); taskParam.setCreateMode(1); taskParam.setFilePath(savePath); taskParam.setMaxConcurrent(3); taskParam.setSeqId(seq.incrementAndGet()); taskParam.setTorrentPath(torrentPath); GetTaskId getTaskId = new GetTaskId(); XLDownloadManager.getInstance().createBtTask(taskParam,getTaskId); if(fileInfos.length > 1 && indexs != null && indexs.length > 0) { BtIndexSet btIndexSet = new BtIndexSet(indexs.length); int i = 0; for(int index : indexs) { btIndexSet.mIndexSet[i++] = index; } XLDownloadManager.getInstance().selectBtSubTask(getTaskId.getTaskId(),btIndexSet); } XLDownloadManager.getInstance().setTaskLxState(getTaskId.getTaskId(), 0, 1); // XLDownloadManager.getInstance().startDcdn(getTaskId.getTaskId(), currentFileInfo.mRealIndex, "", "", ""); XLDownloadManager.getInstance().startTask(getTaskId.getTaskId(), false); // XLDownloadManager.getInstance().setBtPriorSubTask(getTaskId.getTaskId(),currentFileInfo.mRealIndex); // XLTaskLocalUrl localUrl = new XLTaskLocalUrl(); // XLDownloadManager.getInstance().getLocalUrl(savePath+"/" +(TextUtils.isEmpty(currentFileInfo.mSubPath) ? "" : currentFileInfo.mSubPath+"/")+ currentFileInfo.mFileName,localUrl); // currentFileInfo.playUrl = localUrl.mStrUrl; // currentFileInfo.hash = torrentInfo.mInfoHash; // return currentFileInfo; return getTaskId.getTaskId(); }
Example #8
Source File: DownLoadModelImp.java From AndroidDownload with Apache License 2.0 | 5 votes |
@Override public Boolean startTask(DownloadTaskEntity task) { try { long taskId=0; if(task.getTaskType()==Const.BT_DOWNLOAD){ TorrentInfo torrentInfo= XLTaskHelper.instance(x.app().getApplicationContext()).getTorrentInfo(task.getUrl()); int i=0; int[] indexs=new int[torrentInfo.mSubFileInfo.length]; for(TorrentFileInfo torrent:torrentInfo.mSubFileInfo) { indexs[i++]=torrent.mFileIndex; } taskId = XLTaskHelper.instance(x.app().getApplicationContext()).addTorrentTask(task.getUrl(), task.getLocalPath(),indexs); }else if(task.getTaskType()==Const.URL_DOWNLOAD){ taskId = XLTaskHelper.instance(x.app().getApplicationContext()).addThunderTask(task.getUrl(), task.getLocalPath(), null); } XLTaskInfo taskInfo = XLTaskHelper.instance(x.app().getApplicationContext()).getTaskInfo(taskId); task.setmFileSize(taskInfo.mFileSize); task.setTaskId(taskId); task.setmTaskStatus(taskInfo.mTaskStatus); DBTools.getInstance().db().saveOrUpdate(task); if(taskInfo.mTaskId==0) return false; } catch (Exception e) { e.printStackTrace(); return false; } return true; }
Example #9
Source File: XLDownloadManager.java From BtPlayer with Apache License 2.0 | 5 votes |
public int getTorrentInfo(String str, TorrentInfo torrentInfo) { int i = 9900; increRefCount(); if (!(this.mLoader == null || str == null || torrentInfo == null)) { i = this.mLoader.getTorrentInfo(str, torrentInfo); } decreRefCount(); return i; }
Example #10
Source File: XLTaskHelper.java From BtPlayer with Apache License 2.0 | 5 votes |
/** * 添加种子下载任务,如果是磁力链需要先通过addMagentTask将种子下载下来 * @param torrentPath 种子地址 * @param savePath 保存路径 * @param indexs 需要下载的文件索引 * @return * @throws Exception */ public synchronized long addTorrentTask(String torrentPath,String savePath,int []indexs) throws Exception { TorrentInfo torrentInfo = new TorrentInfo(); XLDownloadManager.getInstance().getTorrentInfo(torrentPath,torrentInfo); TorrentFileInfo[] fileInfos = torrentInfo.mSubFileInfo; BtTaskParam taskParam = new BtTaskParam(); taskParam.setCreateMode(1); taskParam.setFilePath(savePath); taskParam.setMaxConcurrent(3); taskParam.setSeqId(seq.incrementAndGet()); taskParam.setTorrentPath(torrentPath); GetTaskId getTaskId = new GetTaskId(); XLDownloadManager.getInstance().createBtTask(taskParam,getTaskId); if(fileInfos.length > 1 && indexs != null && indexs.length > 0) { BtIndexSet btIndexSet = new BtIndexSet(indexs.length); int i = 0; for(int index : indexs) { btIndexSet.mIndexSet[i++] = index; } XLDownloadManager.getInstance().selectBtSubTask(getTaskId.getTaskId(),btIndexSet); } XLDownloadManager.getInstance().setTaskLxState(getTaskId.getTaskId(), 0, 1); // XLDownloadManager.getInstance().startDcdn(getTaskId.getTaskId(), currentFileInfo.mRealIndex, "", "", ""); XLDownloadManager.getInstance().startTask(getTaskId.getTaskId(), false); // XLDownloadManager.getInstance().setBtPriorSubTask(getTaskId.getTaskId(),currentFileInfo.mRealIndex); // XLTaskLocalUrl localUrl = new XLTaskLocalUrl(); // XLDownloadManager.getInstance().getLocalUrl(savePath+"/" +(TextUtils.isEmpty(currentFileInfo.mSubPath) ? "" : currentFileInfo.mSubPath+"/")+ currentFileInfo.mFileName,localUrl); // currentFileInfo.playUrl = localUrl.mStrUrl; // currentFileInfo.hash = torrentInfo.mInfoHash; // return currentFileInfo; return getTaskId.getTaskId(); }
Example #11
Source File: DownLoadUtil.java From BtPlayer with Apache License 2.0 | 5 votes |
public void getTaskInfo(String url) { XLTaskHelper xlTaskHelper = XLTaskHelper.instance(globalContext); if (UrlType.isTorrentUrl(url)) { TorrentInfo torrentInfo = xlTaskHelper.getTorrentInfo(url); LogPrinter.i(TAG, torrentInfo.toString()); } else { String fileName = xlTaskHelper.getFileName(url); if (fileName.endsWith(".torrent")) dstFileIsTorrentFileTask = true; LogPrinter.i(TAG, fileName); } }
Example #12
Source File: DownLoadUtil.java From BtPlayer with Apache License 2.0 | 5 votes |
public void startDownLoad(String url) throws Exception { savePath = StorageUtils.getDefaultSavePath(globalContext); String fileName = null; if (UrlType.isTorrentUrl(url)) { TorrentInfo info = getTorrentInfo(url); savePath += "/" + info.mMultiFileBaseFolder; File f = new File(savePath); f.mkdirs(); fileName = null; } else { fileName = getFileName(url); } preFile = savePath + (fileName == null ? "" : "/" + fileName); LogPrinter.i(TAG, "start download url : " + url + ", save path : " + savePath); if (UrlType.isThunderUrl(url) || UrlType.isHttpOrHttpsUrl(url) || UrlType.isFTPUrl(url)) { taskID = XLTaskHelper.instance(globalContext) .addThunderTask(url, savePath, fileName); } else if (UrlType.isMagnetUrl(url)) { taskID = XLTaskHelper.instance(globalContext) .addMagentTask(url, savePath, fileName); } else if (StorageUtils.isTorrentFile(url)) { taskID = XLTaskHelper.instance(globalContext) .addTorrentTask(url, savePath, null); } LogPrinter.i(TAG, "download url taskID : " + taskID); updateProgress(); }
Example #13
Source File: XLDownloadManager.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
public int getTorrentInfo(String str, TorrentInfo torrentInfo) { int i = 9900; increRefCount(); if (!(this.mLoader == null || str == null || torrentInfo == null)) { i = this.mLoader.getTorrentInfo(str, torrentInfo); } decreRefCount(); return i; }
Example #14
Source File: XLTaskHelper.java From BtPlayer with Apache License 2.0 | 4 votes |
/** * 获取种子详情 * @param torrentPath * @return */ public synchronized TorrentInfo getTorrentInfo(String torrentPath) { TorrentInfo torrentInfo = new TorrentInfo(); XLDownloadManager.getInstance().getTorrentInfo(torrentPath,torrentInfo); return torrentInfo; }
Example #15
Source File: DownLoadModelImp.java From AndroidDownload with Apache License 2.0 | 4 votes |
@Override public Boolean startTorrentTask(String btpath, int[] indexs) { DownloadTaskEntity task=new DownloadTaskEntity(); TorrentInfo torrentInfo= XLTaskHelper.instance(x.app().getApplicationContext()).getTorrentInfo(btpath); if(indexs==null || indexs.length<=0) { int i = 0; indexs = new int[torrentInfo.mSubFileInfo.length]; for (TorrentFileInfo torrent : torrentInfo.mSubFileInfo) { indexs[i++] = torrent.mFileIndex; } } String savePath= AppSettingUtil.getInstance().getFileSavePath(); if(torrentInfo.mIsMultiFiles) { savePath += File.separator + torrentInfo.mMultiFileBaseFolder; task.setmFileName(torrentInfo.mMultiFileBaseFolder); }else{ if(torrentInfo.mSubFileInfo.length>1) { savePath += File.separator + FileTools.getFileNameWithoutSuffix(btpath); task.setmFileName(FileTools.getFileNameWithoutSuffix(btpath)); }else{ task.setmFileName(torrentInfo.mSubFileInfo[0].mFileName); } } long taskId= 0; try { taskId = XLTaskHelper.instance(x.app().getApplicationContext()).addTorrentTask(btpath, savePath,indexs); XLTaskInfo taskInfo = XLTaskHelper.instance(x.app().getApplicationContext()).getTaskInfo(taskId); task.setLocalPath(savePath); task.setFile(!torrentInfo.mIsMultiFiles); task.setHash(torrentInfo.mInfoHash); task.setUrl(btpath); task.setmFileSize(taskInfo.mFileSize); task.setmTaskStatus(taskInfo.mTaskStatus); task.setTaskId(taskId); task.setmDCDNSpeed(taskInfo.mAdditionalResDCDNSpeed); task.setmDownloadSize(taskInfo.mDownloadSize); task.setmDownloadSpeed(taskInfo.mDownloadSpeed); task.setTaskType(Const.BT_DOWNLOAD); task.setCreateDate(new Date()); DBTools.getInstance().db().saveBindingId(task); } catch (Exception e) { e.printStackTrace(); return false; } return true; }
Example #16
Source File: DownLoadUtil.java From BtPlayer with Apache License 2.0 | 4 votes |
private TorrentInfo getTorrentInfo(String url) { XLTaskHelper xlTaskHelper = XLTaskHelper.instance(globalContext); TorrentInfo torrentInfo = xlTaskHelper.getTorrentInfo(url); return torrentInfo; }
Example #17
Source File: XLTaskHelper.java From AndroidDownload with Apache License 2.0 | 4 votes |
/** * 获取种子详情 * @param torrentPath * @return */ public synchronized TorrentInfo getTorrentInfo(String torrentPath) { TorrentInfo torrentInfo = new TorrentInfo(); XLDownloadManager.getInstance().getTorrentInfo(torrentPath,torrentInfo); return torrentInfo; }
Example #18
Source File: XLTaskHelper.java From MiniThunder with Apache License 2.0 | 4 votes |
/** * 获取种子详情 * @param torrentPath * @return */ public synchronized TorrentInfo getTorrentInfo(String torrentPath) { TorrentInfo torrentInfo = new TorrentInfo(); XLDownloadManager.getInstance().getTorrentInfo(torrentPath,torrentInfo); return torrentInfo; }
Example #19
Source File: XLTaskHelper.java From TVRemoteIME with GNU General Public License v2.0 | 4 votes |
/** * 获取种子详情 * @param torrentPath * @return */ public synchronized TorrentInfo getTorrentInfo(String torrentPath) { TorrentInfo torrentInfo = new TorrentInfo(); XLDownloadManager.getInstance().getTorrentInfo(torrentPath,torrentInfo); return torrentInfo; }
Example #20
Source File: XLLoader.java From BtPlayer with Apache License 2.0 | votes |
public native int getTorrentInfo(String str, TorrentInfo torrentInfo);
Example #21
Source File: XLLoader.java From TVRemoteIME with GNU General Public License v2.0 | votes |
public native int getTorrentInfo(String str, TorrentInfo torrentInfo);
Example #22
Source File: XLLoader.java From AndroidDownload with Apache License 2.0 | votes |
public native int getTorrentInfo(String str, TorrentInfo torrentInfo);
Example #23
Source File: XLLoader.java From MiniThunder with Apache License 2.0 | votes |
public native int getTorrentInfo(String str, TorrentInfo torrentInfo);