| 1 |
# -*- coding: utf-8 -*- |
| 2 |
|
| 3 |
# Copyright 2016-2017 Leonardo Taccari |
| 4 |
# Copyright 2017-2025 Mike Fährmann |
| 5 |
# |
| 6 |
# This program is free software; you can redistribute it and/or modify |
| 7 |
# it under the terms of the GNU General Public License version 2 as |
| 8 |
# published by the Free Software Foundation. |
| 9 |
|
| 10 |
"""Extractors for https://www.slideshare.net/""" |
| 11 |
|
| 12 |
from .common import GalleryExtractor |
| 13 |
|
| 14 |
|
| 15 |
class SlidesharePresentationExtractor(GalleryExtractor): |
| 16 |
"""Extractor for images from a presentation on slideshare.net""" |
| 17 |
category = "slideshare" |
| 18 |
subcategory = "presentation" |
| 19 |
directory_fmt = ("{category}", "{user}") |
| 20 |
filename_fmt = "{presentation}-{num:>02}.{extension}" |
| 21 |
archive_fmt = "{presentation}_{num}" |
| 22 |
pattern = (r"(?:https?://)?(?:www\.)?slideshare\.net" |
| 23 |
r"/(?:mobile/)?([^/?#]+)/([^/?#]+)") |
| 24 |
example = "https://www.slideshare.net/USER/PRESENTATION" |
| 25 |
|
| 26 |
def __init__(self, match): |
| 27 |
self.user, self.presentation = match.groups() |
| 28 |
url = f"https://www.slideshare.net/{self.user}/{self.presentation}" |
| 29 |
GalleryExtractor.__init__(self, match, url) |
| 30 |
|
| 31 |
def metadata(self, page): |
| 32 |
data = self._extract_nextdata(page) |
| 33 |
self.slideshow = slideshow = data["props"]["pageProps"]["slideshow"] |
| 34 |
|
| 35 |
return { |
| 36 |
"user" : slideshow["username"], |
| 37 |
"presentation": self.presentation, |
| 38 |
"title" : slideshow["title"].strip(), |
| 39 |
"description" : slideshow["description"].strip(), |
| 40 |
"views" : slideshow["views"], |
| 41 |
"likes" : slideshow["likes"], |
| 42 |
"date" : self.parse_datetime_iso( |
| 43 |
slideshow["createdAt"][:19]), |
| 44 |
} |
| 45 |
|
| 46 |
def images(self, page): |
| 47 |
slides = self.slideshow["slides"] |
| 48 |
begin = (f"{slides['host']}/{slides['imageLocation']}" |
| 49 |
f"/95/{slides['title']}-") |
| 50 |
end = "-1024.jpg" |
| 51 |
|
| 52 |
return [ |
| 53 |
(begin + str(n) + end, None) |
| 54 |
for n in range(1, self.slideshow["totalSlides"]+1) |
| 55 |
] |