cohost


Namecohost JSON
Version 0.4.1 PyPI version JSON
download
home_page
SummaryUnofficial Python API wrapper for Cohost.org - the fourth website!
upload_time2024-03-18 12:33:56
maintainer
docs_urlNone
author
requires_python>=3.9
licenseMIT License Copyright (c) 2022 Vallerie Knight Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords cohost.org cohost api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Cohost.py

![Edit of Eggbug into the python logo](pybug_small.png)

A python library for Cohost!

## Hyperstart

> `pip install cohost`

## Quickstart

> `pip install cohost`

```python3
from cohost.models.user import User
from cohost.models.block import AttachmentBlock, MarkdownBlock

cookie = 'yourCookie'
user = User.loginWithCookie(cookie)
# Alternatively: use a username/password combo
# import os
# user = User.login(os.getenv("COHOST_USER"), os.getenv("COHOST_PASS"))

for project in user.editedProjects:
    print(project) # Print all pages you have edit permissions for
project = user.getProject('vallerie') # will retrieve the page I have edit writes for with handle @vallerie

blocks = [
    AttachmentBlock('pybug.png'), # References image file pybug.png
    MarkdownBlock('**Hello from Python!**') # Example of markdown / text block
]
newPost = project.post('Title of python post!', blocks, tags=['cohost.py', 'python'])
print('Check out your post at {}'.format(newPost.url))
```

## Getting started

1. Have an activated Cohost.org account. This entire library will probably explode if you use it with an unactivated account, and it defo isn't some bypass.
2. Install library with `pip install cohost`
3. Log in with a cookie or a username/password
4. Import data models you require, and go from there!

## Terminology

Some things are different on the API, and on the UI, and for the most part this library will match the API's terminology. Some key concepts:

- A user is minimal - it will contain authentication, email, and some other key details but not much else
- All the pages you can edit are referred to as "projects"
- Each post is made up content "Blocks"

## Retrieving your cookie

One way to login is to use an authentication token for Cohost. This can be retrieved by:

1. Open Developer Tools in your browser
1. Go to "Storage"
1. Find the "Cookies" entry
1. Copy the data for "`connect.sid`".
1. Use this in the library

## What's working? (allegedly)

- Logging in as a user (using either a cookie or a username/password)
- Retrieving projects of a user (and of other people when you got a post to go with it)
- Retrieving posts of a page
- Posting to a page
- Attaching images to a post (with alt-text support!)
- Editing posts
- Retrieving notifications with pagination

## What's not done but needs to be done?

- Retrieving single posts - currently have to read entire projects
- Retrieving a project's drafts
- Retrieving a projects of others without a post inbetween
- Sharing posts (with comment)
- Editing profiles
- Deleting posts
- Likely a whole bunch of other things I haven't thought about
- Better docs

## What's not implemented intentionally?

Some features I intend not to add. These features aren't impossible to build, but, they could be detrimental to the Cohost experience for other users, send mass notifications without an account being activated, or pose security issues. This is designed to deter low effort malicious bots, to reduce the workload on Cohost's staff.

These include:

- Editing a user's password
- Accepting follow requests
- Sharing a post without a comment
- Creating new projects

If you implement these features, please keep them **private** for your projects.
If you think one of these should be implemented, please file a GitHub issue with your case as to why.

## Support Cohost

[Buy Cohost PLUS](https://cohost.org/rc/user/settings)

## Follow me on Cohost!

[hello is me](https://cohost.org/vallerie)

## Thanks

- [cohost.js](https://github.com/mogery/cohost.js/) - provided a good point to start looking at how to go about this, and how cohost works in fundamental aspects. also has a working login thing which i need to properly understand at some point
- [cohost.org](https://cohost.org) - home of eggbug
- [requests](https://requests.readthedocs.io/en/latest/) - i would be lost in python if it weren't for requests, my beloved
- the random tumblr anon who sent me an activation link - thanks

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "cohost",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Val Knight <val@valknight.xyz>",
    "keywords": "cohost.org,cohost,api",
    "author": "",
    "author_email": "Val Knight <val@valknight.xyz>",
    "download_url": "https://files.pythonhosted.org/packages/66/17/e297a4c3f25fd212dc190b0db0fe1568fe6fbac2a8f660b36365bebaf398/cohost-0.4.1.tar.gz",
    "platform": null,
    "description": "# Cohost.py\n\n![Edit of Eggbug into the python logo](pybug_small.png)\n\nA python library for Cohost!\n\n## Hyperstart\n\n> `pip install cohost`\n\n## Quickstart\n\n> `pip install cohost`\n\n```python3\nfrom cohost.models.user import User\nfrom cohost.models.block import AttachmentBlock, MarkdownBlock\n\ncookie = 'yourCookie'\nuser = User.loginWithCookie(cookie)\n# Alternatively: use a username/password combo\n# import os\n# user = User.login(os.getenv(\"COHOST_USER\"), os.getenv(\"COHOST_PASS\"))\n\nfor project in user.editedProjects:\n    print(project) # Print all pages you have edit permissions for\nproject = user.getProject('vallerie') # will retrieve the page I have edit writes for with handle @vallerie\n\nblocks = [\n    AttachmentBlock('pybug.png'), # References image file pybug.png\n    MarkdownBlock('**Hello from Python!**') # Example of markdown / text block\n]\nnewPost = project.post('Title of python post!', blocks, tags=['cohost.py', 'python'])\nprint('Check out your post at {}'.format(newPost.url))\n```\n\n## Getting started\n\n1. Have an activated Cohost.org account. This entire library will probably explode if you use it with an unactivated account, and it defo isn't some bypass.\n2. Install library with `pip install cohost`\n3. Log in with a cookie or a username/password\n4. Import data models you require, and go from there!\n\n## Terminology\n\nSome things are different on the API, and on the UI, and for the most part this library will match the API's terminology. Some key concepts:\n\n- A user is minimal - it will contain authentication, email, and some other key details but not much else\n- All the pages you can edit are referred to as \"projects\"\n- Each post is made up content \"Blocks\"\n\n## Retrieving your cookie\n\nOne way to login is to use an authentication token for Cohost. This can be retrieved by:\n\n1. Open Developer Tools in your browser\n1. Go to \"Storage\"\n1. Find the \"Cookies\" entry\n1. Copy the data for \"`connect.sid`\".\n1. Use this in the library\n\n## What's working? (allegedly)\n\n- Logging in as a user (using either a cookie or a username/password)\n- Retrieving projects of a user (and of other people when you got a post to go with it)\n- Retrieving posts of a page\n- Posting to a page\n- Attaching images to a post (with alt-text support!)\n- Editing posts\n- Retrieving notifications with pagination\n\n## What's not done but needs to be done?\n\n- Retrieving single posts - currently have to read entire projects\n- Retrieving a project's drafts\n- Retrieving a projects of others without a post inbetween\n- Sharing posts (with comment)\n- Editing profiles\n- Deleting posts\n- Likely a whole bunch of other things I haven't thought about\n- Better docs\n\n## What's not implemented intentionally?\n\nSome features I intend not to add. These features aren't impossible to build, but, they could be detrimental to the Cohost experience for other users, send mass notifications without an account being activated, or pose security issues. This is designed to deter low effort malicious bots, to reduce the workload on Cohost's staff.\n\nThese include:\n\n- Editing a user's password\n- Accepting follow requests\n- Sharing a post without a comment\n- Creating new projects\n\nIf you implement these features, please keep them **private** for your projects.\nIf you think one of these should be implemented, please file a GitHub issue with your case as to why.\n\n## Support Cohost\n\n[Buy Cohost PLUS](https://cohost.org/rc/user/settings)\n\n## Follow me on Cohost!\n\n[hello is me](https://cohost.org/vallerie)\n\n## Thanks\n\n- [cohost.js](https://github.com/mogery/cohost.js/) - provided a good point to start looking at how to go about this, and how cohost works in fundamental aspects. also has a working login thing which i need to properly understand at some point\n- [cohost.org](https://cohost.org) - home of eggbug\n- [requests](https://requests.readthedocs.io/en/latest/) - i would be lost in python if it weren't for requests, my beloved\n- the random tumblr anon who sent me an activation link - thanks\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2022 Vallerie Knight  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Unofficial Python API wrapper for Cohost.org - the fourth website!",
    "version": "0.4.1",
    "project_urls": {
        "repository": "https://github.com/valknight/cohost.py"
    },
    "split_keywords": [
        "cohost.org",
        "cohost",
        "api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "05334f64a8a236c143d56689132629fda2f0752ce023a1eb088d3ff433ceb73e",
                "md5": "88a0e59dc61a019cff7056615a407bea",
                "sha256": "95baea85d9cc0462c369d9deff346204ffef843bd424f6a7193ec5c199c49572"
            },
            "downloads": -1,
            "filename": "cohost-0.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "88a0e59dc61a019cff7056615a407bea",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 16988,
            "upload_time": "2024-03-18T12:33:54",
            "upload_time_iso_8601": "2024-03-18T12:33:54.346389Z",
            "url": "https://files.pythonhosted.org/packages/05/33/4f64a8a236c143d56689132629fda2f0752ce023a1eb088d3ff433ceb73e/cohost-0.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6617e297a4c3f25fd212dc190b0db0fe1568fe6fbac2a8f660b36365bebaf398",
                "md5": "ca1092bd53f8a9c43e3b851b2b8a7aa0",
                "sha256": "3d0911c83bdf313a43517e382966072a7c6c2aad8797faf1658d1edcc8456f91"
            },
            "downloads": -1,
            "filename": "cohost-0.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "ca1092bd53f8a9c43e3b851b2b8a7aa0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 16437,
            "upload_time": "2024-03-18T12:33:56",
            "upload_time_iso_8601": "2024-03-18T12:33:56.031911Z",
            "url": "https://files.pythonhosted.org/packages/66/17/e297a4c3f25fd212dc190b0db0fe1568fe6fbac2a8f660b36365bebaf398/cohost-0.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-18 12:33:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "valknight",
    "github_project": "cohost.py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cohost"
}
        
Elapsed time: 0.19801s