1
0
Fork 0
mirror of https://github.com/kemayo/leech synced 2025-12-09 18:04:27 +01:00

Explicitly support XenForo

This commit is contained in:
David Lynch 2015-10-28 15:52:11 -05:00
parent ecfe1f35a8
commit 150d0f63d5
2 changed files with 39 additions and 13 deletions

View file

@ -20,6 +20,8 @@ class Site:
def _soup(self, url, method='html5lib'):
page = self.fetch(url)
if not page:
raise SiteException("Couldn't fetch", url)
return BeautifulSoup(page, method)
class SiteException(Exception):
@ -35,4 +37,4 @@ def get(url):
return site_class
# And now, the things that will use this:
from . import spacebattles, fanfictionnet, deviantart, stash
from . import xenforo, fanfictionnet, deviantart, stash

View file

@ -4,13 +4,14 @@ import re
from . import register, Site, SiteException
@register
class SpaceBattles(Site):
"""SpaceBattles is a forum..."""
class XenForo(Site):
"""XenForo is forum software that powers a number of fiction-related forums."""
@staticmethod
def matches(url):
return re.match(r'^https?://forums.(?:spacebattles|sufficientvelocity).com/threads/.*\d+/?.*', url)
domain = False
@classmethod
def matches(cls, url):
return re.match(r'^https?://%s/threads/.*\d+/?.*' % cls.domain, url)
def extract(self, url):
soup = self._soup(url)
@ -101,12 +102,35 @@ class SpaceBattles(Site):
return post.prettify()
@register
class SpaceBattlesIndex(SpaceBattles):
"""A spacebattles thread with an index post"""
@staticmethod
def matches(url):
return re.match(r'^https?://forums.(?:spacebattles|sufficientvelocity).com/posts/\d+/?.*', url)
class XenForoIndex(XenForo):
@classmethod
def matches(cls, url):
return re.match(r'^https?://%s/posts/\d+/?.*' % cls.domain, url)
def _chapter_list(self, url):
return self._chapter_list_index(url)
@register
class SpaceBattles(XenForo):
domain = 'forums.spacebattles.com'
@register
class SpaceBattlesIndex(XenForoIndex):
domain = 'forums.spacebattles.com'
@register
class SufficientVelocity(XenForo):
domain = 'forums.sufficientvelocity.com'
@register
class QuestionableQuesting(XenForo):
domain = 'forum.questionablequesting.com'
@register
class QuestionableQuestingIndex(QuestionableQuesting, XenForoIndex):
pass