[koharu] cleanup

- update BASE_PATTERN formatting
- fix groups indices
- add tests for new domains
- update docs/supportedsites
This commit is contained in:
Mike Fährmann
2024-11-15 22:35:11 +01:00
parent a09d9edaa6
commit e5c2882320
4 changed files with 37 additions and 15 deletions

View File

@@ -511,12 +511,6 @@ Consider all listed sites to potentially be NSFW.
<td>Soundtracks</td> <td>Soundtracks</td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td>Koharu</td>
<td>https://koharu.to/</td>
<td>Favorites, Galleries, Search Results</td>
<td></td>
</tr>
<tr> <tr>
<td>Komikcast</td> <td>Komikcast</td>
<td>https://komikcast.cz/</td> <td>https://komikcast.cz/</td>
@@ -829,6 +823,12 @@ Consider all listed sites to potentially be NSFW.
<td>Articles, Tag Searches</td> <td>Articles, Tag Searches</td>
<td></td> <td></td>
</tr> </tr>
<tr>
<td>SchaleNetwork</td>
<td>https://niyaniya.moe/</td>
<td>Favorites, Galleries, Search Results</td>
<td></td>
</tr>
<tr> <tr>
<td>Scrolller</td> <td>Scrolller</td>
<td>https://scrolller.com/</td> <td>https://scrolller.com/</td>

View File

@@ -6,13 +6,19 @@
# it under the terms of the GNU General Public License version 2 as # it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation. # published by the Free Software Foundation.
"""Extractors for https://koharu.to/""" """Extractors for https://niyaniya.moe/"""
from .common import GalleryExtractor, Extractor, Message from .common import GalleryExtractor, Extractor, Message
from .. import text, exception from .. import text, exception
from ..cache import cache from ..cache import cache
BASE_PATTERN = r"(?i)(?:https?://)?((?:anchira|seia)\.to|(?:niyaniya|shupogaki)\.moe|hoshino\.one)" BASE_PATTERN = (
r"(?i)(?:https?://)?("
r"(?:niyaniya|shupogaki)\.moe|"
r"(?:koharu|anchira|seia)\.to|"
r"(?:hoshino)\.one"
r")"
)
class KoharuExtractor(Extractor): class KoharuExtractor(Extractor):
@@ -179,11 +185,11 @@ class KoharuGalleryExtractor(KoharuExtractor, GalleryExtractor):
break break
except KeyError: except KeyError:
self.log.debug("%s: Format %s is not available", self.log.debug("%s: Format %s is not available",
self.groups[0], fmtid) self.groups[1], fmtid)
else: else:
raise exception.NotFoundError("format") raise exception.NotFoundError("format")
self.log.debug("%s: Selected format %s", self.groups[0], fmtid) self.log.debug("%s: Selected format %s", self.groups[1], fmtid)
fmt["w"] = fmtid fmt["w"] = fmtid
return fmt return fmt
@@ -195,7 +201,7 @@ class KoharuSearchExtractor(KoharuExtractor):
example = "https://niyaniya.moe/?s=QUERY" example = "https://niyaniya.moe/?s=QUERY"
def items(self): def items(self):
params = text.parse_query(self.groups[0]) params = text.parse_query(self.groups[1])
params["page"] = text.parse_int(params.get("page"), 1) params["page"] = text.parse_int(params.get("page"), 1)
return self._pagination("/books", params) return self._pagination("/books", params)
@@ -209,7 +215,7 @@ class KoharuFavoriteExtractor(KoharuExtractor):
def items(self): def items(self):
self.login() self.login()
params = text.parse_query(self.groups[0]) params = text.parse_query(self.groups[1])
params["page"] = text.parse_int(params.get("page"), 1) params["page"] = text.parse_int(params.get("page"), 1)
return self._pagination("/favorites", params) return self._pagination("/favorites", params)

View File

@@ -84,6 +84,7 @@ CATEGORY_MAP = {
"jpgfish" : "JPG Fish", "jpgfish" : "JPG Fish",
"kabeuchi" : "かべうち", "kabeuchi" : "かべうち",
"kemonoparty" : "Kemono", "kemonoparty" : "Kemono",
"koharu" : "SchaleNetwork",
"livedoor" : "livedoor Blog", "livedoor" : "livedoor Blog",
"ohpolly" : "Oh Polly", "ohpolly" : "Oh Polly",
"omgmiamiswimwear": "Omg Miami Swimwear", "omgmiamiswimwear": "Omg Miami Swimwear",

View File

@@ -66,9 +66,24 @@ __tests__ = (
}, },
{ {
"#url" : "https://anchira.to/g/14216/6c67076fdd45", "#url" : "https://koharu.to/g/14216/6c67076fdd45",
"#category": ("", "koharu", "gallery"), "#class": koharu.KoharuGalleryExtractor,
"#class" : koharu.KoharuGalleryExtractor, },
{
"#url" : "https://anchira.to/g/14216/6c67076fdd45",
"#class": koharu.KoharuGalleryExtractor,
},
{
"#url" : "https://seia.to/g/14216/6c67076fdd45",
"#class": koharu.KoharuGalleryExtractor,
},
{
"#url" : "https://shupogaki.moe/g/14216/6c67076fdd45",
"#class": koharu.KoharuGalleryExtractor,
},
{
"#url" : "https://hoshino.one/g/14216/6c67076fdd45",
"#class": koharu.KoharuGalleryExtractor,
}, },
{ {