[slideshare] fix extraction

pull/4312/head
Mike Fährmann 1 year ago
parent ffbbbd3baf
commit c84397023a
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -30,21 +30,20 @@ class SlidesharePresentationExtractor(GalleryExtractor):
"count": 19, "count": 19,
"content": "2b6a191eab60b3978fdacfecf2da302dd45bc108", "content": "2b6a191eab60b3978fdacfecf2da302dd45bc108",
"keyword": { "keyword": {
"comments": "0",
"description": "Get Started with SlideShare - " "description": "Get Started with SlideShare - "
"A Beginngers Guide for Creators", "A Beginngers Guide for Creators",
"likes": r"re:\d{3,}", "likes": int,
"presentation": "get-started-with-slide-share", "presentation": "get-started-with-slide-share",
"published": "dt:2015-05-20 00:00:00", "date": "dt:2015-05-20 17:38:21",
"title": "Getting Started With SlideShare", "title": "Getting Started With SlideShare",
"user": "Slideshare", "user": "Slideshare",
"views": r"re:\d{7,}", "views": int,
}, },
}), }),
# long title and description # long title and description
(("https://www.slideshare.net/pragmaticsolutions/warum-sie-nicht-ihren" (("https://www.slideshare.net/pragmaticsolutions/warum-sie-nicht-ihren"
"-mitarbeitenden-ndern-sollten-sondern-ihr-managementsystem"), { "-mitarbeitenden-ndern-sollten-sondern-ihr-managementsystem"), {
"url": "cf70ca99f57f61affab47ebf8583eb564b21e3a7", "url": "d8952260f8bec337dd809a958ec8091350393f6b",
"keyword": { "keyword": {
"title": "Warum Sie nicht Ihren Mitarbeitenden ändern " "title": "Warum Sie nicht Ihren Mitarbeitenden ändern "
"sollten, sondern Ihr Managementsystem", "sollten, sondern Ihr Managementsystem",
@ -58,7 +57,7 @@ class SlidesharePresentationExtractor(GalleryExtractor):
# mobile URL # mobile URL
(("https://www.slideshare.net" (("https://www.slideshare.net"
"/mobile/uqudent/introduction-to-fixed-prosthodontics"), { "/mobile/uqudent/introduction-to-fixed-prosthodontics"), {
"url": "43eda2adf4dd221a251c8df794dfb82649e94647", "url": "72c431cb1eccbb6794f608ecbbc01d52e8768159",
}), }),
) )
@ -69,43 +68,31 @@ class SlidesharePresentationExtractor(GalleryExtractor):
GalleryExtractor.__init__(self, match, url) GalleryExtractor.__init__(self, match, url)
def metadata(self, page): def metadata(self, page):
extr = text.extract_from(page) data = util.json_loads(text.extr(
descr = extr('<meta name="description" content="', '"') page, 'id="__NEXT_DATA__" type="application/json">', '</script>'))
comments = extr('content="UserComments:', '"') self.slideshow = slideshow = data["props"]["pageProps"]["slideshow"]
likes = extr('content="UserLikes:', '"')
views = extr('content="UserPageVisits:', '"')
title = extr('<span class="j-title-breadcrumb">', '</span>')
published = extr('<div class="metadata-item">', '</div>')
if descr.endswith(""):
alt_descr = extr('slideshow-description-text"', '</p>')
if alt_descr:
descr = text.remove_html(alt_descr.partition(">")[2]).strip()
return { return {
"user": self.user, "user" : slideshow["username"],
"presentation": self.presentation, "presentation": self.presentation,
"title": text.unescape(title.strip()), "title" : slideshow["title"].strip(),
"description": text.unescape(descr), "description" : slideshow["description"].strip(),
"views": views, "views" : slideshow["views"],
"likes": likes, "likes" : slideshow["likes"],
"comments": comments, "date" : text.parse_datetime(
"published": text.parse_datetime( slideshow["createdAt"], "%Y-%m-%d %H:%M:%S %Z"),
published.strip(), "%b. %d, %Y"),
} }
@staticmethod def images(self, page):
def images(page): parts = self.slideshow["slideImages"][0]["baseUrl"].split("/")
data = util.json_loads(text.extract(
page, "xtend(true, slideshare_object.slideshow_config, ", ");")[0])
# useing 'stripped_title' here is technically wrong, but it works all begin = "{}/95/{}-".format(
# the same, slideshare doesn't seem to care what characters go there "/".join(parts[:4]),
begin = "https://image.slidesharecdn.com/{}/95/{}-".format( self.slideshow["strippedTitle"],
data["ppt_location"], data["stripped_title"]) )
end = "-1024.jpg?cb=" + str(data["timestamp"]) end = "-1024.jpg?" + parts[-1].rpartition("?")[2]
return [ return [
(begin + str(n) + end, None) (begin + str(n) + end, None)
for n in range(1, data["slide_count"]+1) for n in range(1, self.slideshow["totalSlides"]+1)
] ]

Loading…
Cancel
Save