both /article/get/ endpoints now return json

This commit is contained in:
n0one
2025-09-17 16:09:29 +03:00
parent 7949312f9a
commit 73da634029

View File

@ -70,14 +70,14 @@ async def remove_rating(entry: Entry, response: Response):
async def get_article_html(article: Article, response: Response = None): async def get_article_html(article: Article, response: Response = None):
html_string = await scraper.get_article_html(article.url) html_string = await scraper.get_article_html(article.url)
b64_string = base64.b64encode(html_string.encode('utf-8')).decode('utf-8') b64_string = base64.b64encode(html_string.encode('utf-8')).decode('utf-8')
return Response(content=article.url + '\r\n' + b64_string, media_type='text/plain') return {article.url: b64_string}
@router.post('/article/get/md') @router.post('/article/get/md')
async def get_article_md(article: Article, response: Response = None): async def get_article_md(article: Article, response: Response = None):
md_string = await scraper.get_article_html(article.url, md=True) md_string = await scraper.get_article_html(article.url, md=True)
b64_string = base64.b64encode(md_string.encode('utf-8')).decode('utf-8') b64_string = base64.b64encode(md_string.encode('utf-8')).decode('utf-8')
return Response(content=article.url + '\r\n' + b64_string, media_type='text/plain') return {article.url: b64_string}
@router.post('/articles/get/html') @router.post('/articles/get/html')