[directlink] update filename format and metadata

This commit is contained in:
Mike Fährmann
2017-05-30 17:33:09 +02:00
parent c184e47ee3
commit b6fffa9e26
4 changed files with 9 additions and 7 deletions

View File

@@ -15,19 +15,22 @@ from .. import text
class DirectlinkExtractor(Extractor):
"""Extractor for direct links to images"""
category = "directlink"
pattern = [r"https?://[^?&#]+\.(?:jpe?g|png|gif|webm|mp4|ogg)"]
filename_fmt = "{domain}/{path}"
pattern = [r"https?://([^/]+)/([^?&#]+\.(?:jpe?g|png|gif|webm|mp4|ogg))"]
test = [(("https://photos.smugmug.com/The-World/Hawaii/"
"i-SWz2K6n/2/X3/IMG_0311-X3.jpg"), {
"url": "32ee1045881e17ef3f13a9958595afa42421ec6c",
"keyword": "5bd7871a6957e1693c43abf31d7c0a38e39a81de",
"keyword": "1abd2f2c115cdf2cf2671d2611349b4213c3ab3e",
})]
def __init__(self, match):
Extractor.__init__(self)
self.domain, self.path = match.groups()
self.url = match.string
def items(self):
data = text.nameext_from_url(self.url)
data = {"domain": self.domain, "path": self.path}
text.nameext_from_url(self.url, data)
yield Message.Version, 1
yield Message.Directory, data
yield Message.Url, self.url, data