[imgchili] workaround for long filenames

This commit is contained in:
Mike Fährmann
2016-09-10 13:12:02 +02:00
parent 155af213a9
commit 888a988725
2 changed files with 10 additions and 8 deletions

View File

@@ -43,7 +43,7 @@ class ImgchiliExtractor(Extractor):
class ImgchiliImageExtractor(ImgchiliExtractor): class ImgchiliImageExtractor(ImgchiliExtractor):
"""Extractor for single images from imgchili""" """Extractor for single images from imgchili.net"""
subcategory = "image" subcategory = "image"
filename_fmt = "{filename}" filename_fmt = "{filename}"
pattern = [r"(?:https?://)?(?:www\.)?imgchili\.net/show/\d+/(\d+)_[^/]+"] pattern = [r"(?:https?://)?(?:www\.)?imgchili\.net/show/\d+/(\d+)_[^/]+"]
@@ -54,15 +54,17 @@ class ImgchiliImageExtractor(ImgchiliExtractor):
})] })]
def get_job_metadata(self, page): def get_job_metadata(self, page):
name , pos = text.extract(page, 'An image called ', '" />\n') name1 , pos = text.extract(page, 'name="description" content="', '. An ')
name2 , pos = text.extract(page, 'image called ', '" />\n', pos)
_ , pos = text.extract(page, '<link rel="image_src"', '', pos) _ , pos = text.extract(page, '<link rel="image_src"', '', pos)
self.imgurl, pos = text.extract(page, ' href="', '"', pos) self.imgurl, pos = text.extract(page, ' href="', '"', pos)
name = name.split("in the gallery ") parts = name2.split("in the gallery ")
return text.nameext_from_url(name[0], { name = parts[0] if not parts[0].endswith("...") else name1
return text.nameext_from_url(name, {
"category": self.category, "category": self.category,
"subcategory": self.subcategory, "subcategory": self.subcategory,
"image-id": self.match.group(1), "image-id": self.match.group(1),
"title": text.unescape(name[-1]) if len(name) > 1 else "" "title": text.unescape(parts[-1]) if len(parts) > 1 else ""
}) })
def get_images(self, page): def get_images(self, page):
@@ -70,7 +72,7 @@ class ImgchiliImageExtractor(ImgchiliExtractor):
class ImgchiliAlbumExtractor(ImgchiliExtractor): class ImgchiliAlbumExtractor(ImgchiliExtractor):
"""Extractor for image-albums from imgchili""" """Extractor for image-albums from imgchili.net"""
subcategory = "album" subcategory = "album"
directory_fmt = ["{category}", "{title} - {key}"] directory_fmt = ["{category}", "{title} - {key}"]
filename_fmt = "{num:>03} {filename}" filename_fmt = "{num:>03} {filename}"

View File

@@ -6,14 +6,14 @@
# 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.
"""Extract images from http://img.yt/""" """Extract images from https://img.yt/"""
from .common import Extractor, Message from .common import Extractor, Message
from .. import text from .. import text
from os.path import splitext from os.path import splitext
class ImgytImageExtractor(Extractor): class ImgytImageExtractor(Extractor):
"""Extractor for single images from img.yt"""
category = "imgyt" category = "imgyt"
directory_fmt = ["{category}"] directory_fmt = ["{category}"]
filename_fmt = "{filename}" filename_fmt = "{filename}"