clean code
This commit is contained in:
parent
99eff17554
commit
49b46ff095
4 changed files with 15 additions and 45 deletions
|
|
@ -31,19 +31,14 @@ __all__ = ['ArteBrowser']
|
||||||
class ArteBrowser(BaseBrowser):
|
class ArteBrowser(BaseBrowser):
|
||||||
DOMAIN = u'videos.arte.tv'
|
DOMAIN = u'videos.arte.tv'
|
||||||
ENCODING = None
|
ENCODING = None
|
||||||
PAGES = {r'http://videos.arte.tv/%(lang)s/videos/arte7.*': IndexPage,
|
PAGES = {r'http://videos.arte.tv/\w+/videos/arte7.*': IndexPage,
|
||||||
r'http://videos.arte.tv/%(lang)s/do_search/videos/%(searchlang)s.*': IndexPage,
|
r'http://videos.arte.tv/\w+/do_search/videos/.*': IndexPage,
|
||||||
r'http://videos.arte.tv/%(lang)s/videos/(?P<id>.+)\.html': VideoPage
|
r'http://videos.arte.tv/\w+/videos/(?P<id>.+)\.html': VideoPage
|
||||||
}
|
}
|
||||||
|
|
||||||
SEARCH_LANG = {'fr': 'recherche', 'de':'suche', 'en': 'search'}
|
SEARCH_LANG = {'fr': 'recherche', 'de':'suche', 'en': 'search'}
|
||||||
|
|
||||||
def __init__(self, lang, quality, *args, **kwargs):
|
def __init__(self, lang, quality, *args, **kwargs):
|
||||||
last_pages = self.PAGES
|
|
||||||
self.PAGES = {}
|
|
||||||
for url, page in last_pages.iteritems():
|
|
||||||
self.PAGES[url % {'lang': lang, 'searchlang': self.SEARCH_LANG[lang]}] = page
|
|
||||||
|
|
||||||
BaseBrowser.__init__(self, *args, **kwargs)
|
BaseBrowser.__init__(self, *args, **kwargs)
|
||||||
self.lang = lang
|
self.lang = lang
|
||||||
self.quality = quality
|
self.quality = quality
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ import mechanize
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import re
|
import re
|
||||||
|
|
||||||
# Browser
|
|
||||||
class Cragr(BaseBrowser):
|
class Cragr(BaseBrowser):
|
||||||
PROTOCOL = 'https'
|
PROTOCOL = 'https'
|
||||||
ENCODING = 'utf-8'
|
ENCODING = 'utf-8'
|
||||||
|
|
@ -37,12 +36,12 @@ class Cragr(BaseBrowser):
|
||||||
|
|
||||||
def __init__(self, website, *args, **kwargs):
|
def __init__(self, website, *args, **kwargs):
|
||||||
self.DOMAIN = website
|
self.DOMAIN = website
|
||||||
self.PAGES = {'https://%s/' % website: pages.LoginPage,
|
self.PAGES = {'https://[^/]+/': pages.LoginPage,
|
||||||
'https://%s/.*\.c.*' % website: pages.AccountsList,
|
'https://[^/]+/.*\.c.*': pages.AccountsList,
|
||||||
('https://%s/login/process' % website) + self.SESSION_REGEXP: pages.AccountsList,
|
'https://[^/]+/login/process%s' % self.SESSION_REGEXP: pages.AccountsList,
|
||||||
'https://%s/accounting/listAccounts' % website: pages.AccountsList,
|
'https://[^/]+/accounting/listAccounts': pages.AccountsList,
|
||||||
'https://%s/accounting/listOperations' % website: pages.AccountsList,
|
'https://[^/]+/accounting/listOperations': pages.AccountsList,
|
||||||
'https://%s/accounting/showAccountDetail.+' % website: pages.AccountsList,
|
'https://[^/]+/accounting/showAccountDetail.+': pages.AccountsList,
|
||||||
}
|
}
|
||||||
BaseBrowser.__init__(self, *args, **kwargs)
|
BaseBrowser.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,18 +28,14 @@ __all__ = ['GazelleBrowser']
|
||||||
|
|
||||||
|
|
||||||
class GazelleBrowser(BaseBrowser):
|
class GazelleBrowser(BaseBrowser):
|
||||||
PAGES = {'https?://%s/?(index.php)?': IndexPage,
|
PAGES = {'https?://[^/]+/?(index.php)?': IndexPage,
|
||||||
'https?://%s/login.php': LoginPage,
|
'https?://[^/]+/login.php': LoginPage,
|
||||||
'https?://%s/torrents.php.*': TorrentsPage,
|
'https?://[^/]+/torrents.php.*': TorrentsPage,
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, protocol, domain, *args, **kwargs):
|
def __init__(self, protocol, domain, *args, **kwargs):
|
||||||
self.DOMAIN = domain
|
self.DOMAIN = domain
|
||||||
self.PROTOCOL = protocol
|
self.PROTOCOL = protocol
|
||||||
self.PAGES = {}
|
|
||||||
for key, value in GazelleBrowser.PAGES.iteritems():
|
|
||||||
self.PAGES[key % domain] = value
|
|
||||||
|
|
||||||
BaseBrowser.__init__(self, *args, **kwargs)
|
BaseBrowser.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@
|
||||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
import urllib
|
||||||
|
|
||||||
from weboob.tools.browser import BaseBrowser
|
from weboob.tools.browser import BaseBrowser
|
||||||
|
|
||||||
from .pages.index import IndexPage
|
from .pages.index import IndexPage
|
||||||
|
|
@ -37,33 +39,11 @@ class PiratebayBrowser(BaseBrowser):
|
||||||
'https://thepiratebay.org/torrent/.*' : TorrentPage
|
'https://thepiratebay.org/torrent/.*' : TorrentPage
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
#self.DOMAIN = domain
|
|
||||||
#self.PROTOCOL = protocol
|
|
||||||
#self.PAGES = {}
|
|
||||||
#for key, value in PiratebayBrowser.PAGES.iteritems():
|
|
||||||
# self.PAGES[key % domain] = value
|
|
||||||
|
|
||||||
BaseBrowser.__init__(self, *args, **kwargs)
|
|
||||||
|
|
||||||
#def login(self):
|
|
||||||
# if not self.is_on_page(LoginPage):
|
|
||||||
# self.home()
|
|
||||||
# self.page.login(self.username, self.password)
|
|
||||||
|
|
||||||
#def is_logged(self):
|
|
||||||
# if not self.page or self.is_on_page(LoginPage):
|
|
||||||
# return False
|
|
||||||
# if self.is_on_page(IndexPage):
|
|
||||||
# return self.page.is_logged()
|
|
||||||
# return True
|
|
||||||
|
|
||||||
def home(self):
|
def home(self):
|
||||||
return self.location('https://thepiratebay.org')
|
return self.location('https://thepiratebay.org')
|
||||||
|
|
||||||
def iter_torrents(self, pattern):
|
def iter_torrents(self, pattern):
|
||||||
#self.location(self.buildurl('/torrents.php', searchstr=pattern))
|
self.location('https://thepiratebay.org/search/%s/0/7/0' % urllib.quote_plus(pattern.encode('utf-8')))
|
||||||
self.location('https://thepiratebay.org/search/%s/0/7/0' % pattern.encode('utf-8'))
|
|
||||||
|
|
||||||
assert self.is_on_page(TorrentsPage)
|
assert self.is_on_page(TorrentsPage)
|
||||||
return self.page.iter_torrents()
|
return self.page.iter_torrents()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue