[imagehosts] remove 'splitext' import
This commit is contained in:
@@ -11,7 +11,6 @@
|
|||||||
from .common import Extractor, Message
|
from .common import Extractor, Message
|
||||||
from .. import text, exception
|
from .. import text, exception
|
||||||
from ..cache import memcache
|
from ..cache import memcache
|
||||||
from os.path import splitext
|
|
||||||
|
|
||||||
|
|
||||||
class ImagehostImageExtractor(Extractor):
|
class ImagehostImageExtractor(Extractor):
|
||||||
@@ -98,9 +97,6 @@ class ImxtoImageExtractor(ImagehostImageExtractor):
|
|||||||
ImagehostImageExtractor.__init__(self, match)
|
ImagehostImageExtractor.__init__(self, match)
|
||||||
if "/img-" in self.page_url:
|
if "/img-" in self.page_url:
|
||||||
self.page_url = self.page_url.replace("img.yt", "imx.to")
|
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):
|
def get_info(self, page):
|
||||||
url, pos = text.extract(
|
url, pos = text.extract(
|
||||||
@@ -108,9 +104,7 @@ class ImxtoImageExtractor(ImagehostImageExtractor):
|
|||||||
if not url:
|
if not url:
|
||||||
self.not_found()
|
self.not_found()
|
||||||
filename, pos = text.extract(page, ' title="', '"', pos)
|
filename, pos = text.extract(page, ' title="', '"', pos)
|
||||||
if self.url_ext and filename:
|
return url, filename or None
|
||||||
filename += splitext(url)[1]
|
|
||||||
return url, filename or url
|
|
||||||
|
|
||||||
def metadata(self, page):
|
def metadata(self, page):
|
||||||
extr = text.extract_from(page, page.index("[ FILESIZE <"))
|
extr = text.extract_from(page, page.index("[ FILESIZE <"))
|
||||||
@@ -172,7 +166,7 @@ class AcidimgImageExtractor(ImagehostImageExtractor):
|
|||||||
if not filename:
|
if not filename:
|
||||||
filename, pos = text.extract(page, 'alt="', '"', pos)
|
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):
|
class ImagevenueImageExtractor(ImagehostImageExtractor):
|
||||||
|
|||||||
@@ -14,12 +14,16 @@ __tests__ = (
|
|||||||
"#comment" : "new-style URL",
|
"#comment" : "new-style URL",
|
||||||
"#category": ("imagehost", "imxto", "image"),
|
"#category": ("imagehost", "imxto", "image"),
|
||||||
"#class" : imagehosts.ImxtoImageExtractor,
|
"#class" : imagehosts.ImxtoImageExtractor,
|
||||||
"#sha1_url" : "ab2173088a6cdef631d7a47dec4a5da1c6a00130",
|
"#results" : "https://image.imx.to/u/i/2018/04/09/1qdeva.png",
|
||||||
"#sha1_content": "0c8768055e4e20e7c7259608b67799171b691140",
|
"#sha1_content": "0c8768055e4e20e7c7259608b67799171b691140",
|
||||||
|
|
||||||
|
"filename" : "test-テスト",
|
||||||
|
"extension": "png",
|
||||||
|
"post_url" : "https://imx.to/i/1qdeva",
|
||||||
"size" : 18,
|
"size" : 18,
|
||||||
"width" : 64,
|
"width" : 64,
|
||||||
"height": 32,
|
"height": 32,
|
||||||
|
"token" : "1qdeva",
|
||||||
"hash" : "94d56c599223c59f3feb71ea603484d1",
|
"hash" : "94d56c599223c59f3feb71ea603484d1",
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -28,12 +32,16 @@ __tests__ = (
|
|||||||
"#comment" : "old-style URL",
|
"#comment" : "old-style URL",
|
||||||
"#category": ("imagehost", "imxto", "image"),
|
"#category": ("imagehost", "imxto", "image"),
|
||||||
"#class" : imagehosts.ImxtoImageExtractor,
|
"#class" : imagehosts.ImxtoImageExtractor,
|
||||||
"#sha1_url" : "a83fe6ef1909a318c4d49fcf2caf62f36c3f9204",
|
"#results" : "https://image.imx.to/u/i/2016/08/03/57a2050547b60.jpg",
|
||||||
"#sha1_content": "54592f2635674c25677c6872db3709d343cdf92f",
|
"#sha1_content": "54592f2635674c25677c6872db3709d343cdf92f",
|
||||||
|
|
||||||
|
"filename" : "test",
|
||||||
|
"extension": "jpg",
|
||||||
|
"post_url" : "https://imx.to/img-57a2050547b97.html",
|
||||||
"size" : 5284,
|
"size" : 5284,
|
||||||
"width" : 320,
|
"width" : 320,
|
||||||
"height": 160,
|
"height": 160,
|
||||||
|
"token" : "57a2050547b97",
|
||||||
"hash" : "40da6aaa7b8c42b18ef74309bbc713fc",
|
"hash" : "40da6aaa7b8c42b18ef74309bbc713fc",
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -42,7 +50,16 @@ __tests__ = (
|
|||||||
"#comment" : "img.yt domain",
|
"#comment" : "img.yt domain",
|
||||||
"#category": ("imagehost", "imxto", "image"),
|
"#category": ("imagehost", "imxto", "image"),
|
||||||
"#class" : imagehosts.ImxtoImageExtractor,
|
"#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,
|
"#class" : imagehosts.ImxtoGalleryExtractor,
|
||||||
"#pattern" : imagehosts.ImxtoImageExtractor.pattern,
|
"#pattern" : imagehosts.ImxtoImageExtractor.pattern,
|
||||||
"#count" : 1037,
|
"#count" : 1037,
|
||||||
"#auth" : True,
|
|
||||||
|
|
||||||
"title": "freckledspirit",
|
"title": "freckledspirit",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user