|
|
@ -101,20 +101,25 @@ public class BitCometAdapter implements IDaemonAdapter { |
|
|
|
|
|
|
|
|
|
|
|
// Request all torrents from server
|
|
|
|
// Request all torrents from server
|
|
|
|
// first, check client for the new AJAX interface (BitComet v.1.34 and up)
|
|
|
|
// first, check client for the new AJAX interface (BitComet v.1.34 and up)
|
|
|
|
String result = makeRequest("/panel/task_list_xml"); |
|
|
|
try { |
|
|
|
if (result.startsWith("<?xml", 0)) { |
|
|
|
String xmlResult = makeRequest("/panel/task_list_xml"); |
|
|
|
return new RetrieveTaskSuccessResult((RetrieveTask) task, parseXmlTorrents(result), null); |
|
|
|
if (xmlResult.startsWith("<?xml", 0)) { |
|
|
|
|
|
|
|
return new RetrieveTaskSuccessResult((RetrieveTask) task, parseXmlTorrents(xmlResult), null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
// it's probably an old client, parse HTML instead
|
|
|
|
|
|
|
|
String htmlResult = makeRequest("/panel/task_list"); |
|
|
|
|
|
|
|
return new RetrieveTaskSuccessResult((RetrieveTask) task, parseHttpTorrents(htmlResult), null); |
|
|
|
} |
|
|
|
} |
|
|
|
// it's old client, parse HTML
|
|
|
|
|
|
|
|
result = makeRequest("/panel/task_list"); |
|
|
|
|
|
|
|
return new RetrieveTaskSuccessResult((RetrieveTask) task, parseHttpTorrents(result), null); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case GetFileList: |
|
|
|
case GetFileList: |
|
|
|
|
|
|
|
|
|
|
|
// Request files listing for a specific torrent
|
|
|
|
// Request files listing for a specific torrent
|
|
|
|
String fhash = ((GetFileListTask)task).getTargetTorrent().getUniqueID(); |
|
|
|
String fhash = ((GetFileListTask)task).getTargetTorrent().getUniqueID(); |
|
|
|
result = makeRequest("/panel/task_detail", new BasicNameValuePair("id", fhash), new BasicNameValuePair("show", "files")); |
|
|
|
String fileListResult = makeRequest("/panel/task_detail", new BasicNameValuePair("id", fhash), |
|
|
|
return new GetFileListTaskSuccessResult((GetFileListTask) task, parseHttpTorrentFiles(result, fhash)); |
|
|
|
new BasicNameValuePair("show", "files")); |
|
|
|
|
|
|
|
return new GetFileListTaskSuccessResult((GetFileListTask) task, parseHttpTorrentFiles(fileListResult, |
|
|
|
|
|
|
|
fhash)); |
|
|
|
|
|
|
|
|
|
|
|
case AddByFile: |
|
|
|
case AddByFile: |
|
|
|
|
|
|
|
|
|
|
|