示例#1
0
文件: views.py 项目: kaycal/DTest
def announce(request):
    
    try:
        params = torUtils.getParams(request.get_full_path()) # <-- Add this to models
        ih = params[u'info_hash'][0]
        
        # Match params to grab a specific torrent
        t = Torrent.getTorrent(info_hash=ih)
        
        # Check whether this is a new or returning client
        c = t.getPeer(ip=request.META["REMOTE_ADDR"])
        if c.size == 0:
            c = Client.create(n = params['name'], i = request.META["REMOTE_ADDR"], p = params['port'], ih = params[u'info_hash'][0])
        else:
            # Parse old client
            c = c[0]
        c.update(params["event"])

    except Exception as e:
        print "Torrent not found; ", e
    #     return HttpResponse("Newp!")
    # Match client against list of known users
    # -- Seeding:
    # -- Leeching:
    # -- Loading:
    # -- Inactive:
    # If no announce, double-check peer connections, and send a new list
    return HttpResponse("Fixthis")
示例#2
0
文件: views.py 项目: kaycal/DTest
def scrape(request):
    bdT = models.getTorrent(torUtils.getParams(request.get_full_path())['info_hash'][0])
    bd = {
          "files":{
                   bdT["info_hash"]:{
                        "complete":len(bdT["torrent"].peers.all()), # Number of seeders (integer)
                        "downloaded":0, # total number of times the tracker has registered a completion
                        "incomplete":0, # Number of non-seeder peers / leechers (integer)
                        "name":"Blah", # Torrent's internal name, as specified by the "name" file
                       }
                  }
         }
    return HttpResponse(bencode.bencode(bd))