1
0
Fork 0
mirror of https://github.com/kemayo/leech synced 2025-12-06 08:22:56 +01:00

Fiction.live: niche URLs

* occasional stories with "Sci-fi" in the URL instead of "stories"
* rare cases of `-` in the work id

Fixes #31
This commit is contained in:
David Lynch 2019-11-14 14:45:19 -06:00
parent a856f9d0f8
commit 6631095726

View file

@ -15,12 +15,12 @@ class FictionLive(Site):
@staticmethod @staticmethod
def matches(url): def matches(url):
# e.g. https://fiction.live/stories/Descendant-of-a-Demon-Lord/SBBA49fQavNQMWxFT # e.g. https://fiction.live/stories/Descendant-of-a-Demon-Lord/SBBA49fQavNQMWxFT
match = re.match(r'^(https?://fiction\.live/stories/[^\/]+/[0-9a-zA-Z]+)/?.*', url) match = re.match(r'^(https?://fiction\.live/(?:stories|Sci-fi)/[^\/]+/[0-9a-zA-Z\-]+)/?.*', url)
if match: if match:
return match.group(1) return match.group(1)
def extract(self, url): def extract(self, url):
workid = re.match(r'^https?://fiction\.live/stories/[^\/]+/([0-9a-zA-Z]+)/?.*', url).group(1) workid = re.match(r'^https?://fiction\.live/(?:stories|Sci-fi)/[^\/]+/([0-9a-zA-Z\-]+)/?.*', url).group(1)
response = self.session.get(f'https://fiction.live/api/node/{workid}').json() response = self.session.get(f'https://fiction.live/api/node/{workid}').json()