mirror of
https://github.com/wassname/FanFicFare.git
synced 2026-09-11 11:52:07 +08:00
Backported some changes from the http://nocturnal-light.net/ adapter
This commit is contained in:
@@ -12,6 +12,16 @@ def getClass():
|
||||
return SpikeluverComAdapter
|
||||
|
||||
|
||||
# yields Tag _and_ NavigableString siblings from the given tag. The
|
||||
# BeautifulSoup findNextSiblings() method for some reasons only returns either
|
||||
# NavigableStrings _or_ Tag objects, not both.
|
||||
def _yield_next_siblings(tag):
|
||||
sibling = tag.nextSibling
|
||||
while sibling:
|
||||
yield sibling
|
||||
sibling = sibling.nextSibling
|
||||
|
||||
|
||||
class SpikeluverComAdapter(BaseSiteAdapter):
|
||||
SITE_ABBREVIATION = 'slc'
|
||||
SITE_DOMAIN = 'spikeluver.com'
|
||||
@@ -107,11 +117,7 @@ class SpikeluverComAdapter(BaseSiteAdapter):
|
||||
contents = []
|
||||
keep_summary_html = self.getConfig('keep_summary_html')
|
||||
|
||||
# For some reason span_tag.findNextSiblings() only returns tags
|
||||
# instead both NavigableString objects _and_ Tag objects as
|
||||
# documented, so navigate manually
|
||||
sibling = span_tag.nextSibling
|
||||
while sibling:
|
||||
for sibling in _yield_next_siblings(span_tag):
|
||||
if isinstance(sibling, BeautifulSoup.Tag):
|
||||
# Encountered next label, break. Not as bad as other
|
||||
# e-fiction sites, let's hope this is enough for proper
|
||||
@@ -125,7 +131,6 @@ class SpikeluverComAdapter(BaseSiteAdapter):
|
||||
contents.append(''.join(sibling(text=True)))
|
||||
else:
|
||||
contents.append(sibling)
|
||||
sibling = sibling.nextSibling
|
||||
|
||||
# Remove the preceding break line tag and other crud
|
||||
contents.pop()
|
||||
|
||||
@@ -12,6 +12,16 @@ def getClass():
|
||||
return Voracity2EficComAdapter
|
||||
|
||||
|
||||
# yields Tag _and_ NavigableString siblings from the given tag. The
|
||||
# BeautifulSoup findNextSiblings() method for some reasons only returns either
|
||||
# NavigableStrings _or_ Tag objects, not both.
|
||||
def _yield_next_siblings(tag):
|
||||
sibling = tag.nextSibling
|
||||
while sibling:
|
||||
yield sibling
|
||||
sibling = sibling.nextSibling
|
||||
|
||||
|
||||
class Voracity2EficComAdapter(BaseSiteAdapter):
|
||||
SITE_ABBREVIATION = 'voe'
|
||||
SITE_DOMAIN = 'voracity2.e-fic.com'
|
||||
@@ -147,11 +157,7 @@ class Voracity2EficComAdapter(BaseSiteAdapter):
|
||||
contents = []
|
||||
keep_summary_html = self.getConfig('keep_summary_html')
|
||||
|
||||
# For some reason span_tag.findNextSiblings() only returns tags
|
||||
# instead both NavigableString objects _and_ Tag objects as
|
||||
# documented, so navigate manually
|
||||
sibling = b_tag.nextSibling
|
||||
while sibling:
|
||||
for sibling in _yield_next_siblings(b_tag):
|
||||
if isinstance(sibling, BeautifulSoup.Tag):
|
||||
# Encountered next label, break. This method is the
|
||||
# safest and most reliable I could think of. Blame
|
||||
@@ -167,7 +173,6 @@ class Voracity2EficComAdapter(BaseSiteAdapter):
|
||||
contents.append(''.join(sibling(text=True)))
|
||||
else:
|
||||
contents.append(sibling)
|
||||
sibling = sibling.nextSibling
|
||||
|
||||
# Remove the preceding break line tag and other crud
|
||||
contents.pop()
|
||||
|
||||
Reference in New Issue
Block a user