mirror of
https://github.com/ioistired/pleroma-ebooks.git
synced 2025-01-08 17:44:45 +01:00
use json5 instead lol
toml sucks add null when
This commit is contained in:
parent
79301382cd
commit
944e2fc3a5
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,6 +10,7 @@ __pycache__/
|
|||||||
.vscode/
|
.vscode/
|
||||||
.editorconfig
|
.editorconfig
|
||||||
.*.swp
|
.*.swp
|
||||||
|
# couldn't decide on a config format lol
|
||||||
config.json
|
config.json
|
||||||
config.toml
|
config.toml
|
||||||
venv/
|
venv/
|
||||||
|
@ -23,7 +23,7 @@ pleroma-ebooks uses ActivityPub to download posts. This means that it is not dep
|
|||||||
I recommend that you create your bot's account on a Mastodon instance. Creating a bot on a Pleroma instance means that your bot will be unable to reply, although posting will work just fine. However, even if your bot is on a Mastodon instance, it will be able to learn from any Pleroma or Misskey users just fine.
|
I recommend that you create your bot's account on a Mastodon instance. Creating a bot on a Pleroma instance means that your bot will be unable to reply, although posting will work just fine. However, even if your bot is on a Mastodon instance, it will be able to learn from any Pleroma or Misskey users just fine.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
Configuring pleroma-ebooks is accomplished by editing `config.toml`. If you want to use a different file for configuration, specify it with the `--cfg` argument. For example, if you want to use `/home/lynne/c.toml` instead, you would run `python3 fetch_posts.py --cfg /home/lynne/c.toml` instead of just `python3 fetch_posts.py`
|
Configuring pleroma-ebooks is accomplished by editing `config.json`. If you want to use a different file for configuration, specify it with the `--cfg` argument. For example, if you want to use `/home/lynne/c.json` instead, you would run `python3 fetch_posts.py --cfg /home/lynne/c.json` instead of just `python3 fetch_posts.py`
|
||||||
|
|
||||||
| Setting | Default | Meaning |
|
| Setting | Default | Meaning |
|
||||||
|--------------------------|-----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|--------------------------|-----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
|
@ -12,7 +12,6 @@ import aiohttp
|
|||||||
import argparse
|
import argparse
|
||||||
import functions
|
import functions
|
||||||
import contextlib
|
import contextlib
|
||||||
import pytomlpp as toml
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from pleroma import Pleroma, http_session_factory
|
from pleroma import Pleroma, http_session_factory
|
||||||
|
|
||||||
@ -69,7 +68,7 @@ async def main():
|
|||||||
try:
|
try:
|
||||||
following = await client.following()
|
following = await client.following()
|
||||||
except aiohttp.ClientResponseError as exc:
|
except aiohttp.ClientResponseError as exc:
|
||||||
if exc.code == HTTPStatus.FORBIDDEN:
|
if exc.status == HTTPStatus.FORBIDDEN:
|
||||||
print(f'The provided access token in {args.cfg} is invalid.', file=sys.stderr)
|
print(f'The provided access token in {args.cfg} is invalid.', file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@ -128,7 +127,7 @@ async def fetch_posts(cfg, http, cur, acc):
|
|||||||
done = True
|
done = True
|
||||||
break
|
break
|
||||||
except aiohttp.ClientResponseError as exc:
|
except aiohttp.ClientResponseError as exc:
|
||||||
if exc.code == HTTPStatus.TOO_MANY_REQUESTS:
|
if exc.status == HTTPStatus.TOO_MANY_REQUESTS:
|
||||||
print("We're rate limited. Skipping to next account.")
|
print("We're rate limited. Skipping to next account.")
|
||||||
done = True
|
done = True
|
||||||
break
|
break
|
||||||
|
@ -8,15 +8,15 @@ import shutil
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
import argparse
|
import argparse
|
||||||
import markovify
|
import markovify
|
||||||
|
import json5 as json
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import pytomlpp as toml
|
|
||||||
from random import randint
|
from random import randint
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
def arg_parser_factory(*, description):
|
def arg_parser_factory(*, description):
|
||||||
parser = argparse.ArgumentParser(description=description)
|
parser = argparse.ArgumentParser(description=description)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-c', '--cfg', dest='cfg', default='config.toml', nargs='?',
|
'-c', '--cfg', dest='cfg', default='config.json', nargs='?',
|
||||||
help='Specify a custom location for the config file.'
|
help='Specify a custom location for the config file.'
|
||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
@ -25,12 +25,11 @@ def parse_args(*, description):
|
|||||||
return arg_parser_factory(description=description).parse_args()
|
return arg_parser_factory(description=description).parse_args()
|
||||||
|
|
||||||
def load_config(cfg_path):
|
def load_config(cfg_path):
|
||||||
# TOML doesn't support null here so we have to use JSON 😒
|
|
||||||
with open('config.defaults.json') as f:
|
with open('config.defaults.json') as f:
|
||||||
cfg = json.load(f)
|
cfg = json.load(f)
|
||||||
|
|
||||||
with open(cfg_path) as f:
|
with open(cfg_path) as f:
|
||||||
cfg.update(toml.load(f))
|
cfg.update(json.load(f))
|
||||||
|
|
||||||
if not cfg['site'].startswith('https://') and not cfg['site'].startswith('http://'):
|
if not cfg['site'].startswith('https://') and not cfg['site'].startswith('http://'):
|
||||||
print("Site must begin with 'https://' or 'http://'. Value '{0}' is invalid - try 'https://{0}' instead.".format(cfg['site']), file=sys.stderr)
|
print("Site must begin with 'https://' or 'http://'. Value '{0}' is invalid - try 'https://{0}' instead.".format(cfg['site']), file=sys.stderr)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
markovify ~= 0.9.0
|
markovify ~= 0.9.0
|
||||||
beautifulsoup4 ~= 4.9
|
beautifulsoup4 ~= 4.9
|
||||||
aiohttp ~= 3.0
|
aiohttp ~= 3.0
|
||||||
pytomlpp ~= 1.0
|
json5 ~= 0.9.5
|
||||||
anyio ~= 3.0
|
anyio ~= 3.0
|
||||||
asqlite @ git+https://github.com/Rapptz/asqlite.git
|
asqlite @ git+https://github.com/Rapptz/asqlite.git
|
||||||
|
Loading…
Reference in New Issue
Block a user