[path] implement dynamic length directories (#1350)
append directory segments for each item of a list (or general non-string iterable), which can be returned with the 'I' specifier
This commit is contained in:
@@ -19,7 +19,7 @@ BASE_PATTERN = r"(?:https?://)?(?:www\.)?aryion\.com/g4"
|
|||||||
class AryionExtractor(Extractor):
|
class AryionExtractor(Extractor):
|
||||||
"""Base class for aryion extractors"""
|
"""Base class for aryion extractors"""
|
||||||
category = "aryion"
|
category = "aryion"
|
||||||
directory_fmt = ("{category}", "{user!l}", "{path:J - }")
|
directory_fmt = ("{category}", "{user!l}", "{path:I}")
|
||||||
filename_fmt = "{id} {title}.{extension}"
|
filename_fmt = "{id} {title}.{extension}"
|
||||||
archive_fmt = "{id}"
|
archive_fmt = "{id}"
|
||||||
cookies_domain = ".aryion.com"
|
cookies_domain = ".aryion.com"
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ class BbcGalleryExtractor(GalleryExtractor):
|
|||||||
"""Extractor for a programme gallery on bbc.co.uk"""
|
"""Extractor for a programme gallery on bbc.co.uk"""
|
||||||
category = "bbc"
|
category = "bbc"
|
||||||
root = "https://www.bbc.co.uk"
|
root = "https://www.bbc.co.uk"
|
||||||
directory_fmt = ("{category}", "{path[0]}", "{path[1]}", "{path[2]}",
|
directory_fmt = ("{category}", "{path:I}")
|
||||||
"{path[3:]:J - /}")
|
|
||||||
filename_fmt = "{num:>02}.{extension}"
|
filename_fmt = "{num:>02}.{extension}"
|
||||||
archive_fmt = "{programme}_{num}"
|
archive_fmt = "{programme}_{num}"
|
||||||
pattern = rf"{BASE_PATTERN}[^/?#]+(?!/galleries)(?:/[^/?#]+)?)$"
|
pattern = rf"{BASE_PATTERN}[^/?#]+(?!/galleries)(?:/[^/?#]+)?)$"
|
||||||
|
|||||||
@@ -282,12 +282,20 @@ class PathFormat():
|
|||||||
segments = []
|
segments = []
|
||||||
strip = self.strip
|
strip = self.strip
|
||||||
for fmt in formatters:
|
for fmt in formatters:
|
||||||
segment = fmt(kwdict).strip()
|
segment = fmt(kwdict)
|
||||||
if strip and segment not in {".", ".."}:
|
if segment.__class__ is str:
|
||||||
# remove trailing dots and spaces (#647)
|
segment = segment.strip()
|
||||||
segment = segment.rstrip(strip)
|
if strip and segment not in {".", ".."}:
|
||||||
if segment:
|
segment = segment.rstrip(strip)
|
||||||
segments.append(self.clean_segment(segment))
|
if segment:
|
||||||
|
segments.append(self.clean_segment(segment))
|
||||||
|
else: # assume list
|
||||||
|
for segment in segment:
|
||||||
|
segment = segment.strip()
|
||||||
|
if strip and segment not in {".", ".."}:
|
||||||
|
segment = segment.rstrip(strip)
|
||||||
|
if segment:
|
||||||
|
segments.append(self.clean_segment(segment))
|
||||||
return segments
|
return segments
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
raise exception.DirectoryFormatError(exc)
|
raise exception.DirectoryFormatError(exc)
|
||||||
|
|||||||
Reference in New Issue
Block a user