Add Bibliogram support.

This commit is contained in:
lost 2021-11-09 00:00:00 +00:00
parent 99e840031d
commit a0f2449c25
Signed by: 0x80
GPG Key ID: 00B9C3A6C02F71F6
3 changed files with 57 additions and 0 deletions

View File

@ -1,6 +1,12 @@
#!/usr/bin/python3
supported_software = {
"bibliogram" : [
'<meta name="generator" content="Bibliogram">',
'<link rel="manifest" href="/bibliogram.webmanifest">',
'<meta property="og:site_name" content="Bibliogram">',
'<section class="bibliogram-meta">'
],
"peertube" : [
'<meta property="og:platform" content="PeerTube"'
]

View File

@ -0,0 +1,47 @@
#!/usr/bin/python3
from utils import *
from download_page import download
# portable code to get filename
import os
platform = os.path.basename(__file__)
if platform.endswith(".py"):
platform = platform[:(-3)]
def extract_from_url (url, verbosity):
# split into domain and path
index = url.find("/",url.find("//")+2)
path = url[index:]
if not url.endswith('/'):
url = url + '/'
if path.startswith("/u/"):
return url + "rss.xml"
def extract_from_page (page, verbosity, url, args):
# split into domain and path
index = url.find("/",url.find("//")+2)
domain = url[:index]
path = url[index:]
username = search (page, '<a class="name" href="', '">')
if not username is None:
return extract_from_url (domain + username, verbosity)
def extract (url, page=None, network=False, verbosity=3, args={}):
feed = extract_from_url (url, verbosity)
if not feed is None:
return feed
if not network:
return None
# this should not happen because we have no hardcoded Bibliogram domains
if page is None:
page = download (platform, url, args, verbosity)
feed = extract_from_page (page, verbosity, url, args)
if not feed is None:
return feed

4
tests/bibliogram.txt Normal file
View File

@ -0,0 +1,4 @@
https://bibliogram.snopyta.org/u/carachangrenofficial https://bibliogram.snopyta.org/u/carachangrenofficial/rss.xml
https://bibliogram.snopyta.org/u/carachangrenofficial/ https://bibliogram.snopyta.org/u/carachangrenofficial/rss.xml
https://bibliogram.snopyta.org/p/CVyC07sJVfS https://bibliogram.snopyta.org/u/carachangrenofficial/rss.xml
https://bibliogram.snopyta.org/p/CVyC07sJVfS/ https://bibliogram.snopyta.org/u/carachangrenofficial/rss.xml