Beispiel #1
0
def download_any(request):
    link = request.GET.get('link')
    name = request.GET.get('name')
    dl = UTorrentDL()
    dl.get(link, dump_dir)

    request = UTorrentConn("127.0.0.1:2219", "Boyshouse", "nickc")
    torrents = request.gettorrs()
    for torrent in torrents:
        if torrent.name == name:
            request.setprop("label", "Dump-" + torrent.hash, torrent.hash)    
    return HttpResponse()
Beispiel #2
0
    def download(self, link, name):
        if not os.path.exists(self.getDir()):
            os.mkdir(self.getDir())

        if os.path.isfile(self.path):
            os.remove(self.path)

        dl = UTorrentDL()
        dl.get(link, self.getDir())

        request = UTorrentConn("127.0.0.1:2219", "Boyshouse", "nickc")
        torrents = request.gettorrs()
        for torrent in torrents:
            # print torrent.name
            # print name
            if torrent.name == name:
                # Check if it is a .rar
                error = True
                while error:
                    try:
                        filename = request.getfilename(torrent.hash)
                    except:
                        continue
                    error = False
                # print filename
                # print 'hi'
                ext = os.path.splitext(filename)[1]
                # print ext
                if ext == ".rar" or fnmatch.fnmatch(ext, ".r[0-9][0-9]"):
                    request.removedata(torrent.hash)
                    request.remove(torrent.hash)
                    return False

                error = True
                while error:
                    try:
                        request.setprop("label", str(self.id), torrent.hash)
                    except:
                        continue
                    error = False

                self.dl_hash = torrent.hash
                self.downloading = True
                self.save()
                return True
        print "Did not find torrent"