A resubmit of the previous one, this time with understandable name. Copied the original submission text. This is a simple backend for btdigg.org. This site is especially interesting because it is not an indexer where uploaders add their torrents; it crawls the DHT and listens to all infohashes being exchanged by the nodes. Because of this, btdigg.org provides no description and no torrent files, only magnets. Moreover, there are no seeders and leechers (although there is the number of peers in the swarms) Note that there is no icon. Signed-off-by: Matthieu Rakotojaona <matthieu.rakotojaona@gmail.com> Signed-off-by: Romain Bignon <romain@symlink.me>
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
import urllib
|
|
|
|
from weboob.tools.browser import BaseBrowser
|
|
|
|
from .pages.index import IndexPage
|
|
from .pages.torrents import TorrentsPage, TorrentPage
|
|
|
|
|
|
__all__ = ['BTDiggBrowser']
|
|
|
|
|
|
class BTDiggBrowser(BaseBrowser):
|
|
DOMAIN = 'btdigg.org'
|
|
PROTOCOL = 'https'
|
|
ENCODING = 'utf-8'
|
|
USER_AGENT = BaseBrowser.USER_AGENTS['wget']
|
|
PAGES = {'https://btdigg.org/': IndexPage,
|
|
'https://btdigg.org/search?.*q=[^?]*': TorrentsPage,
|
|
'https://btdigg.org/search?.*info_hash=[^?]*': TorrentPage,
|
|
}
|
|
|
|
def home(self):
|
|
return self.location('https://btdigg.org')
|
|
|
|
def iter_torrents(self, pattern):
|
|
self.location('https://btdigg.org/search?q=%s' % urllib.quote_plus(pattern.encode('utf-8')))
|
|
|
|
assert self.is_on_page(TorrentsPage)
|
|
return self.page.iter_torrents()
|
|
|
|
def get_torrent(self, id):
|
|
self.location('https://btdigg.org/search?info_hash=%s' % id)
|
|
|
|
assert self.is_on_page(TorrentPage)
|
|
return self.page.get_torrent(id)
|
|
|
|
def get_torrent_file(self, id):
|
|
self.location('https://btdigg.org/search?info_hash=%s' % id)
|
|
|
|
assert self.is_on_page(TorrentPage)
|
|
return self.page.get_torrent_file(id)
|