update - add support for some scrobble types
continuous-integration/drone/push Build is passing Details

This commit is contained in:
James Ravenscroft 2022-02-19 17:09:11 +00:00
parent 899f9485bf
commit c6166a9212
2 changed files with 35 additions and 8 deletions

View File

@ -1,3 +1,18 @@
# pymicrocosm
A tiny python-based micropub endpoint that supports a Gitea + drone static website
## Developing
Using a recent version of python 3.7+ install [poetry](https://python-poetry.org/):
```shell
pip install poetry
```
Then you can install microcosm and its required libraries with:
```shell
poetry install
```

View File

@ -31,10 +31,8 @@ app.config['SECRET_KEY'] = 'my super secret key'
ENTITY_TYPE_PLURAL_MAP = {
"post": "posts",
"note": "notes",
"reply": "replies",
"bookmark": "bookmarks"
"watch":"watches"
}
@ -296,6 +294,12 @@ def detect_entry_type(doc: dict) -> str:
elif ('like-of' in doc) or ('u-like-of' in doc):
entry_type = "like"
elif ('read-of' in doc):
entry_type = "read"
elif ('watch-of' in doc):
entry_type = "watch"
elif ('name' in doc) or ('p-name' in doc):
entry_type = "post"
else:
@ -306,14 +310,23 @@ def detect_entry_type(doc: dict) -> str:
def capture_frontmatter_props(doc: Dict[str, Union[str, List[str]]], frontmatter: Dict[str, Union[str,List[str]]]):
keys = ['bookmark-of', 'in-reply-to', 'repost-of', 'like-of']
keys = ['summary', 'bookmark-of', 'in-reply-to', 'repost-of', 'like-of', 'read-of', 'watch-of', 'read-status', 'rating']
keys += [f'u-{key}' for key in keys]
for key in keys:
if key in doc:
if isinstance(doc[key], list) and (len(doc[key]) < 2):
if isinstance(doc[key], dict) and ('type' in doc[key]):
if doc[key]['type'][0] == 'h-cite':
if 'citations' not in frontmatter:
frontmatter['citations'] = []
frontmatter['citations'].append(doc[key]['properties'])
elif isinstance(doc[key], list) and (len(doc[key]) < 2):
frontmatter[key] = doc[key][0]
else:
frontmatter[key] = doc[key]
@ -415,7 +428,6 @@ def process_json_post():
if 'name' in props:
frontmatter['title'] = props['name'][0]
docstr = ""
if 'photo' in props:
@ -556,4 +568,4 @@ def index():
if __name__ == '__main__':
app.run(debug=True)
app.run(debug=False)