ivanprogramming / telegraph_api Goto Github PK
View Code? Open in Web Editor NEWAsynchronus wrapper for Telegra.ph REST API
Home Page: https://telegraph-api.readthedocs.io/en/latest
License: MIT License
Asynchronus wrapper for Telegra.ph REST API
Home Page: https://telegraph-api.readthedocs.io/en/latest
License: MIT License
Hi, man!
Have a problem with create_page
method. I'm trying to create a page with huge text content. And it seems that your library is passing it as query string parameter. So I get 414 Request-URI Too Large
.
Telegra.ph supports passing parameters inside the request's body form.
Can you fix this, please?
I am using this lib for create post with images. but i install this lib(latest version),it got exceptions.
you can see code below:
# Importing required package
from telegraph_api import Telegraph
import asyncio
import os
# Declaring asynchronous function for using await
async def main():
# Creating new Telegraph object
telegraph = Telegraph()
# Creating new account
account = await telegraph.create_account("V2PH public projects", author_name="UnknowMe")
print(account)
abspath = os.path.abspath("./土肥圆矮挫丑黑穷《风华绝代的身材若隐若现》 [尤蜜荟YouMi] Vol.165 写真集")
listdir = os.listdir(abspath)
filtered_files = [abspath + os.sep + i for i in listdir if i != ".DS_Store" and i.endswith(".jpg")]
for image in filtered_files:
image_node = await telegraph.upload_file(image)
print(image_node)
print(listdir)
# Creating new page
# new_page = await telegraph.create_page(
# "My first Telegraph Post",
# content_html="<p>Hello world!</p>" # Html content can be presented
# )
# # Printing page url into console
# print(new_page.url)
if __name__ == '__main__':
# Running asynchronous function
asyncio.run(main())
and i run this code, here is the result:
As you can see, I can create an telegraph account, but when the code runs on upload file, it cant process.
And I have check the source code in this lib, I found it upload image with get method, and the respose return an text/html. this lib
use json to parse and error raised. So I think we could use post method for upload media, and I also check the telegraph upload url is : https://telegra.ph/upload. When you request that in an browser, it's a post method to the server.
You can use this url to have test: https://likev.github.io/test/upload-image.html
I have fix this problem, and I will make a pr for this lib. Would you make a merge if this is ok?
Hello, man, again! :)
According to the API doc, get_page_list
returns PageList object.
Telegraph_api/telegraph_api/api.py
Lines 165 to 166 in 30a302d
List[Page]
is used as the return type of get_page_list
.
For now, I'm getting the following exception, when trying to call get_page_list
:
File "/Users/IvanProgramming/anaconda3/envs/nudes/lib/python3.10/site-packages/IPython/core/interactiveshell.py", line 3369, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-9-f596fc14c206>", line 1, in <cell line: 1>
created_pages = loop.run_until_complete(tr.tlgh.get_page_list())
File "/Users/IvanProgramming/anaconda3/envs/nudes/lib/python3.10/asyncio/base_events.py", line 641, in run_until_complete
return future.result()
File "/Users/IvanProgramming/anaconda3/envs/nudes/lib/python3.10/site-packages/telegraph_api/api.py", line 166, in get_page_list
pages: List[Page] = await self.make_request(APIEndpoints.GET_PAGE_LIST, params=normalize_locals(locals()),
File "/Users/IvanProgramming/anaconda3/envs/nudes/lib/python3.10/site-packages/telegraph_api/api.py", line 262, in make_request
return parse_obj_as(model, data)
File "/Users/IvanProgramming/anaconda3/envs/nudes/lib/python3.10/site-packages/pydantic/tools.py", line 35, in parse_obj_as
return model_type(__root__=obj).__root__
File "/Users/IvanProgramming/anaconda3/envs/nudes/lib/python3.10/site-packages/pydantic/main.py", line 406, in __init__
raise validation_error
pydantic.error_wrappers.ValidationError: 1 validation error for ParsingModel[List]
__root__
value is not a valid list (type=type_error.list)
It looks like get_page_list
is broken. It would be better if you added a PageList
class with compatibility with the Telegraph documentation. Changing List[Page]
to PageList
is a breaking change, but it will fix this method. Because for now, it's:
List[Page]
doesn't have total count
property as mentioned in docs;GET
returns success.A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.