# coding: utf-8 from __future__ import unicode_literals from .common import SelfhostedInfoExtractor from ..utils import ( clean_html, float_or_none, int_or_none, str_or_none, try_get, unescapeHTML, ExtractorError, ) from urllib.parse import ( parse_qs, urlencode, urlparse, ) import json import re from .peertube import PeerTubeSHIE class MastodonSHIE(SelfhostedInfoExtractor): """ This extractor is for services implementing the Mastodon API, not just Mastodon Supported services (possibly more already work or could): - Mastodon - https://github.com/tootsuite/mastodon - Glitch (a fork of Mastodon) - https://github.com/glitch-soc/mastodon - Pleroma - https://git.pleroma.social/pleroma/pleroma - Gab Social (a fork of Mastodon) - https://code.gab.com/gab/social/gab-social/ """ IE_NAME = 'mastodon' _VALID_URL = r'mastodon:(?P[^:]+):(?P.+)' _NETRC_MACHINE = 'mastodon' _SH_VALID_URL = r'''(?x) https?:// (?P[^/\s]+)/ (?: # mastodon @[a-zA-Z0-9_]+ # gab social |[a-zA-Z0-9_]+/posts # mastodon legacy (?) |users/[a-zA-Z0-9_]+/statuses # pleroma |notice # pleroma (OStatus standard?) - https://git.pleroma.social/pleroma/pleroma/-/blob/e9859b68fcb9c38b2ec27a45ffe0921e8d78b5e1/lib/pleroma/web/router.ex#L607 |objects |activities )/(?P[0-9a-zA-Z-]+) ''' _SH_VALID_CONTENT_STRINGS = ( ',"settings":{"known_fediverse":', # Mastodon initial-state '
  • Documentation
  • ', 'Pleroma', '', '', 'Alternatively, try one of the native apps for Gab Social for your platform.', ) _SH_VALID_CONTENT_REGEXES = ( # double quotes on Mastodon, single quotes on Gab Social r'