weboob.tools.browser -> weboob.deprecated.browser weboob.tools.parsers -> weboob.deprecated.browser.parsers weboob.tools.mech -> weboob.deprecated.mech weboob.browser2 -> weboob.browser weboob.core.exceptions -> weboob.exceptions Also, the new tree for browser2 is: weboob.browser: import weboob.browser.browsers.* and weboob.browser.url.* weboob.browser.browsers: all browsers (including PagesBrowser and LoginBrowser) weboob.browser.url: the URL class weboob.browser.profiles: all Profile classes weboob.browser.sessions: WeboobSession and FuturesSession weboob.browser.cookies: that's a cookies thing weboob.browser.pages: all Page and derivated classes, and Form class weboob.browser.exceptions: specific browser exceptions weboob.browser.elements: AbstractElement classes, and 'method' decorator weboob.browser.filters.*: all filters
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
import urllib
|
|
|
|
from weboob.deprecated.browser import Browser
|
|
|
|
from .pages.index import IndexPage
|
|
from .pages.torrents import TorrentsPage, TorrentPage
|
|
|
|
|
|
__all__ = ['BTDiggBrowser']
|
|
|
|
|
|
class BTDiggBrowser(Browser):
|
|
DOMAIN = 'btdigg.org'
|
|
PROTOCOL = 'https'
|
|
ENCODING = 'utf-8'
|
|
USER_AGENT = Browser.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)
|