[imagehosts] remove 'splitext' import

This commit is contained in:
Mike Fährmann
2025-12-22 17:29:29 +01:00
parent 568faee726
commit eda6957d4c
2 changed files with 22 additions and 12 deletions

View File

@@ -11,7 +11,6 @@
from .common import Extractor, Message
from .. import text, exception
from ..cache import memcache
from os.path import splitext
class ImagehostImageExtractor(Extractor):
@@ -98,9 +97,6 @@ class ImxtoImageExtractor(ImagehostImageExtractor):
ImagehostImageExtractor.__init__(self, match)
if "/img-" in self.page_url:
self.page_url = self.page_url.replace("img.yt", "imx.to")
self.url_ext = True
else:
self.url_ext = False
def get_info(self, page):
url, pos = text.extract(
@@ -108,9 +104,7 @@ class ImxtoImageExtractor(ImagehostImageExtractor):
if not url:
self.not_found()
filename, pos = text.extract(page, ' title="', '"', pos)
if self.url_ext and filename:
filename += splitext(url)[1]
return url, filename or url
return url, filename or None
def metadata(self, page):
extr = text.extract_from(page, page.index("[ FILESIZE <"))
@@ -172,7 +166,7 @@ class AcidimgImageExtractor(ImagehostImageExtractor):
if not filename:
filename, pos = text.extract(page, 'alt="', '"', pos)
return url, (filename + splitext(url)[1]) if filename else url
return url, filename or None
class ImagevenueImageExtractor(ImagehostImageExtractor):

View File

@@ -14,12 +14,16 @@ __tests__ = (
"#comment" : "new-style URL",
"#category": ("imagehost", "imxto", "image"),
"#class" : imagehosts.ImxtoImageExtractor,
"#sha1_url" : "ab2173088a6cdef631d7a47dec4a5da1c6a00130",
"#results" : "https://image.imx.to/u/i/2018/04/09/1qdeva.png",
"#sha1_content": "0c8768055e4e20e7c7259608b67799171b691140",
"filename" : "test-テスト",
"extension": "png",
"post_url" : "https://imx.to/i/1qdeva",
"size" : 18,
"width" : 64,
"height": 32,
"token" : "1qdeva",
"hash" : "94d56c599223c59f3feb71ea603484d1",
},
@@ -28,12 +32,16 @@ __tests__ = (
"#comment" : "old-style URL",
"#category": ("imagehost", "imxto", "image"),
"#class" : imagehosts.ImxtoImageExtractor,
"#sha1_url" : "a83fe6ef1909a318c4d49fcf2caf62f36c3f9204",
"#results" : "https://image.imx.to/u/i/2016/08/03/57a2050547b60.jpg",
"#sha1_content": "54592f2635674c25677c6872db3709d343cdf92f",
"filename" : "test",
"extension": "jpg",
"post_url" : "https://imx.to/img-57a2050547b97.html",
"size" : 5284,
"width" : 320,
"height": 160,
"token" : "57a2050547b97",
"hash" : "40da6aaa7b8c42b18ef74309bbc713fc",
},
@@ -42,7 +50,16 @@ __tests__ = (
"#comment" : "img.yt domain",
"#category": ("imagehost", "imxto", "image"),
"#class" : imagehosts.ImxtoImageExtractor,
"#sha1_url": "a83fe6ef1909a318c4d49fcf2caf62f36c3f9204",
"#results" : "https://image.imx.to/u/i/2016/08/03/57a2050547b60.jpg",
"filename" : "test",
"extension": "jpg",
"post_url" : "https://imx.to/img-57a2050547b97.html",
"size" : 5284,
"width" : 320,
"height": 160,
"token" : "57a2050547b97",
"hash" : "40da6aaa7b8c42b18ef74309bbc713fc",
},
{
@@ -69,7 +86,6 @@ __tests__ = (
"#class" : imagehosts.ImxtoGalleryExtractor,
"#pattern" : imagehosts.ImxtoImageExtractor.pattern,
"#count" : 1037,
"#auth" : True,
"title": "freckledspirit",
},