[sexcom] extract 'date_url' metadata (#7239)
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
from .common import Extractor, Message
|
from .common import Extractor, Message
|
||||||
from .. import text
|
from .. import text
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
BASE_PATTERN = r"(?:https?://)?(?:www\.)?sex\.com"
|
BASE_PATTERN = r"(?:https?://)?(?:www\.)?sex\.com"
|
||||||
|
|
||||||
@@ -25,8 +26,20 @@ class SexcomExtractor(Extractor):
|
|||||||
def items(self):
|
def items(self):
|
||||||
yield Message.Directory, self.metadata()
|
yield Message.Directory, self.metadata()
|
||||||
for pin in map(self._parse_pin, self.pins()):
|
for pin in map(self._parse_pin, self.pins()):
|
||||||
if pin:
|
if not pin:
|
||||||
yield Message.Url, pin["url"], pin
|
continue
|
||||||
|
|
||||||
|
url = pin["url"]
|
||||||
|
parts = url.rsplit("/", 4)
|
||||||
|
try:
|
||||||
|
pin["date_url"] = dt = datetime(
|
||||||
|
int(parts[1]), int(parts[2]), int(parts[3]))
|
||||||
|
if "date" not in pin:
|
||||||
|
pin["date"] = dt
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
yield Message.Url, url, pin
|
||||||
|
|
||||||
def metadata(self):
|
def metadata(self):
|
||||||
return {}
|
return {}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ __tests__ = (
|
|||||||
|
|
||||||
"comments" : range(0, 5),
|
"comments" : range(0, 5),
|
||||||
"date" : "dt:2014-10-19 15:45:44",
|
"date" : "dt:2014-10-19 15:45:44",
|
||||||
|
"date_url" : "dt:2014-08-26 00:00:00",
|
||||||
"extension": "jpg",
|
"extension": "jpg",
|
||||||
"filename" : "7637609",
|
"filename" : "7637609",
|
||||||
"likes" : range(240, 275),
|
"likes" : range(240, 275),
|
||||||
@@ -44,6 +45,8 @@ __tests__ = (
|
|||||||
"#urls" : "https://imagex1.sx.cdn.live/images/pinporn/2017/12/07/18760842.gif",
|
"#urls" : "https://imagex1.sx.cdn.live/images/pinporn/2017/12/07/18760842.gif",
|
||||||
"#sha1_content": "176cc63fa05182cb0438c648230c0f324a5965fe",
|
"#sha1_content": "176cc63fa05182cb0438c648230c0f324a5965fe",
|
||||||
|
|
||||||
|
"date" : "dt:2017-12-07 00:00:00",
|
||||||
|
"date_url" : "dt:2017-12-07 00:00:00",
|
||||||
"extension": "gif",
|
"extension": "gif",
|
||||||
"filename" : "18760842",
|
"filename" : "18760842",
|
||||||
"pin_id" : 209061,
|
"pin_id" : 209061,
|
||||||
@@ -64,6 +67,8 @@ __tests__ = (
|
|||||||
"#urls" : "https://imagex1.sx.cdn.live/images/pinporn/2017/12/07/18760842.gif",
|
"#urls" : "https://imagex1.sx.cdn.live/images/pinporn/2017/12/07/18760842.gif",
|
||||||
"#sha1_content": "176cc63fa05182cb0438c648230c0f324a5965fe",
|
"#sha1_content": "176cc63fa05182cb0438c648230c0f324a5965fe",
|
||||||
|
|
||||||
|
"date" : "dt:2017-12-07 00:00:00",
|
||||||
|
"date_url" : "dt:2017-12-07 00:00:00",
|
||||||
"extension": "gif",
|
"extension": "gif",
|
||||||
"filename" : "18760842",
|
"filename" : "18760842",
|
||||||
"pin_id" : 209061,
|
"pin_id" : 209061,
|
||||||
@@ -85,7 +90,8 @@ __tests__ = (
|
|||||||
"#sha1_content": "e1a5834869163e2c4d1ca2677f5b7b367cf8cfff",
|
"#sha1_content": "e1a5834869163e2c4d1ca2677f5b7b367cf8cfff",
|
||||||
|
|
||||||
"comments" : range(0, 5),
|
"comments" : range(0, 5),
|
||||||
"date" : "2018-02-10 14:58:55",
|
"date" : "dt:2018-02-10 14:58:55",
|
||||||
|
"date_url" : "dt:2018-02-10 00:00:00",
|
||||||
"extension": "mp4",
|
"extension": "mp4",
|
||||||
"filename" : "776229_hd",
|
"filename" : "776229_hd",
|
||||||
"likes" : range(30, 50),
|
"likes" : range(30, 50),
|
||||||
|
|||||||
Reference in New Issue
Block a user