Ejemplo n.º 1
0
    def download(self):
        from torretta.backends import backends

        backend = backends.get(self.backend)()
        assert backend, "%s backend has been disabled" % self.backend

        name = self.text
        if not name.endswith(".torrent"):
            name = name + ".torrent"
        self.filename = backend.get_torrent(self.link, name=name)
        self.save()
        return self.filename
Ejemplo n.º 2
0
    def handle(self, *torrents, **options):
        assert options.get('torrent')

        torrent = options.pop('torrent')
        client = clients.get(options.get('client'))()
        backend = backends.get(options.get('backend'))()

        try:
            torrent = Torrent.objects.get(pk=int(torrent))
        except ValueError:
            assert torrent.startswith("http")
            torrent = backend.get_torrent(torrent)

        client.download(torrent)
Ejemplo n.º 3
0
    def handle(self, *search, **options):

        if options.pop('list_backends'):
            for module in backends:
                print module
            return

        backend = options.get('backend', True)
        query = '%20'.join(search)

        mod = backends.get(backend)()
        table = [["pk", "text", "link", "rating", "seeds", "backend"]]

        limit = options.pop('limit')
        for i, t in enumerate(mod.get_torrents_list(query, use_cache=options.pop('use_cache'))):
            if limit > 0 and i >= limit:
                break
            table.append([str(t.pk), smart_str(t.text, errors='ignore'), t.link, t.rating, t.seeds, t.backend])
        pprint_table(sys.stdout, table)