This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Using web interface as remote API: torrent status parsing

Tags: None
(comma "," separated)
elmotheelk
Registered Member
Posts
2
Karma
0
Hi,

I am the developer of Transdroid, a remote torrent manager for Android. It supports setting up a remote connection to KTorrent from your Android phone and therebye viewing the active torrents, starting/stopping/removing them, etc.

Transdroid uses the KTorrent web interface to connect to KTorrent, by sending HTTP requests and parsing the XML response. For the list of torrents with statistics, I GET request '/data/torrents.xml' and parse teh XML output. I know this wasn't the original purpose but it still works fine and seems to me the only viable way to communicate with KTorretn over HTTP.

I have one problem however: parsing the statistics and most importantly the status of running torrents. A typical output of torrents.xml would look like this:
Code: Select all
<torrents>
    <torrent>
        <name>Super OS 9.10 DVD Ubuntu-Linux based OS</name>
        <info_hash>20e551d74f949ebbea752e97d0eee2085b7e4275</info_hash>
        <status>Downloading</status>
        <bytes_downloaded>443.3 MiB</bytes_downloaded>
        <bytes_uploaded>192.2 KiB</bytes_uploaded>
        <total_bytes>1.1 GiB</total_bytes>
        <total_bytes_to_download>1.1 GiB</total_bytes_to_download>
        <download_rate>5.1 MiB/s</download_rate>
        <upload_rate>67.8 KiB/s</upload_rate>
        <num_peers>19</num_peers>
        <seeders>18</seeders>
        <seeders_total>40</seeders_total>
        <leechers>1</leechers>
        <leechers_total>4</leechers_total>
        <running>1</running>
        <percentage>39.40</percentage>
        <num_files>5</num_files>
    </torrent>
</torrents>


These values are, however, localized and that's were the problem is. Parsing the number (that can have both . and , as decimal seperator) is nasty but possible. Parsing the <status> is however only practically possible in English. When the application language is set to something else (which can be many languages) the <status> is also localized and Transdroid would have to know each KTorrent-supported language then.

For example if I set my KTorrent to Dutch, the output would something like:
Code: Select all
<status>Downloaden</status>


Question is: would it be possible to include at least a reliably parseable (say, a number or enumeration-based) indicator that isn't localized? The only way users can use Transdroid now is to set their language to English.

Sorry to the long story and I hope it's clear. I test against Ubuntu 10.04's KTorrent 3.3.4.
George
Moderator
Posts
5421
Karma
1
I could add a parameter like this: /data/torrents.xml?l10n=no

Which would then return non localized data. Should not be that much work.
elmotheelk
Registered Member
Posts
2
Karma
0
That would be perfect. :-) Thanks for the fast response.


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], lockheed, Sogou [Bot], Yahoo [Bot]