Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL format for transmission ? #1

Open
stuaxo opened this issue Oct 18, 2016 · 12 comments
Open

URL format for transmission ? #1

stuaxo opened this issue Oct 18, 2016 · 12 comments

Comments

@stuaxo
Copy link

stuaxo commented Oct 18, 2016

TRACKERS = [
    "udp://192.168.23.80:9000",
]
tc.change_torrent(trackerAdd=TRACKERS, ids=[t.id])

I've been using rpc to transmission to add the url of the tracker, but it always says

Scrape error: Connection failed - Today 03:09:51 PM

Any idea what the url should look like ?

@stuaxo
Copy link
Author

stuaxo commented Oct 18, 2016

Ah, this seems to work on the desktop client, but can't get it working on the transmission web client, running on a raspberry pi - weird.

@stuaxo stuaxo closed this as completed Oct 18, 2016
@elektito
Copy link
Owner

Not sure about the difference between those two clients, but this could have something to do with the fact that pybtracker does not support scraping at the moment.

@stuaxo
Copy link
Author

stuaxo commented Oct 18, 2016

Any idea what is needed to implement scraping ? - Would it mean pybttracker serving a webpage, over something like aiohttp ?

@stuaxo
Copy link
Author

stuaxo commented Oct 18, 2016

Ah, just read up on scraping a little. .. yep. I know very little about trackers, but am learning.

@elektito
Copy link
Owner

UDP trackers work over UDP (to state the obvious) so naturally aiohttp won't help here. Take a look at BEP 15 to find out what needs to be done. Implementation involves something similar to what we're already doing with connect and announce requests. If there's anything in particular you need to know about just comment here and I'll help you as far as I can.

@stuaxo
Copy link
Author

stuaxo commented Oct 19, 2016

Here is how I'd probably implement this, if get time - is it possible to sanity check ?

A process_scrape to return the correct data, called from here

https://github.com/elektito/pybtracker/blob/master/pybtracker/server.py#L120

@elektito
Copy link
Owner

Yes, that's right.

@stuaxo
Copy link
Author

stuaxo commented Mar 8, 2017

I had a bit of a look at pytt, it has a really simple looking scraper implementation (also MIT licensed)
https://github.com/semk/Pytt/blob/master/pytt/tracker.py#L116

Having a look back at pybttracker I'm not quite sure how to convert this to using structs as in pybttracker.

@elektito
Copy link
Owner

elektito commented Mar 9, 2017

The code you are referring to is for an HTTP tracker which is text based. It won't help you with the UDP tracker which is binary.

Did you take a look at BEP 15? It clearly lays out the binary format for you. For example, the scrape request looks something like this:

Offset            Size                Name              Value
0                 64-bit integer  connection_id
8                 32-bit integer  action                2 // scrape
12                32-bit integer  transaction_id
16 + 20 * n       20-byte string  info_hash

So creating the request message would look something like: struct.pack('QII', connid, 2, tid) + infohash.

@stuaxo
Copy link
Author

stuaxo commented Mar 9, 2017

This made a lot more sense not being tired :)

Cheers for the example.

I knocked up a quick patch, any idea how I can test it (I guess creating the request similar to above) + see if its along the right lines ?

I tried running the tests in python3.5 and got this:

$ python test.py 
.............E................WARNING:pybtracker.server:Invalid event in announce.
.....WARNING:pybtracker.server:Invalid event in announce.
.....WARNING:pybtracker.server:Invalid event in announce.
.......
======================================================================
ERROR: test_announce (__main__.TrackerClientTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/mnt/data/home/stu/.virtualenvs/cord-py3/lib/python3.5/site-packages/asynctest/case.py", line 176, in run
    self._run_test_method(testMethod)
  File "/mnt/data/home/stu/.virtualenvs/cord-py3/lib/python3.5/site-packages/asynctest/case.py", line 228, in _run_test_method
    self.loop.run_until_complete(result)
  File "/mnt/data/home/stu/.virtualenvs/cord-py3/lib/python3.5/site-packages/asynctest/case.py", line 111, in wrapper
    return method(*args, **kwargs)
  File "/usr/lib/python3.5/asyncio/base_events.py", line 457, in run_until_complete
    return future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 292, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "test.py", line 410, in test_announce
    await client.announce(b'012345678901234567890', 2000, 1000, 900, 5, 130)
  File "/mnt/data/home/stu/projects/external/pybtracker/pybtracker/client.py", line 227, in announce
    infohash, num_want, downloaded, left, uploaded, event)
  File "/usr/lib/python3.5/asyncio/coroutines.py", line 209, in coro
    res = yield from res
TypeError: 'CoroutineMock' object is not iterable

----------------------------------------------------------------------
Ran 47 tests in 0.129s

FAILED (errors=1)

@elektito
Copy link
Owner

elektito commented Mar 9, 2017

I have no idea. I ran the tests on your fork and all test cases passed cleanly. Do you have any changes you haven't pushed to github?

@elektito elektito reopened this Mar 9, 2017
@stuaxo
Copy link
Author

stuaxo commented Mar 9, 2017

Nope, that's it.

I guess I need to add some tests of the functionality before this can be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants