diff --git a/.github/workflows/ci_publish.yml b/.github/workflows/ci_publish.yml index 0e4e7b7..f04374c 100644 --- a/.github/workflows/ci_publish.yml +++ b/.github/workflows/ci_publish.yml @@ -1,4 +1,4 @@ -name: Upload Python Package +name: Publish on: push: branches: diff --git a/.gitignore b/.gitignore index 1d4e738..b97131e 100644 --- a/.gitignore +++ b/.gitignore @@ -128,4 +128,4 @@ dmypy.json # Pyre type checker .pyre/ -.idea/ \ No newline at end of file +.idea/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..93999f6 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,16 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.3.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/psf/black + rev: 22.10.0 + hooks: + - id: black + - repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort + name: isort (python) diff --git a/LICENSE b/LICENSE index 1c58a92..b4ae2f6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 hogier +Copyright (c) 2022 ma2za Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 24c01d0..9f6844b 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,11 @@ # Python Substack -# Introduction - This is an unofficial library providing a Python interface for [Substack](https://substack.com/). -I am in no way affiliated with Substack. It works with -Python versions from 3.7+. +I am in no way affiliated with Substack. + +[![Downloads](https://static.pepy.tech/badge/python-substack/month)](https://pepy.tech/project/python-substack) +![Release Build](https://github.com/ma2za/python-substack/actions/workflows/ci_publish.yml/badge.svg) +--- # Installation @@ -12,17 +13,247 @@ You can install python-substack using: $ pip install python-substack -# Usage +--- + +# Setup Set the following environment variables by creating a **.env** file: - PUBLICATION_URL=https://ma2za.substack.com EMAIL= PASSWORD= - USER_ID= + PUBLICATION_URL= # Optional: your publication URL + COOKIES_PATH= # Optional: path to cookies JSON file + COOKIES_STRING= # Optional: cookie string for authentication + +## If you don't have a password + +Recently Substack has been setting up new accounts without a password. If you sign out and sign back in, it just uses +your email address with a "magic" link. + +Set a password: + +- Sign out of Substack +- At the sign-in page, click "Sign in with password" under the `Email` text box +- Then choose, "Set a new password" + +The .env file will be ignored by git but always be careful. + +--- + +# Usage + +Check out the examples folder for some examples 😃 🚀 + +## Basic Authentication + +```python +import os +from dotenv import load_dotenv + +from substack import Api +from substack.post import Post + +load_dotenv() + +# Authenticate with email and password +api = Api( + email=os.getenv("EMAIL"), + password=os.getenv("PASSWORD"), + publication_url=os.getenv("PUBLICATION_URL"), +) +``` + +## Cookie-based Authentication + +You can also authenticate using cookies instead of email/password: + +```python +import os +from dotenv import load_dotenv + +from substack import Api + +load_dotenv() + +# Authenticate with cookies (alternative to email/password) +api = Api( + cookies_path=os.getenv("COOKIES_PATH"), # Path to cookies JSON file + # OR + cookies_string=os.getenv("COOKIES_STRING"), # Cookie string + publication_url=os.getenv("PUBLICATION_URL"), +) +``` + +## Creating and Publishing Posts + +```python +user_id = api.get_user_id() + +# Switch Publications - The library defaults to your user's primary publication. You can retrieve all your publications and change which one you want to use. + +# primary publication +user_publication = api.get_user_primary_publication() +# all publications +user_publications = api.get_user_publications() + +# This step is only necessary if you are not using your primary publication +# api.change_publication(user_publication) + +# Create a post with basic settings +post = Post( + title="How to publish a Substack post using the Python API", + subtitle="This post was published using the Python API", + user_id=user_id +) + +# Create a post with audience and comment permissions +post = Post( + title="My Post Title", + subtitle="My Post Subtitle", + user_id=user_id, + audience="everyone", # Options: "everyone", "only_paid", "founding", "only_free" + write_comment_permissions="everyone" # Options: "none", "only_paid", "everyone" +) + +post.add({'type': 'paragraph', 'content': 'This is how you add a new paragraph to your post!'}) + +# bolden text +post.add({'type': "paragraph", + 'content': [{'content': "This is how you "}, {'content': "bolden ", 'marks': [{'type': "strong"}]}, + {'content': "a word."}]}) + +# add hyperlink to text +post.add({'type': 'paragraph', 'content': [ + {'content': "View Link", 'marks': [{'type': "link", 'href': 'https://whoraised.substack.com/'}]}]}) + +# set paywall boundary +post.add({'type': 'paywall'}) + +# add image +post.add({'type': 'captionedImage', 'src': "https://media.tenor.com/7B4jMa-a7bsAAAAC/i-am-batman.gif"}) + +# add local image +image = api.get_image('image.png') +post.add({"type": "captionedImage", "src": image.get("url")}) + +# embed publication +embedded = api.publication_embed("https://jackio.substack.com/") +post.add({"type": "embeddedPublication", "url": embedded}) + +# create post from Markdown +markdown_content = """ +# My Heading + +This is a paragraph with **bold** and *italic* text. + +![Image Alt](https://example.com/image.jpg) +""" +post.from_markdown(markdown_content, api=api) + +draft = api.post_draft(post.get_draft()) + +# set section (can only be done after first posting the draft) +# post.set_section("rick rolling", api.get_sections()) +# api.put_draft(draft.get("id"), draft_section_id=post.draft_section_id) + +api.prepublish_draft(draft.get("id")) + +api.publish_draft(draft.get("id")) +``` + +## Loading Posts from YAML Files + +You can define your posts in YAML files for easier management: + +```python +import yaml +import os +from dotenv import load_dotenv + +from substack import Api +from substack.post import Post + +load_dotenv() + +# Load post data from YAML file +with open("draft.yaml", "r") as fp: + post_data = yaml.safe_load(fp) + +# Authenticate (using cookies or email/password) +cookies_path = os.getenv("COOKIES_PATH") +cookies_string = os.getenv("COOKIES_STRING") + +api = Api( + email=os.getenv("EMAIL") if not cookies_path and not cookies_string else None, + password=os.getenv("PASSWORD") if not cookies_path and not cookies_string else None, + cookies_path=cookies_path, + cookies_string=cookies_string, + publication_url=os.getenv("PUBLICATION_URL"), +) + +user_id = api.get_user_id() + +# Create post from YAML data +post = Post( + post_data.get("title"), + post_data.get("subtitle", ""), + user_id, + audience=post_data.get("audience", "everyone"), + write_comment_permissions=post_data.get("write_comment_permissions", "everyone"), +) + +# Add body content from YAML +body = post_data.get("body", {}) +for _, item in body.items(): + # Handle local images - upload them first + if item.get("type") == "captionedImage" and not item.get("src").startswith("http"): + image = api.get_image(item.get("src")) + item.update({"src": image.get("url")}) + post.add(item) + +draft = api.post_draft(post.get_draft()) +api.put_draft(draft.get("id"), draft_section_id=post.draft_section_id) + +# Publish the draft +api.prepublish_draft(draft.get("id")) +api.publish_draft(draft.get("id")) +``` + +Example YAML structure: + +```yaml +title: "My Post Title" +subtitle: "My Post Subtitle" +audience: "everyone" # everyone, only_paid, founding, only_free +write_comment_permissions: "everyone" # none, only_paid, everyone +section: "my-section" +body: + 0: + type: "heading" + level: 1 + content: "Introduction" + 1: + type: "paragraph" + content: "This is a paragraph." + 2: + type: "captionedImage" + src: "local_image.jpg" # Local images will be uploaded automatically +``` + +# Contributing + +Install pre-commit: + +```shell +pip install pre-commit +``` + +Set up pre-commit + +```shell +pre-commit install +``` -The only way I found to discover the USER_ID is to inspect -the payload to a **/drafts** request. Under the fields **draftBylines** -or **postBylines** there is a subfield **user_id** or **id** +## Cookie Help -The .env file will be ignored by git but always be careful. \ No newline at end of file +To get a cookie string, after login, go to dev tools (F12), network tab, refresh and find one of the requests like subscription/unred/subscriptions, right click and copy as fetch (Node.js), paste somewhere and get the entire cookie string assigned to the cookie header and put it in the env variables as COOKIES_STRING, et voila! diff --git a/examples/draft.yaml b/examples/draft.yaml index bb739a1..cb0c54b 100644 --- a/examples/draft.yaml +++ b/examples/draft.yaml @@ -2,6 +2,12 @@ title: "How to publish a Substack post using the Python API" subtitle: "This post was published using the Python API" +audience: + "everyone" # everyone, only_paid, founding, only_free +write_comment_permissions: + "none" # none, only_paid, everyone +section: + "rick" body: 0: type: "heading" @@ -10,9 +16,20 @@ body: 1: type: "paragraph" content: "1)" + marks: + - type: "strong" + - type: "em" 2: type: "paragraph" - content: "Discover your USER ID by inspecting the request body of any publish request." + content: + - content: "hello" + marks: + - type: "strong" + - type: "em" + - content: ", how are you?" + 10: + type: "paragraph" + content: "my friend" 3: type: "horizontal_rule" 4: @@ -26,4 +43,10 @@ body: content: "Set the EMAIL, PASSWORD, PUBLICATION_URL and USER_ID environment variables." 7: type: "captionedImage" - src: "rickroll_4k.jpg" \ No newline at end of file + src: "rickroll_4k.jpg" + 8: + type: "youtube2" + src: "EnDg65ISswg" + 9: + type: "subscribeWidget" + message: "Hello Everyone!!!" diff --git a/examples/get_subscriber_count.py b/examples/get_subscriber_count.py new file mode 100644 index 0000000..ee8a388 --- /dev/null +++ b/examples/get_subscriber_count.py @@ -0,0 +1,17 @@ +import os + +from dotenv import load_dotenv + +from substack import Api + +load_dotenv() + +if __name__ == "__main__": + api = Api( + email=os.getenv("EMAIL"), + password=os.getenv("PASSWORD"), + publication_url=os.getenv("PUBLICATION_URL"), + ) + + subscriberCount: int = api.get_publication_subscriber_count() + print(f"Subscriber count: {subscriberCount}") diff --git a/examples/publish_markdown.py b/examples/publish_markdown.py new file mode 100644 index 0000000..a0321ba --- /dev/null +++ b/examples/publish_markdown.py @@ -0,0 +1,111 @@ +""" +Example: Publishing a post from Markdown content + +This example demonstrates how to use the new Markdown support +to create Substack posts from Markdown files. + +This example reads from README.md to test the Markdown parsing. +""" + +import argparse +import os +from pathlib import Path +from dotenv import load_dotenv + +from substack import Api +from substack.post import Post + +load_dotenv() + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument( + "-m", + "--markdown", + default="README.md", + required=False, + help="Markdown file to publish (default: README.md).", + type=str, + ) + parser.add_argument( + "--publish", help="Publish the draft.", action="store_true", default=False + ) + parser.add_argument( + "--cookies", + help="Path to cookies JSON file for authentication (optional, can also be set via COOKIES_PATH or COOKIES_STRING env vars).", + type=str, + default=None, + ) + args = parser.parse_args() + + cookies_path = args.cookies or os.getenv("COOKIES_PATH") + cookies_string = os.getenv("COOKIES_STRING") + + # Initialize API + api = Api( + email=os.getenv("EMAIL") if not cookies_path and not cookies_string else None, + password=os.getenv("PASSWORD") if not cookies_path and not cookies_string else None, + cookies_path=cookies_path, + cookies_string=cookies_string, + publication_url=os.getenv("PUBLICATION_URL"), + ) + + user_id = api.get_user_id() + + # Determine the markdown file path + markdown_path = Path(args.markdown) + if not markdown_path.is_absolute(): + # If relative path, try relative to current directory first, then parent directory + if markdown_path.exists(): + pass # Use as-is + else: + # Try relative to parent directory (for README.md in project root) + markdown_path = Path(__file__).parent.parent / args.markdown + + if not markdown_path.exists(): + print(f"Error: Markdown file not found at {markdown_path}") + exit(1) + + with open(markdown_path, "r", encoding="utf-8") as f: + markdown_content = f.read() + + # Extract title from first heading (if it starts with #) + title = "Python Substack" + subtitle = "Markdown Test Post" + + lines = markdown_content.split("\n") + for line in lines: + if line.startswith("# "): + title = line[2:].strip() + break + elif line.startswith("#"): + # Skip badge lines and other non-title content + continue + + # Create a post + post = Post( + title=title, + subtitle=subtitle, + user_id=user_id, + ) + + # Parse and add Markdown content + print(f"Parsing Markdown from {markdown_path}...") + post.from_markdown(markdown_content, api=api) + + # Create draft + print("Creating draft...") + draft = api.post_draft(post.get_draft()) + + if args.publish: + print("Preparing to publish...") + api.prepublish_draft(draft.get("id")) + print("Publishing...") + api.publish_draft(draft.get("id")) + print("Post published successfully!") + else: + print(f"Draft created with ID: {draft.get('id')}") + print(f"Title: {title}") + print(f"Subtitle: {subtitle}") + print("Use --publish flag to publish the draft.") + diff --git a/examples/publish_post.py b/examples/publish_post.py index 07ac152..a614201 100644 --- a/examples/publish_post.py +++ b/examples/publish_post.py @@ -10,27 +10,54 @@ load_dotenv() if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("-p", "--post", default="draft.yaml", required=False, - help="YAML file containing the post to publish.", type=str) - parser.add_argument("--publish", help="Publish the draft.", action="store_true", default=False) + parser.add_argument( + "-p", + "--post", + default="draft.yaml", + required=False, + help="YAML file containing the post to publish.", + type=str, + ) + parser.add_argument( + "--publish", help="Publish the draft.", action="store_true", default=True + ) + parser.add_argument( + "--cookies", + help="Path to cookies JSON file for authentication (optional, can also be set via COOKIES_PATH or COOKIES_STRING env vars).", + type=str, + default=None, + ) args = parser.parse_args() with open(args.post, "r") as fp: post_data = yaml.safe_load(fp) - title = post_data.get("title", "") - subtitle = post_data.get("subtitle", "") - body = post_data.get("body", {}) + cookies_path = args.cookies or os.getenv("COOKIES_PATH") + cookies_string = os.getenv("COOKIES_STRING") api = Api( - email=os.getenv("EMAIL"), - password=os.getenv("PASSWORD"), + email=os.getenv("EMAIL") if not cookies_path and not cookies_string else None, + password=os.getenv("PASSWORD") if not cookies_path and not cookies_string else None, + cookies_path=cookies_path, + cookies_string=cookies_string, publication_url=os.getenv("PUBLICATION_URL"), ) - post = Post(title, subtitle, os.getenv("USER_ID")) + user_id = api.get_user_id() + + post = Post( + post_data.get("title"), + post_data.get("subtitle", ""), + user_id, + audience=post_data.get("audience", "everyone"), + write_comment_permissions=post_data.get( + "write_comment_permissions", "everyone" + ), + ) + + body = post_data.get("body", {}) + for _, item in body.items(): if item.get("type") == "captionedImage": image = api.get_image(item.get("src")) @@ -39,6 +66,9 @@ draft = api.post_draft(post.get_draft()) + # post.set_section(post_data.get("section"), api.get_sections()) + api.put_draft(draft.get("id"), draft_section_id=post.draft_section_id) + if args.publish: api.prepublish_draft(draft.get("id")) diff --git a/poetry.lock b/poetry.lock index ca06c6e..ce3ef34 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,121 +1,162 @@ -# This file is automatically @generated by Poetry and should not be changed by hand. +# This file is automatically @generated by Poetry 2.1.2 and should not be changed by hand. [[package]] name = "certifi" -version = "2023.5.7" +version = "2025.11.12" description = "Python package for providing Mozilla's CA Bundle." -category = "main" optional = false -python-versions = ">=3.6" +python-versions = ">=3.7" +groups = ["main"] files = [ - {file = "certifi-2023.5.7-py3-none-any.whl", hash = "sha256:c6c2e98f5c7869efca1f8916fed228dd91539f9f1b444c314c06eef02980c716"}, - {file = "certifi-2023.5.7.tar.gz", hash = "sha256:0f0d56dc5a6ad56fd4ba36484d6cc34451e1c6548c61daad8c320169f91eddc7"}, + {file = "certifi-2025.11.12-py3-none-any.whl", hash = "sha256:97de8790030bbd5c2d96b7ec782fc2f7820ef8dba6db909ccf95449f2d062d4b"}, + {file = "certifi-2025.11.12.tar.gz", hash = "sha256:d8ab5478f2ecd78af242878415affce761ca6bc54a22a27e026d7c25357c3316"}, ] [[package]] name = "charset-normalizer" -version = "3.1.0" +version = "3.4.4" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." -category = "main" optional = false -python-versions = ">=3.7.0" +python-versions = ">=3.7" +groups = ["main"] files = [ - {file = "charset-normalizer-3.1.0.tar.gz", hash = "sha256:34e0a2f9c370eb95597aae63bf85eb5e96826d81e3dcf88b8886012906f509b5"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:e0ac8959c929593fee38da1c2b64ee9778733cdf03c482c9ff1d508b6b593b2b"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d7fc3fca01da18fbabe4625d64bb612b533533ed10045a2ac3dd194bfa656b60"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:04eefcee095f58eaabe6dc3cc2262f3bcd776d2c67005880894f447b3f2cb9c1"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:20064ead0717cf9a73a6d1e779b23d149b53daf971169289ed2ed43a71e8d3b0"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1435ae15108b1cb6fffbcea2af3d468683b7afed0169ad718451f8db5d1aff6f"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c84132a54c750fda57729d1e2599bb598f5fa0344085dbde5003ba429a4798c0"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:75f2568b4189dda1c567339b48cba4ac7384accb9c2a7ed655cd86b04055c795"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:11d3bcb7be35e7b1bba2c23beedac81ee893ac9871d0ba79effc7fc01167db6c"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:891cf9b48776b5c61c700b55a598621fdb7b1e301a550365571e9624f270c203"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:5f008525e02908b20e04707a4f704cd286d94718f48bb33edddc7d7b584dddc1"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:b06f0d3bf045158d2fb8837c5785fe9ff9b8c93358be64461a1089f5da983137"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:49919f8400b5e49e961f320c735388ee686a62327e773fa5b3ce6721f7e785ce"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:22908891a380d50738e1f978667536f6c6b526a2064156203d418f4856d6e86a"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-win32.whl", hash = "sha256:12d1a39aa6b8c6f6248bb54550efcc1c38ce0d8096a146638fd4738e42284448"}, - {file = "charset_normalizer-3.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:65ed923f84a6844de5fd29726b888e58c62820e0769b76565480e1fdc3d062f8"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:9a3267620866c9d17b959a84dd0bd2d45719b817245e49371ead79ed4f710d19"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6734e606355834f13445b6adc38b53c0fd45f1a56a9ba06c2058f86893ae8017"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f8303414c7b03f794347ad062c0516cee0e15f7a612abd0ce1e25caf6ceb47df"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:aaf53a6cebad0eae578f062c7d462155eada9c172bd8c4d250b8c1d8eb7f916a"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3dc5b6a8ecfdc5748a7e429782598e4f17ef378e3e272eeb1340ea57c9109f41"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e1b25e3ad6c909f398df8921780d6a3d120d8c09466720226fc621605b6f92b1"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0ca564606d2caafb0abe6d1b5311c2649e8071eb241b2d64e75a0d0065107e62"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b82fab78e0b1329e183a65260581de4375f619167478dddab510c6c6fb04d9b6"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:bd7163182133c0c7701b25e604cf1611c0d87712e56e88e7ee5d72deab3e76b5"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:11d117e6c63e8f495412d37e7dc2e2fff09c34b2d09dbe2bee3c6229577818be"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:cf6511efa4801b9b38dc5546d7547d5b5c6ef4b081c60b23e4d941d0eba9cbeb"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:abc1185d79f47c0a7aaf7e2412a0eb2c03b724581139193d2d82b3ad8cbb00ac"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:cb7b2ab0188829593b9de646545175547a70d9a6e2b63bf2cd87a0a391599324"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-win32.whl", hash = "sha256:c36bcbc0d5174a80d6cccf43a0ecaca44e81d25be4b7f90f0ed7bcfbb5a00909"}, - {file = "charset_normalizer-3.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:cca4def576f47a09a943666b8f829606bcb17e2bc2d5911a46c8f8da45f56755"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0c95f12b74681e9ae127728f7e5409cbbef9cd914d5896ef238cc779b8152373"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fca62a8301b605b954ad2e9c3666f9d97f63872aa4efcae5492baca2056b74ab"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ac0aa6cd53ab9a31d397f8303f92c42f534693528fafbdb997c82bae6e477ad9"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c3af8e0f07399d3176b179f2e2634c3ce9c1301379a6b8c9c9aeecd481da494f"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a5fc78f9e3f501a1614a98f7c54d3969f3ad9bba8ba3d9b438c3bc5d047dd28"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:628c985afb2c7d27a4800bfb609e03985aaecb42f955049957814e0491d4006d"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:74db0052d985cf37fa111828d0dd230776ac99c740e1a758ad99094be4f1803d"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:1e8fcdd8f672a1c4fc8d0bd3a2b576b152d2a349782d1eb0f6b8e52e9954731d"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:04afa6387e2b282cf78ff3dbce20f0cc071c12dc8f685bd40960cc68644cfea6"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:dd5653e67b149503c68c4018bf07e42eeed6b4e956b24c00ccdf93ac79cdff84"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:d2686f91611f9e17f4548dbf050e75b079bbc2a82be565832bc8ea9047b61c8c"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-win32.whl", hash = "sha256:4155b51ae05ed47199dc5b2a4e62abccb274cee6b01da5b895099b61b1982974"}, - {file = "charset_normalizer-3.1.0-cp37-cp37m-win_amd64.whl", hash = "sha256:322102cdf1ab682ecc7d9b1c5eed4ec59657a65e1c146a0da342b78f4112db23"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:e633940f28c1e913615fd624fcdd72fdba807bf53ea6925d6a588e84e1151531"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:3a06f32c9634a8705f4ca9946d667609f52cf130d5548881401f1eb2c39b1e2c"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7381c66e0561c5757ffe616af869b916c8b4e42b367ab29fedc98481d1e74e14"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3573d376454d956553c356df45bb824262c397c6e26ce43e8203c4c540ee0acb"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e89df2958e5159b811af9ff0f92614dabf4ff617c03a4c1c6ff53bf1c399e0e1"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:78cacd03e79d009d95635e7d6ff12c21eb89b894c354bd2b2ed0b4763373693b"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:de5695a6f1d8340b12a5d6d4484290ee74d61e467c39ff03b39e30df62cf83a0"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1c60b9c202d00052183c9be85e5eaf18a4ada0a47d188a83c8f5c5b23252f649"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:f645caaf0008bacf349875a974220f1f1da349c5dbe7c4ec93048cdc785a3326"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:ea9f9c6034ea2d93d9147818f17c2a0860d41b71c38b9ce4d55f21b6f9165a11"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:80d1543d58bd3d6c271b66abf454d437a438dff01c3e62fdbcd68f2a11310d4b"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:73dc03a6a7e30b7edc5b01b601e53e7fc924b04e1835e8e407c12c037e81adbd"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6f5c2e7bc8a4bf7c426599765b1bd33217ec84023033672c1e9a8b35eaeaaaf8"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-win32.whl", hash = "sha256:12a2b561af122e3d94cdb97fe6fb2bb2b82cef0cdca131646fdb940a1eda04f0"}, - {file = "charset_normalizer-3.1.0-cp38-cp38-win_amd64.whl", hash = "sha256:3160a0fd9754aab7d47f95a6b63ab355388d890163eb03b2d2b87ab0a30cfa59"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:38e812a197bf8e71a59fe55b757a84c1f946d0ac114acafaafaf21667a7e169e"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:6baf0baf0d5d265fa7944feb9f7451cc316bfe30e8df1a61b1bb08577c554f31"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:8f25e17ab3039b05f762b0a55ae0b3632b2e073d9c8fc88e89aca31a6198e88f"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3747443b6a904001473370d7810aa19c3a180ccd52a7157aacc264a5ac79265e"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b116502087ce8a6b7a5f1814568ccbd0e9f6cfd99948aa59b0e241dc57cf739f"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d16fd5252f883eb074ca55cb622bc0bee49b979ae4e8639fff6ca3ff44f9f854"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:21fa558996782fc226b529fdd2ed7866c2c6ec91cee82735c98a197fae39f706"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6f6c7a8a57e9405cad7485f4c9d3172ae486cfef1344b5ddd8e5239582d7355e"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:ac3775e3311661d4adace3697a52ac0bab17edd166087d493b52d4f4f553f9f0"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:10c93628d7497c81686e8e5e557aafa78f230cd9e77dd0c40032ef90c18f2230"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:6f4f4668e1831850ebcc2fd0b1cd11721947b6dc7c00bf1c6bd3c929ae14f2c7"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:0be65ccf618c1e7ac9b849c315cc2e8a8751d9cfdaa43027d4f6624bd587ab7e"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:53d0a3fa5f8af98a1e261de6a3943ca631c526635eb5817a87a59d9a57ebf48f"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-win32.whl", hash = "sha256:a04f86f41a8916fe45ac5024ec477f41f886b3c435da2d4e3d2709b22ab02af1"}, - {file = "charset_normalizer-3.1.0-cp39-cp39-win_amd64.whl", hash = "sha256:830d2948a5ec37c386d3170c483063798d7879037492540f10a475e3fd6f244b"}, - {file = "charset_normalizer-3.1.0-py3-none-any.whl", hash = "sha256:3d9098b479e78c85080c98e1e35ff40b4a31d8953102bb0fd7d1b6f8a2111a3d"}, + {file = "charset_normalizer-3.4.4-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:e824f1492727fa856dd6eda4f7cee25f8518a12f3c4a56a74e8095695089cf6d"}, + {file = "charset_normalizer-3.4.4-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:4bd5d4137d500351a30687c2d3971758aac9a19208fc110ccb9d7188fbe709e8"}, + {file = "charset_normalizer-3.4.4-cp310-cp310-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:027f6de494925c0ab2a55eab46ae5129951638a49a34d87f4c3eda90f696b4ad"}, + {file = "charset_normalizer-3.4.4-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:f820802628d2694cb7e56db99213f930856014862f3fd943d290ea8438d07ca8"}, + {file = "charset_normalizer-3.4.4-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:798d75d81754988d2565bff1b97ba5a44411867c0cf32b77a7e8f8d84796b10d"}, + {file = "charset_normalizer-3.4.4-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9d1bb833febdff5c8927f922386db610b49db6e0d4f4ee29601d71e7c2694313"}, + {file = "charset_normalizer-3.4.4-cp310-cp310-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:9cd98cdc06614a2f768d2b7286d66805f94c48cde050acdbbb7db2600ab3197e"}, + {file = "charset_normalizer-3.4.4-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:077fbb858e903c73f6c9db43374fd213b0b6a778106bc7032446a8e8b5b38b93"}, + {file = "charset_normalizer-3.4.4-cp310-cp310-musllinux_1_2_armv7l.whl", hash = "sha256:244bfb999c71b35de57821b8ea746b24e863398194a4014e4c76adc2bbdfeff0"}, + {file = "charset_normalizer-3.4.4-cp310-cp310-musllinux_1_2_ppc64le.whl", hash = "sha256:64b55f9dce520635f018f907ff1b0df1fdc31f2795a922fb49dd14fbcdf48c84"}, + {file = "charset_normalizer-3.4.4-cp310-cp310-musllinux_1_2_riscv64.whl", hash = "sha256:faa3a41b2b66b6e50f84ae4a68c64fcd0c44355741c6374813a800cd6695db9e"}, + {file = "charset_normalizer-3.4.4-cp310-cp310-musllinux_1_2_s390x.whl", hash = "sha256:6515f3182dbe4ea06ced2d9e8666d97b46ef4c75e326b79bb624110f122551db"}, + {file = "charset_normalizer-3.4.4-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:cc00f04ed596e9dc0da42ed17ac5e596c6ccba999ba6bd92b0e0aef2f170f2d6"}, + {file = "charset_normalizer-3.4.4-cp310-cp310-win32.whl", hash = "sha256:f34be2938726fc13801220747472850852fe6b1ea75869a048d6f896838c896f"}, + {file = "charset_normalizer-3.4.4-cp310-cp310-win_amd64.whl", hash = "sha256:a61900df84c667873b292c3de315a786dd8dac506704dea57bc957bd31e22c7d"}, + {file = "charset_normalizer-3.4.4-cp310-cp310-win_arm64.whl", hash = "sha256:cead0978fc57397645f12578bfd2d5ea9138ea0fac82b2f63f7f7c6877986a69"}, + {file = "charset_normalizer-3.4.4-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:6e1fcf0720908f200cd21aa4e6750a48ff6ce4afe7ff5a79a90d5ed8a08296f8"}, + {file = "charset_normalizer-3.4.4-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:5f819d5fe9234f9f82d75bdfa9aef3a3d72c4d24a6e57aeaebba32a704553aa0"}, + {file = "charset_normalizer-3.4.4-cp311-cp311-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:a59cb51917aa591b1c4e6a43c132f0cdc3c76dbad6155df4e28ee626cc77a0a3"}, + {file = "charset_normalizer-3.4.4-cp311-cp311-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:8ef3c867360f88ac904fd3f5e1f902f13307af9052646963ee08ff4f131adafc"}, + {file = "charset_normalizer-3.4.4-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:d9e45d7faa48ee908174d8fe84854479ef838fc6a705c9315372eacbc2f02897"}, + {file = "charset_normalizer-3.4.4-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:840c25fb618a231545cbab0564a799f101b63b9901f2569faecd6b222ac72381"}, + {file = "charset_normalizer-3.4.4-cp311-cp311-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:ca5862d5b3928c4940729dacc329aa9102900382fea192fc5e52eb69d6093815"}, + {file = "charset_normalizer-3.4.4-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:d9c7f57c3d666a53421049053eaacdd14bbd0a528e2186fcb2e672effd053bb0"}, + {file = "charset_normalizer-3.4.4-cp311-cp311-musllinux_1_2_armv7l.whl", hash = "sha256:277e970e750505ed74c832b4bf75dac7476262ee2a013f5574dd49075879e161"}, + {file = "charset_normalizer-3.4.4-cp311-cp311-musllinux_1_2_ppc64le.whl", hash = "sha256:31fd66405eaf47bb62e8cd575dc621c56c668f27d46a61d975a249930dd5e2a4"}, + {file = "charset_normalizer-3.4.4-cp311-cp311-musllinux_1_2_riscv64.whl", hash = "sha256:0d3d8f15c07f86e9ff82319b3d9ef6f4bf907608f53fe9d92b28ea9ae3d1fd89"}, + {file = "charset_normalizer-3.4.4-cp311-cp311-musllinux_1_2_s390x.whl", hash = "sha256:9f7fcd74d410a36883701fafa2482a6af2ff5ba96b9a620e9e0721e28ead5569"}, + {file = "charset_normalizer-3.4.4-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:ebf3e58c7ec8a8bed6d66a75d7fb37b55e5015b03ceae72a8e7c74495551e224"}, + {file = "charset_normalizer-3.4.4-cp311-cp311-win32.whl", hash = "sha256:eecbc200c7fd5ddb9a7f16c7decb07b566c29fa2161a16cf67b8d068bd21690a"}, + {file = "charset_normalizer-3.4.4-cp311-cp311-win_amd64.whl", hash = "sha256:5ae497466c7901d54b639cf42d5b8c1b6a4fead55215500d2f486d34db48d016"}, + {file = "charset_normalizer-3.4.4-cp311-cp311-win_arm64.whl", hash = "sha256:65e2befcd84bc6f37095f5961e68a6f077bf44946771354a28ad434c2cce0ae1"}, + {file = "charset_normalizer-3.4.4-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:0a98e6759f854bd25a58a73fa88833fba3b7c491169f86ce1180c948ab3fd394"}, + {file = "charset_normalizer-3.4.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b5b290ccc2a263e8d185130284f8501e3e36c5e02750fc6b6bdeb2e9e96f1e25"}, + {file = "charset_normalizer-3.4.4-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:74bb723680f9f7a6234dcf67aea57e708ec1fbdf5699fb91dfd6f511b0a320ef"}, + {file = "charset_normalizer-3.4.4-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:f1e34719c6ed0b92f418c7c780480b26b5d9c50349e9a9af7d76bf757530350d"}, + {file = "charset_normalizer-3.4.4-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:2437418e20515acec67d86e12bf70056a33abdacb5cb1655042f6538d6b085a8"}, + {file = "charset_normalizer-3.4.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:11d694519d7f29d6cd09f6ac70028dba10f92f6cdd059096db198c283794ac86"}, + {file = "charset_normalizer-3.4.4-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:ac1c4a689edcc530fc9d9aa11f5774b9e2f33f9a0c6a57864e90908f5208d30a"}, + {file = "charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:21d142cc6c0ec30d2efee5068ca36c128a30b0f2c53c1c07bd78cb6bc1d3be5f"}, + {file = "charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:5dbe56a36425d26d6cfb40ce79c314a2e4dd6211d51d6d2191c00bed34f354cc"}, + {file = "charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:5bfbb1b9acf3334612667b61bd3002196fe2a1eb4dd74d247e0f2a4d50ec9bbf"}, + {file = "charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:d055ec1e26e441f6187acf818b73564e6e6282709e9bcb5b63f5b23068356a15"}, + {file = "charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:af2d8c67d8e573d6de5bc30cdb27e9b95e49115cd9baad5ddbd1a6207aaa82a9"}, + {file = "charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:780236ac706e66881f3b7f2f32dfe90507a09e67d1d454c762cf642e6e1586e0"}, + {file = "charset_normalizer-3.4.4-cp312-cp312-win32.whl", hash = "sha256:5833d2c39d8896e4e19b689ffc198f08ea58116bee26dea51e362ecc7cd3ed26"}, + {file = "charset_normalizer-3.4.4-cp312-cp312-win_amd64.whl", hash = "sha256:a79cfe37875f822425b89a82333404539ae63dbdddf97f84dcbc3d339aae9525"}, + {file = "charset_normalizer-3.4.4-cp312-cp312-win_arm64.whl", hash = "sha256:376bec83a63b8021bb5c8ea75e21c4ccb86e7e45ca4eb81146091b56599b80c3"}, + {file = "charset_normalizer-3.4.4-cp313-cp313-macosx_10_13_universal2.whl", hash = "sha256:e1f185f86a6f3403aa2420e815904c67b2f9ebc443f045edd0de921108345794"}, + {file = "charset_normalizer-3.4.4-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6b39f987ae8ccdf0d2642338faf2abb1862340facc796048b604ef14919e55ed"}, + {file = "charset_normalizer-3.4.4-cp313-cp313-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:3162d5d8ce1bb98dd51af660f2121c55d0fa541b46dff7bb9b9f86ea1d87de72"}, + {file = "charset_normalizer-3.4.4-cp313-cp313-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:81d5eb2a312700f4ecaa977a8235b634ce853200e828fbadf3a9c50bab278328"}, + {file = "charset_normalizer-3.4.4-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:5bd2293095d766545ec1a8f612559f6b40abc0eb18bb2f5d1171872d34036ede"}, + {file = "charset_normalizer-3.4.4-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a8a8b89589086a25749f471e6a900d3f662d1d3b6e2e59dcecf787b1cc3a1894"}, + {file = "charset_normalizer-3.4.4-cp313-cp313-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:bc7637e2f80d8530ee4a78e878bce464f70087ce73cf7c1caf142416923b98f1"}, + {file = "charset_normalizer-3.4.4-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:f8bf04158c6b607d747e93949aa60618b61312fe647a6369f88ce2ff16043490"}, + {file = "charset_normalizer-3.4.4-cp313-cp313-musllinux_1_2_armv7l.whl", hash = "sha256:554af85e960429cf30784dd47447d5125aaa3b99a6f0683589dbd27e2f45da44"}, + {file = "charset_normalizer-3.4.4-cp313-cp313-musllinux_1_2_ppc64le.whl", hash = "sha256:74018750915ee7ad843a774364e13a3db91682f26142baddf775342c3f5b1133"}, + {file = "charset_normalizer-3.4.4-cp313-cp313-musllinux_1_2_riscv64.whl", hash = "sha256:c0463276121fdee9c49b98908b3a89c39be45d86d1dbaa22957e38f6321d4ce3"}, + {file = "charset_normalizer-3.4.4-cp313-cp313-musllinux_1_2_s390x.whl", hash = "sha256:362d61fd13843997c1c446760ef36f240cf81d3ebf74ac62652aebaf7838561e"}, + {file = "charset_normalizer-3.4.4-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:9a26f18905b8dd5d685d6d07b0cdf98a79f3c7a918906af7cc143ea2e164c8bc"}, + {file = "charset_normalizer-3.4.4-cp313-cp313-win32.whl", hash = "sha256:9b35f4c90079ff2e2edc5b26c0c77925e5d2d255c42c74fdb70fb49b172726ac"}, + {file = "charset_normalizer-3.4.4-cp313-cp313-win_amd64.whl", hash = "sha256:b435cba5f4f750aa6c0a0d92c541fb79f69a387c91e61f1795227e4ed9cece14"}, + {file = "charset_normalizer-3.4.4-cp313-cp313-win_arm64.whl", hash = "sha256:542d2cee80be6f80247095cc36c418f7bddd14f4a6de45af91dfad36d817bba2"}, + {file = "charset_normalizer-3.4.4-cp314-cp314-macosx_10_13_universal2.whl", hash = "sha256:da3326d9e65ef63a817ecbcc0df6e94463713b754fe293eaa03da99befb9a5bd"}, + {file = "charset_normalizer-3.4.4-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:8af65f14dc14a79b924524b1e7fffe304517b2bff5a58bf64f30b98bbc5079eb"}, + {file = "charset_normalizer-3.4.4-cp314-cp314-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:74664978bb272435107de04e36db5a9735e78232b85b77d45cfb38f758efd33e"}, + {file = "charset_normalizer-3.4.4-cp314-cp314-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:752944c7ffbfdd10c074dc58ec2d5a8a4cd9493b314d367c14d24c17684ddd14"}, + {file = "charset_normalizer-3.4.4-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:d1f13550535ad8cff21b8d757a3257963e951d96e20ec82ab44bc64aeb62a191"}, + {file = "charset_normalizer-3.4.4-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ecaae4149d99b1c9e7b88bb03e3221956f68fd6d50be2ef061b2381b61d20838"}, + {file = "charset_normalizer-3.4.4-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:cb6254dc36b47a990e59e1068afacdcd02958bdcce30bb50cc1700a8b9d624a6"}, + {file = "charset_normalizer-3.4.4-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:c8ae8a0f02f57a6e61203a31428fa1d677cbe50c93622b4149d5c0f319c1d19e"}, + {file = "charset_normalizer-3.4.4-cp314-cp314-musllinux_1_2_armv7l.whl", hash = "sha256:47cc91b2f4dd2833fddaedd2893006b0106129d4b94fdb6af1f4ce5a9965577c"}, + {file = "charset_normalizer-3.4.4-cp314-cp314-musllinux_1_2_ppc64le.whl", hash = "sha256:82004af6c302b5d3ab2cfc4cc5f29db16123b1a8417f2e25f9066f91d4411090"}, + {file = "charset_normalizer-3.4.4-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:2b7d8f6c26245217bd2ad053761201e9f9680f8ce52f0fcd8d0755aeae5b2152"}, + {file = "charset_normalizer-3.4.4-cp314-cp314-musllinux_1_2_s390x.whl", hash = "sha256:799a7a5e4fb2d5898c60b640fd4981d6a25f1c11790935a44ce38c54e985f828"}, + {file = "charset_normalizer-3.4.4-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:99ae2cffebb06e6c22bdc25801d7b30f503cc87dbd283479e7b606f70aff57ec"}, + {file = "charset_normalizer-3.4.4-cp314-cp314-win32.whl", hash = "sha256:f9d332f8c2a2fcbffe1378594431458ddbef721c1769d78e2cbc06280d8155f9"}, + {file = "charset_normalizer-3.4.4-cp314-cp314-win_amd64.whl", hash = "sha256:8a6562c3700cce886c5be75ade4a5db4214fda19fede41d9792d100288d8f94c"}, + {file = "charset_normalizer-3.4.4-cp314-cp314-win_arm64.whl", hash = "sha256:de00632ca48df9daf77a2c65a484531649261ec9f25489917f09e455cb09ddb2"}, + {file = "charset_normalizer-3.4.4-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:ce8a0633f41a967713a59c4139d29110c07e826d131a316b50ce11b1d79b4f84"}, + {file = "charset_normalizer-3.4.4-cp38-cp38-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:eaabd426fe94daf8fd157c32e571c85cb12e66692f15516a83a03264b08d06c3"}, + {file = "charset_normalizer-3.4.4-cp38-cp38-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:c4ef880e27901b6cc782f1b95f82da9313c0eb95c3af699103088fa0ac3ce9ac"}, + {file = "charset_normalizer-3.4.4-cp38-cp38-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:2aaba3b0819274cc41757a1da876f810a3e4d7b6eb25699253a4effef9e8e4af"}, + {file = "charset_normalizer-3.4.4-cp38-cp38-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:778d2e08eda00f4256d7f672ca9fef386071c9202f5e4607920b86d7803387f2"}, + {file = "charset_normalizer-3.4.4-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:f155a433c2ec037d4e8df17d18922c3a0d9b3232a396690f17175d2946f0218d"}, + {file = "charset_normalizer-3.4.4-cp38-cp38-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:a8bf8d0f749c5757af2142fe7903a9df1d2e8aa3841559b2bad34b08d0e2bcf3"}, + {file = "charset_normalizer-3.4.4-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:194f08cbb32dc406d6e1aea671a68be0823673db2832b38405deba2fb0d88f63"}, + {file = "charset_normalizer-3.4.4-cp38-cp38-musllinux_1_2_armv7l.whl", hash = "sha256:6aee717dcfead04c6eb1ce3bd29ac1e22663cdea57f943c87d1eab9a025438d7"}, + {file = "charset_normalizer-3.4.4-cp38-cp38-musllinux_1_2_ppc64le.whl", hash = "sha256:cd4b7ca9984e5e7985c12bc60a6f173f3c958eae74f3ef6624bb6b26e2abbae4"}, + {file = "charset_normalizer-3.4.4-cp38-cp38-musllinux_1_2_riscv64.whl", hash = "sha256:b7cf1017d601aa35e6bb650b6ad28652c9cd78ee6caff19f3c28d03e1c80acbf"}, + {file = "charset_normalizer-3.4.4-cp38-cp38-musllinux_1_2_s390x.whl", hash = "sha256:e912091979546adf63357d7e2ccff9b44f026c075aeaf25a52d0e95ad2281074"}, + {file = "charset_normalizer-3.4.4-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:5cb4d72eea50c8868f5288b7f7f33ed276118325c1dfd3957089f6b519e1382a"}, + {file = "charset_normalizer-3.4.4-cp38-cp38-win32.whl", hash = "sha256:837c2ce8c5a65a2035be9b3569c684358dfbf109fd3b6969630a87535495ceaa"}, + {file = "charset_normalizer-3.4.4-cp38-cp38-win_amd64.whl", hash = "sha256:44c2a8734b333e0578090c4cd6b16f275e07aa6614ca8715e6c038e865e70576"}, + {file = "charset_normalizer-3.4.4-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:a9768c477b9d7bd54bc0c86dbaebdec6f03306675526c9927c0e8a04e8f94af9"}, + {file = "charset_normalizer-3.4.4-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1bee1e43c28aa63cb16e5c14e582580546b08e535299b8b6158a7c9c768a1f3d"}, + {file = "charset_normalizer-3.4.4-cp39-cp39-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:fd44c878ea55ba351104cb93cc85e74916eb8fa440ca7903e57575e97394f608"}, + {file = "charset_normalizer-3.4.4-cp39-cp39-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:0f04b14ffe5fdc8c4933862d8306109a2c51e0704acfa35d51598eb45a1e89fc"}, + {file = "charset_normalizer-3.4.4-cp39-cp39-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:cd09d08005f958f370f539f186d10aec3377d55b9eeb0d796025d4886119d76e"}, + {file = "charset_normalizer-3.4.4-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4fe7859a4e3e8457458e2ff592f15ccb02f3da787fcd31e0183879c3ad4692a1"}, + {file = "charset_normalizer-3.4.4-cp39-cp39-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:fa09f53c465e532f4d3db095e0c55b615f010ad81803d383195b6b5ca6cbf5f3"}, + {file = "charset_normalizer-3.4.4-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:7fa17817dc5625de8a027cb8b26d9fefa3ea28c8253929b8d6649e705d2835b6"}, + {file = "charset_normalizer-3.4.4-cp39-cp39-musllinux_1_2_armv7l.whl", hash = "sha256:5947809c8a2417be3267efc979c47d76a079758166f7d43ef5ae8e9f92751f88"}, + {file = "charset_normalizer-3.4.4-cp39-cp39-musllinux_1_2_ppc64le.whl", hash = "sha256:4902828217069c3c5c71094537a8e623f5d097858ac6ca8252f7b4d10b7560f1"}, + {file = "charset_normalizer-3.4.4-cp39-cp39-musllinux_1_2_riscv64.whl", hash = "sha256:7c308f7e26e4363d79df40ca5b2be1c6ba9f02bdbccfed5abddb7859a6ce72cf"}, + {file = "charset_normalizer-3.4.4-cp39-cp39-musllinux_1_2_s390x.whl", hash = "sha256:2c9d3c380143a1fedbff95a312aa798578371eb29da42106a29019368a475318"}, + {file = "charset_normalizer-3.4.4-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:cb01158d8b88ee68f15949894ccc6712278243d95f344770fa7593fa2d94410c"}, + {file = "charset_normalizer-3.4.4-cp39-cp39-win32.whl", hash = "sha256:2677acec1a2f8ef614c6888b5b4ae4060cc184174a938ed4e8ef690e15d3e505"}, + {file = "charset_normalizer-3.4.4-cp39-cp39-win_amd64.whl", hash = "sha256:f8e160feb2aed042cd657a72acc0b481212ed28b1b9a95c0cee1621b524e1966"}, + {file = "charset_normalizer-3.4.4-cp39-cp39-win_arm64.whl", hash = "sha256:b5d84d37db046c5ca74ee7bb47dd6cbc13f80665fdde3e8040bdd3fb015ecb50"}, + {file = "charset_normalizer-3.4.4-py3-none-any.whl", hash = "sha256:7a32c560861a02ff789ad905a2fe94e3f840803362c84fecf1851cb4cf3dc37f"}, + {file = "charset_normalizer-3.4.4.tar.gz", hash = "sha256:94537985111c35f28720e43603b8e7b43a6ecfb2ce1d3058bbe955b73404e21a"}, ] [[package]] name = "idna" -version = "3.4" +version = "3.11" description = "Internationalized Domain Names in Applications (IDNA)" -category = "main" optional = false -python-versions = ">=3.5" +python-versions = ">=3.8" +groups = ["main"] files = [ - {file = "idna-3.4-py3-none-any.whl", hash = "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"}, - {file = "idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"}, + {file = "idna-3.11-py3-none-any.whl", hash = "sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea"}, + {file = "idna-3.11.tar.gz", hash = "sha256:795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902"}, ] +[package.extras] +all = ["flake8 (>=7.1.1)", "mypy (>=1.11.2)", "pytest (>=8.3.2)", "ruff (>=0.6.2)"] + [[package]] name = "python-dotenv" version = "0.21.1" description = "Read key-value pairs from a .env file and set them as environment variables" -category = "main" optional = false python-versions = ">=3.7" +groups = ["main"] files = [ {file = "python-dotenv-0.21.1.tar.gz", hash = "sha256:1c93de8f636cde3ce377292818d0e440b6e45a82f215c3744979151fa8151c49"}, {file = "python_dotenv-0.21.1-py3-none-any.whl", hash = "sha256:41e12e0318bebc859fcc4d97d4db8d20ad21721a6aa5047dd59f090391cb549a"}, @@ -126,69 +167,102 @@ cli = ["click (>=5.0)"] [[package]] name = "pyyaml" -version = "6.0" +version = "6.0.3" description = "YAML parser and emitter for Python" -category = "main" optional = false -python-versions = ">=3.6" +python-versions = ">=3.8" +groups = ["main"] files = [ - {file = "PyYAML-6.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53"}, - {file = "PyYAML-6.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c"}, - {file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc"}, - {file = "PyYAML-6.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b"}, - {file = "PyYAML-6.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"}, - {file = "PyYAML-6.0-cp310-cp310-win32.whl", hash = "sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513"}, - {file = "PyYAML-6.0-cp310-cp310-win_amd64.whl", hash = "sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a"}, - {file = "PyYAML-6.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:d4b0ba9512519522b118090257be113b9468d804b19d63c71dbcf4a48fa32358"}, - {file = "PyYAML-6.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:81957921f441d50af23654aa6c5e5eaf9b06aba7f0a19c18a538dc7ef291c5a1"}, - {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:afa17f5bc4d1b10afd4466fd3a44dc0e245382deca5b3c353d8b757f9e3ecb8d"}, - {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dbad0e9d368bb989f4515da330b88a057617d16b6a8245084f1b05400f24609f"}, - {file = "PyYAML-6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:432557aa2c09802be39460360ddffd48156e30721f5e8d917f01d31694216782"}, - {file = "PyYAML-6.0-cp311-cp311-win32.whl", hash = "sha256:bfaef573a63ba8923503d27530362590ff4f576c626d86a9fed95822a8255fd7"}, - {file = "PyYAML-6.0-cp311-cp311-win_amd64.whl", hash = "sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf"}, - {file = "PyYAML-6.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86"}, - {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f"}, - {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92"}, - {file = "PyYAML-6.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4"}, - {file = "PyYAML-6.0-cp36-cp36m-win32.whl", hash = "sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293"}, - {file = "PyYAML-6.0-cp36-cp36m-win_amd64.whl", hash = "sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57"}, - {file = "PyYAML-6.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c"}, - {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0"}, - {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4"}, - {file = "PyYAML-6.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9"}, - {file = "PyYAML-6.0-cp37-cp37m-win32.whl", hash = "sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737"}, - {file = "PyYAML-6.0-cp37-cp37m-win_amd64.whl", hash = "sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d"}, - {file = "PyYAML-6.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b"}, - {file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba"}, - {file = "PyYAML-6.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34"}, - {file = "PyYAML-6.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287"}, - {file = "PyYAML-6.0-cp38-cp38-win32.whl", hash = "sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78"}, - {file = "PyYAML-6.0-cp38-cp38-win_amd64.whl", hash = "sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07"}, - {file = "PyYAML-6.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b"}, - {file = "PyYAML-6.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174"}, - {file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803"}, - {file = "PyYAML-6.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3"}, - {file = "PyYAML-6.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0"}, - {file = "PyYAML-6.0-cp39-cp39-win32.whl", hash = "sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb"}, - {file = "PyYAML-6.0-cp39-cp39-win_amd64.whl", hash = "sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c"}, - {file = "PyYAML-6.0.tar.gz", hash = "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"}, + {file = "PyYAML-6.0.3-cp38-cp38-macosx_10_13_x86_64.whl", hash = "sha256:c2514fceb77bc5e7a2f7adfaa1feb2fb311607c9cb518dbc378688ec73d8292f"}, + {file = "PyYAML-6.0.3-cp38-cp38-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9c57bb8c96f6d1808c030b1687b9b5fb476abaa47f0db9c0101f5e9f394e97f4"}, + {file = "PyYAML-6.0.3-cp38-cp38-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:efd7b85f94a6f21e4932043973a7ba2613b059c4a000551892ac9f1d11f5baf3"}, + {file = "PyYAML-6.0.3-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:22ba7cfcad58ef3ecddc7ed1db3409af68d023b7f940da23c6c2a1890976eda6"}, + {file = "PyYAML-6.0.3-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:6344df0d5755a2c9a276d4473ae6b90647e216ab4757f8426893b5dd2ac3f369"}, + {file = "PyYAML-6.0.3-cp38-cp38-win32.whl", hash = "sha256:3ff07ec89bae51176c0549bc4c63aa6202991da2d9a6129d7aef7f1407d3f295"}, + {file = "PyYAML-6.0.3-cp38-cp38-win_amd64.whl", hash = "sha256:5cf4e27da7e3fbed4d6c3d8e797387aaad68102272f8f9752883bc32d61cb87b"}, + {file = "pyyaml-6.0.3-cp310-cp310-macosx_10_13_x86_64.whl", hash = "sha256:214ed4befebe12df36bcc8bc2b64b396ca31be9304b8f59e25c11cf94a4c033b"}, + {file = "pyyaml-6.0.3-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:02ea2dfa234451bbb8772601d7b8e426c2bfa197136796224e50e35a78777956"}, + {file = "pyyaml-6.0.3-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b30236e45cf30d2b8e7b3e85881719e98507abed1011bf463a8fa23e9c3e98a8"}, + {file = "pyyaml-6.0.3-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:66291b10affd76d76f54fad28e22e51719ef9ba22b29e1d7d03d6777a9174198"}, + {file = "pyyaml-6.0.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9c7708761fccb9397fe64bbc0395abcae8c4bf7b0eac081e12b809bf47700d0b"}, + {file = "pyyaml-6.0.3-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:418cf3f2111bc80e0933b2cd8cd04f286338bb88bdc7bc8e6dd775ebde60b5e0"}, + {file = "pyyaml-6.0.3-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:5e0b74767e5f8c593e8c9b5912019159ed0533c70051e9cce3e8b6aa699fcd69"}, + {file = "pyyaml-6.0.3-cp310-cp310-win32.whl", hash = "sha256:28c8d926f98f432f88adc23edf2e6d4921ac26fb084b028c733d01868d19007e"}, + {file = "pyyaml-6.0.3-cp310-cp310-win_amd64.whl", hash = "sha256:bdb2c67c6c1390b63c6ff89f210c8fd09d9a1217a465701eac7316313c915e4c"}, + {file = "pyyaml-6.0.3-cp311-cp311-macosx_10_13_x86_64.whl", hash = "sha256:44edc647873928551a01e7a563d7452ccdebee747728c1080d881d68af7b997e"}, + {file = "pyyaml-6.0.3-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:652cb6edd41e718550aad172851962662ff2681490a8a711af6a4d288dd96824"}, + {file = "pyyaml-6.0.3-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:10892704fc220243f5305762e276552a0395f7beb4dbf9b14ec8fd43b57f126c"}, + {file = "pyyaml-6.0.3-cp311-cp311-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:850774a7879607d3a6f50d36d04f00ee69e7fc816450e5f7e58d7f17f1ae5c00"}, + {file = "pyyaml-6.0.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:b8bb0864c5a28024fac8a632c443c87c5aa6f215c0b126c449ae1a150412f31d"}, + {file = "pyyaml-6.0.3-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:1d37d57ad971609cf3c53ba6a7e365e40660e3be0e5175fa9f2365a379d6095a"}, + {file = "pyyaml-6.0.3-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:37503bfbfc9d2c40b344d06b2199cf0e96e97957ab1c1b546fd4f87e53e5d3e4"}, + {file = "pyyaml-6.0.3-cp311-cp311-win32.whl", hash = "sha256:8098f252adfa6c80ab48096053f512f2321f0b998f98150cea9bd23d83e1467b"}, + {file = "pyyaml-6.0.3-cp311-cp311-win_amd64.whl", hash = "sha256:9f3bfb4965eb874431221a3ff3fdcddc7e74e3b07799e0e84ca4a0f867d449bf"}, + {file = "pyyaml-6.0.3-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:7f047e29dcae44602496db43be01ad42fc6f1cc0d8cd6c83d342306c32270196"}, + {file = "pyyaml-6.0.3-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:fc09d0aa354569bc501d4e787133afc08552722d3ab34836a80547331bb5d4a0"}, + {file = "pyyaml-6.0.3-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9149cad251584d5fb4981be1ecde53a1ca46c891a79788c0df828d2f166bda28"}, + {file = "pyyaml-6.0.3-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:5fdec68f91a0c6739b380c83b951e2c72ac0197ace422360e6d5a959d8d97b2c"}, + {file = "pyyaml-6.0.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ba1cc08a7ccde2d2ec775841541641e4548226580ab850948cbfda66a1befcdc"}, + {file = "pyyaml-6.0.3-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:8dc52c23056b9ddd46818a57b78404882310fb473d63f17b07d5c40421e47f8e"}, + {file = "pyyaml-6.0.3-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:41715c910c881bc081f1e8872880d3c650acf13dfa8214bad49ed4cede7c34ea"}, + {file = "pyyaml-6.0.3-cp312-cp312-win32.whl", hash = "sha256:96b533f0e99f6579b3d4d4995707cf36df9100d67e0c8303a0c55b27b5f99bc5"}, + {file = "pyyaml-6.0.3-cp312-cp312-win_amd64.whl", hash = "sha256:5fcd34e47f6e0b794d17de1b4ff496c00986e1c83f7ab2fb8fcfe9616ff7477b"}, + {file = "pyyaml-6.0.3-cp312-cp312-win_arm64.whl", hash = "sha256:64386e5e707d03a7e172c0701abfb7e10f0fb753ee1d773128192742712a98fd"}, + {file = "pyyaml-6.0.3-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:8da9669d359f02c0b91ccc01cac4a67f16afec0dac22c2ad09f46bee0697eba8"}, + {file = "pyyaml-6.0.3-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:2283a07e2c21a2aa78d9c4442724ec1eb15f5e42a723b99cb3d822d48f5f7ad1"}, + {file = "pyyaml-6.0.3-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ee2922902c45ae8ccada2c5b501ab86c36525b883eff4255313a253a3160861c"}, + {file = "pyyaml-6.0.3-cp313-cp313-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a33284e20b78bd4a18c8c2282d549d10bc8408a2a7ff57653c0cf0b9be0afce5"}, + {file = "pyyaml-6.0.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0f29edc409a6392443abf94b9cf89ce99889a1dd5376d94316ae5145dfedd5d6"}, + {file = "pyyaml-6.0.3-cp313-cp313-musllinux_1_2_aarch64.whl", hash = "sha256:f7057c9a337546edc7973c0d3ba84ddcdf0daa14533c2065749c9075001090e6"}, + {file = "pyyaml-6.0.3-cp313-cp313-musllinux_1_2_x86_64.whl", hash = "sha256:eda16858a3cab07b80edaf74336ece1f986ba330fdb8ee0d6c0d68fe82bc96be"}, + {file = "pyyaml-6.0.3-cp313-cp313-win32.whl", hash = "sha256:d0eae10f8159e8fdad514efdc92d74fd8d682c933a6dd088030f3834bc8e6b26"}, + {file = "pyyaml-6.0.3-cp313-cp313-win_amd64.whl", hash = "sha256:79005a0d97d5ddabfeeea4cf676af11e647e41d81c9a7722a193022accdb6b7c"}, + {file = "pyyaml-6.0.3-cp313-cp313-win_arm64.whl", hash = "sha256:5498cd1645aa724a7c71c8f378eb29ebe23da2fc0d7a08071d89469bf1d2defb"}, + {file = "pyyaml-6.0.3-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:8d1fab6bb153a416f9aeb4b8763bc0f22a5586065f86f7664fc23339fc1c1fac"}, + {file = "pyyaml-6.0.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:34d5fcd24b8445fadc33f9cf348c1047101756fd760b4dacb5c3e99755703310"}, + {file = "pyyaml-6.0.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:501a031947e3a9025ed4405a168e6ef5ae3126c59f90ce0cd6f2bfc477be31b7"}, + {file = "pyyaml-6.0.3-cp314-cp314-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:b3bc83488de33889877a0f2543ade9f70c67d66d9ebb4ac959502e12de895788"}, + {file = "pyyaml-6.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c458b6d084f9b935061bc36216e8a69a7e293a2f1e68bf956dcd9e6cbcd143f5"}, + {file = "pyyaml-6.0.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:7c6610def4f163542a622a73fb39f534f8c101d690126992300bf3207eab9764"}, + {file = "pyyaml-6.0.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:5190d403f121660ce8d1d2c1bb2ef1bd05b5f68533fc5c2ea899bd15f4399b35"}, + {file = "pyyaml-6.0.3-cp314-cp314-win_amd64.whl", hash = "sha256:4a2e8cebe2ff6ab7d1050ecd59c25d4c8bd7e6f400f5f82b96557ac0abafd0ac"}, + {file = "pyyaml-6.0.3-cp314-cp314-win_arm64.whl", hash = "sha256:93dda82c9c22deb0a405ea4dc5f2d0cda384168e466364dec6255b293923b2f3"}, + {file = "pyyaml-6.0.3-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:02893d100e99e03eda1c8fd5c441d8c60103fd175728e23e431db1b589cf5ab3"}, + {file = "pyyaml-6.0.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:c1ff362665ae507275af2853520967820d9124984e0f7466736aea23d8611fba"}, + {file = "pyyaml-6.0.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:6adc77889b628398debc7b65c073bcb99c4a0237b248cacaf3fe8a557563ef6c"}, + {file = "pyyaml-6.0.3-cp314-cp314t-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:a80cb027f6b349846a3bf6d73b5e95e782175e52f22108cfa17876aaeff93702"}, + {file = "pyyaml-6.0.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c"}, + {file = "pyyaml-6.0.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:66e1674c3ef6f541c35191caae2d429b967b99e02040f5ba928632d9a7f0f065"}, + {file = "pyyaml-6.0.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:16249ee61e95f858e83976573de0f5b2893b3677ba71c9dd36b9cf8be9ac6d65"}, + {file = "pyyaml-6.0.3-cp314-cp314t-win_amd64.whl", hash = "sha256:4ad1906908f2f5ae4e5a8ddfce73c320c2a1429ec52eafd27138b7f1cbe341c9"}, + {file = "pyyaml-6.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b"}, + {file = "pyyaml-6.0.3-cp39-cp39-macosx_10_13_x86_64.whl", hash = "sha256:b865addae83924361678b652338317d1bd7e79b1f4596f96b96c77a5a34b34da"}, + {file = "pyyaml-6.0.3-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c3355370a2c156cffb25e876646f149d5d68f5e0a3ce86a5084dd0b64a994917"}, + {file = "pyyaml-6.0.3-cp39-cp39-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3c5677e12444c15717b902a5798264fa7909e41153cdf9ef7ad571b704a63dd9"}, + {file = "pyyaml-6.0.3-cp39-cp39-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:5ed875a24292240029e4483f9d4a4b8a1ae08843b9c54f43fcc11e404532a8a5"}, + {file = "pyyaml-6.0.3-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0150219816b6a1fa26fb4699fb7daa9caf09eb1999f3b70fb6e786805e80375a"}, + {file = "pyyaml-6.0.3-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:fa160448684b4e94d80416c0fa4aac48967a969efe22931448d853ada8baf926"}, + {file = "pyyaml-6.0.3-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:27c0abcb4a5dac13684a37f76e701e054692a9b2d3064b70f5e4eb54810553d7"}, + {file = "pyyaml-6.0.3-cp39-cp39-win32.whl", hash = "sha256:1ebe39cb5fc479422b83de611d14e2c0d3bb2a18bbcb01f229ab3cfbd8fee7a0"}, + {file = "pyyaml-6.0.3-cp39-cp39-win_amd64.whl", hash = "sha256:2e71d11abed7344e42a8849600193d15b6def118602c4c176f748e4583246007"}, + {file = "pyyaml-6.0.3.tar.gz", hash = "sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f"}, ] [[package]] name = "requests" -version = "2.30.0" +version = "2.32.5" description = "Python HTTP for Humans." -category = "main" optional = false -python-versions = ">=3.7" +python-versions = ">=3.9" +groups = ["main"] files = [ - {file = "requests-2.30.0-py3-none-any.whl", hash = "sha256:10e94cc4f3121ee6da529d358cdaeaff2f1c409cd377dbc72b825852f2f7e294"}, - {file = "requests-2.30.0.tar.gz", hash = "sha256:239d7d4458afcb28a692cdd298d87542235f4ca8d36d03a15bfc128a6559a2f4"}, + {file = "requests-2.32.5-py3-none-any.whl", hash = "sha256:2462f94637a34fd532264295e186976db0f5d453d1cdd31473c85a6a161affb6"}, + {file = "requests-2.32.5.tar.gz", hash = "sha256:dbba0bac56e100853db0ea71b82b4dfd5fe2bf6d3754a8893c3af500cec7d7cf"}, ] [package.dependencies] certifi = ">=2017.4.17" -charset-normalizer = ">=2,<4" +charset_normalizer = ">=2,<4" idna = ">=2.5,<4" urllib3 = ">=1.21.1,<3" @@ -198,23 +272,23 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "urllib3" -version = "2.0.2" +version = "2.6.2" description = "HTTP library with thread-safe connection pooling, file post, and more." -category = "main" optional = false -python-versions = ">=3.7" +python-versions = ">=3.9" +groups = ["main"] files = [ - {file = "urllib3-2.0.2-py3-none-any.whl", hash = "sha256:d055c2f9d38dc53c808f6fdc8eab7360b6fdbbde02340ed25cfbcd817c62469e"}, - {file = "urllib3-2.0.2.tar.gz", hash = "sha256:61717a1095d7e155cdb737ac7bb2f4324a858a1e2e6466f6d03ff630ca68d3cc"}, + {file = "urllib3-2.6.2-py3-none-any.whl", hash = "sha256:ec21cddfe7724fc7cb4ba4bea7aa8e2ef36f607a4bab81aa6ce42a13dc3f03dd"}, + {file = "urllib3-2.6.2.tar.gz", hash = "sha256:016f9c98bb7e98085cb2b4b17b87d2c702975664e4f060c6532e64d1c1a5e797"}, ] [package.extras] -brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)"] -secure = ["certifi", "cryptography (>=1.9)", "idna (>=2.0.0)", "pyopenssl (>=17.1.0)", "urllib3-secure-extra"] +brotli = ["brotli (>=1.2.0) ; platform_python_implementation == \"CPython\"", "brotlicffi (>=1.2.0.0) ; platform_python_implementation != \"CPython\""] +h2 = ["h2 (>=4,<5)"] socks = ["pysocks (>=1.5.6,!=1.5.7,<2.0)"] -zstd = ["zstandard (>=0.18.0)"] +zstd = ["backports-zstd (>=1.0.0) ; python_version < \"3.14\""] [metadata] -lock-version = "2.0" -python-versions = "^3.7" -content-hash = "183cb7c9fea19dde7372dc976fa5a0457252f970e6a79f54631896a8d711cff1" +lock-version = "2.1" +python-versions = "^3.9" +content-hash = "eca02f6ded24311e6a3f6249289dfb5a139fdf1239637acbc90a5b771953df34" diff --git a/pyproject.toml b/pyproject.toml index 95a9024..cec993c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "python-substack" -version = "0.1.7" +version = "0.1.17" description = "A Python wrapper around the Substack API." authors = ["Paolo Mazza "] license = "MIT" @@ -16,16 +16,16 @@ homepage = "https://github.com/ma2za/python-substack" keywords = ["substack"] [tool.poetry.dependencies] -python = "^3.7" +python = "^3.9" -requests = "^2.28.1" +requests = "^2.31.0" python-dotenv = "^0.21.0" PyYAML = "^6.0" -[tool.poetry.dev-dependencies] +[tool.poetry.group.dev.dependencies] [build-system] requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" \ No newline at end of file +build-backend = "poetry.core.masonry.api" diff --git a/substack/__init__.py b/substack/__init__.py index 00538c5..0d8268f 100644 --- a/substack/__init__.py +++ b/substack/__init__.py @@ -4,7 +4,7 @@ __email__ = "mazzapaolo2019@gmail.com" __license__ = "MIT License" __version__ = "1.0" -__url__ = "https://github.com/hogier/python-substack" +__url__ = "https://github.com/ma2za/python-substack" __download_url__ = "https://pypi.python.org/pypi/python-substack" __description__ = "A Python wrapper around the Substack API" diff --git a/substack/api.py b/substack/api.py index 3da37b6..a4b51cb 100644 --- a/substack/api.py +++ b/substack/api.py @@ -1,8 +1,15 @@ +""" + +API Wrapper + +""" + import base64 +import json import logging import os from datetime import datetime -from urllib.parse import urljoin +from urllib.parse import urljoin, unquote import requests @@ -10,6 +17,8 @@ logger = logging.getLogger(__name__) +__all__ = ["Api"] + class Api: """ @@ -19,12 +28,14 @@ class Api: """ def __init__( - self, - email=None, - password=None, - base_url=None, - publication_url=None, - debug=False, + self, + email=None, + password=None, + cookies_path=None, + base_url=None, + publication_url=None, + debug=False, + cookies_string=None, ): """ @@ -35,12 +46,19 @@ def __init__( Args: email: password: + cookies_path + To re-use your session without logging in each time, you can save your cookies to a json file and + then load them in the next session. + Make sure to re-save your cookies, as they do update over time. + cookies_string + To re-use your session without logging in each time, you can provide cookies as a semicolon-separated + string (e.g., "cookie1=value1; cookie2=value2"). This is useful when copying cookies from browser + developer tools. base_url: The base URL to use to contact the Substack API. Defaults to https://substack.com/api/v1. """ self.base_url = base_url or "https://substack.com/api/v1" - self.publication_url = urljoin(publication_url, "api/v1") if debug: logging.basicConfig() @@ -48,8 +66,71 @@ def __init__( self._session = requests.Session() - if email is not None and password is not None: + # Load cookies from file if provided + # Helps with Captcha errors by reusing cookies from "local" auth, then switching to running code in the cloud + if cookies_path is not None: + with open(cookies_path) as f: + cookies = json.load(f) + self._session.cookies.update(cookies) + + elif cookies_string is not None: + cookies = self._parse_cookies_string(cookies_string) + self._session.cookies.update(cookies) + + elif email is not None and password is not None: self.login(email, password) + else: + raise ValueError( + "Must provide email and password, cookies_path, or cookies_string to authenticate." + ) + + user_publication = None + # if the user provided a publication url, then use that + if publication_url: + import re + + # Regular expression to extract subdomain name + match = re.search(r"https://(.*).substack.com", publication_url.lower()) + subdomain = match.group(1) if match else None + + user_publications = self.get_user_publications() + # search through publications to find the publication with the matching subdomain + for publication in user_publications: + if publication["subdomain"] == subdomain: + # set the current publication to the users publication + user_publication = publication + break + else: + # get the users primary publication + user_publication = self.get_user_primary_publication() + + # set the current publication to the users primary publication + self.change_publication(user_publication) + + @staticmethod + def _parse_cookies_string(cookies_string: str) -> dict: + """ + Parse a semicolon-separated cookie string into a dictionary. + + Args: + cookies_string: A semicolon-separated string of cookies (e.g., "cookie1=value1; cookie2=value2") + + Returns: + A dictionary of cookie name-value pairs + """ + cookies = {} + for cookie_pair in cookies_string.split(';'): + cookie_pair = cookie_pair.strip() + if not cookie_pair: + continue + if '=' in cookie_pair: + key, value = cookie_pair.split('=', 1) + key = key.strip() + value = value.strip() + # URL decode the value (e.g., s%3A becomes s:) + value = unquote(value) + cookies[key] = value + return cookies def login(self, email, password) -> dict: """ @@ -71,8 +152,41 @@ def login(self, email, password) -> dict: "redirect": "/", }, ) + return Api._handle_response(response=response) + def signin_for_pub(self, publication): + """ + Complete the signin process + """ + response = self._session.get( + f"https://substack.com/sign-in?redirect=%2F&for_pub={publication['subdomain']}", + ) + try: + output = Api._handle_response(response=response) + except SubstackRequestException as ex: + output = {} + return output + + def change_publication(self, publication): + """ + Change the publication URL + """ + self.publication_url = urljoin(publication["publication_url"], "api/v1") + + # sign-in to the publication + self.signin_for_pub(publication) + + def export_cookies(self, path: str = "cookies.json"): + """ + Export cookies to a json file. + Args: + path: path to the json file + """ + cookies = self._session.cookies.get_dict() + with open(path, "w") as f: + json.dump(cookies, f) + @staticmethod def _handle_response(response: requests.Response): """ @@ -90,35 +204,202 @@ def _handle_response(response: requests.Response): except ValueError: raise SubstackRequestException("Invalid Response: %s" % response.text) + def get_user_id(self): + """ + + Returns: + + """ + profile = self.get_user_profile() + user_id = profile["id"] + + return user_id + + @staticmethod + def get_publication_url(publication: dict) -> str: + """ + Gets the publication url + + Args: + publication: + """ + custom_domain = publication.get("custom_domain", None) + if not custom_domain and not publication.get('custom_domain_optional', None): + publication_url = f"https://{publication['subdomain']}.substack.com" + else: + publication_url = f"https://{custom_domain}" + + return publication_url + + def get_user_primary_publication(self): + """ + Gets the users primary publication + """ + + profile = self.get_user_profile() + primary_publication = None + + # Try old API format first (backward compatibility) + if "primaryPublication" in profile and profile["primaryPublication"] is not None: + primary_publication = profile["primaryPublication"] + else: + # New API format: look for primary publication in publicationUsers + publication_users = profile.get("publicationUsers") + if publication_users is not None and len(publication_users) > 0: + # Find the publication where is_primary is True + for pub_user in publication_users: + if pub_user.get("is_primary", False): + primary_publication = pub_user.get("publication") + if primary_publication: + break + + # If no primary found, use the first publication + if primary_publication is None: + primary_publication = publication_users[0].get("publication") + + if primary_publication is None: + raise SubstackRequestException( + "Could not find primary publication in profile" + ) + + primary_publication["publication_url"] = self.get_publication_url( + primary_publication + ) + + return primary_publication + + def get_user_publications(self): + """ + Gets the users publications + """ + + profile = self.get_user_profile() + + # Loop through users "publicationUsers" list, and return a list + # of dictionaries of "name", and "subdomain", and "id" + user_publications = [] + publication_users = profile.get("publicationUsers") + + if publication_users is None: + # If publicationUsers is None, return empty list or try to construct from other fields + # This maintains backward compatibility while handling new API format + return user_publications + + for publication in publication_users: + pub = publication.get("publication") + if pub is not None: + pub["publication_url"] = self.get_publication_url(pub) + user_publications.append(pub) + + return user_publications + + def get_user_profile(self): + """ + Gets the users profile + """ + response = self._session.get(f"{self.base_url}/user/profile/self") + + return Api._handle_response(response=response) + + def get_user_settings(self): + """ + Get list of users. + + Returns: + + """ + response = self._session.get(f"{self.base_url}/settings") + + return Api._handle_response(response=response) + def get_publication_users(self): """ + Get list of users. + + Returns: - :return: """ response = self._session.get(f"{self.publication_url}/publication/users") return Api._handle_response(response=response) + def get_publication_subscriber_count(self): + + """ + Get subscriber count. + + Returns: + + """ + response = self._session.get( + f"{self.publication_url}/publication_launch_checklist" + ) + + return Api._handle_response(response=response)["subscriberCount"] + + def get_published_posts( + self, offset=0, limit=25, order_by="post_date", order_direction="desc" + ): + """ + Get list of published posts for the publication. + """ + response = self._session.get( + f"{self.publication_url}/post_management/published", + params={ + "offset": offset, + "limit": limit, + "order_by": order_by, + "order_direction": order_direction, + }, + ) + + return Api._handle_response(response=response) + def get_posts(self) -> dict: """ - :return: + Returns: + """ response = self._session.get(f"{self.base_url}/reader/posts") return Api._handle_response(response=response) def get_drafts(self, filter=None, offset=None, limit=None): + """ + + Args: + filter: + offset: + limit: + + Returns: + + """ response = self._session.get( f"{self.publication_url}/drafts", params={"filter": filter, "offset": offset, "limit": limit}, ) return Api._handle_response(response=response) + def get_draft(self, draft_id): + """ + Gets a draft given it's id. + + """ + response = self._session.get(f"{self.publication_url}/drafts/{draft_id}") + return Api._handle_response(response=response) + def delete_draft(self, draft_id): - response = self._session.delete( - f"{self.publication_url}/drafts/{draft_id}" - ) + """ + + Args: + draft_id: + + Returns: + + """ + response = self._session.delete(f"{self.publication_url}/drafts/{draft_id}") return Api._handle_response(response=response) def post_draft(self, body) -> dict: @@ -133,35 +414,19 @@ def post_draft(self, body) -> dict: response = self._session.post(f"{self.publication_url}/drafts", json=body) return Api._handle_response(response=response) - def put_draft( - self, - draft, - title=None, - subtitle=None, - body=None, - cover_image=None, - ) -> dict: + def put_draft(self, draft, **kwargs) -> dict: """ Args: - draft: draft id - title: - subtitle: - body: - cover_image: + draft: + **kwargs: Returns: """ - response = self._session.put( f"{self.publication_url}/drafts/{draft}", - json={ - "draft_title": title, - "draft_subtitle": subtitle, - "draft_body": body, - "cover_image": cover_image, - }, + json=kwargs, ) return Api._handle_response(response=response) @@ -181,7 +446,7 @@ def prepublish_draft(self, draft) -> dict: return Api._handle_response(response=response) def publish_draft( - self, draft, send: bool = True, share_automatically: bool = False + self, draft, send: bool = True, share_automatically: bool = False ) -> dict: """ @@ -211,7 +476,7 @@ def schedule_draft(self, draft, draft_datetime: datetime) -> dict: """ response = self._session.post( f"{self.publication_url}/drafts/{draft}/schedule", - json={"post_date": draft_datetime.isoformat()} + json={"post_date": draft_datetime.isoformat()}, ) return Api._handle_response(response=response) @@ -225,8 +490,7 @@ def unschedule_draft(self, draft) -> dict: """ response = self._session.post( - f"{self.publication_url}/drafts/{draft}/schedule", - json={"post_date": None} + f"{self.publication_url}/drafts/{draft}/schedule", json={"post_date": None} ) return Api._handle_response(response=response) @@ -247,9 +511,7 @@ def get_image(self, image: str): response = self._session.post( f"{self.publication_url}/image", - data={ - "image": image - }, + data={"image": image}, ) return Api._handle_response(response=response) @@ -265,12 +527,23 @@ def get_categories(self): return Api._handle_response(response=response) def get_category(self, category_id, category_type, page): - response = self._session.get(f"{self.base_url}/category/public/{category_id}/{category_type}", - params={"page": page}) + """ + + Args: + category_id: + category_type: + page: + + Returns: + + """ + response = self._session.get( + f"{self.base_url}/category/public/{category_id}/{category_type}", + params={"page": page}, + ) return Api._handle_response(response=response) - def get_single_category(self, category_id, category_type, page=None, - limit=None): + def get_single_category(self, category_id, category_type, page=None, limit=None): """ Args: @@ -290,17 +563,24 @@ def get_single_category(self, category_id, category_type, page=None, while True: page_output = self.get_category(category_id, category_type, page) publications.extend(page_output.get("publications", [])) - if (limit is not None and limit <= len(publications)) or not page_output.get("more", False): + if ( + limit is not None and limit <= len(publications) + ) or not page_output.get("more", False): publications = publications[:limit] break page += 1 output = { "publications": publications, - "more": page_output.get("more", False) + "more": page_output.get("more", False), } return output def delete_all_drafts(self): + """ + + Returns: + + """ response = None while True: drafts = self.get_drafts(filter="draft", limit=10, offset=0) @@ -309,3 +589,51 @@ def delete_all_drafts(self): for draft in drafts: response = self.delete_draft(draft.get("id")) return response + + def get_sections(self): + """ + Get a list of the sections of your publication. + + TODO: this is hacky but I cannot find another place where to get the sections. + Returns: + + """ + response = self._session.get( + f"{self.publication_url}/subscriptions", + ) + content = Api._handle_response(response=response) + sections = [ + p.get("sections") + for p in content.get("publications") + if p.get("hostname") in self.publication_url + ] + return sections[0] + + def publication_embed(self, url): + """ + + Args: + url: + + Returns: + + """ + return self.call("/publication/embed", "GET", url=url) + + def call(self, endpoint, method, **params): + """ + + Args: + endpoint: + method: + **params: + + Returns: + + """ + response = self._session.request( + method=method, + url=f"{self.publication_url}/{endpoint}", + params=params, + ) + return Api._handle_response(response=response) diff --git a/substack/exceptions.py b/substack/exceptions.py index 27a0301..e9b6f29 100644 --- a/substack/exceptions.py +++ b/substack/exceptions.py @@ -26,3 +26,7 @@ def __init__(self, message): def __str__(self): return f"SubstackRequestException: {self.message}" + + +class SectionNotExistsException(SubstackRequestException): + pass diff --git a/substack/post.py b/substack/post.py index 54a26a1..de262ee 100644 --- a/substack/post.py +++ b/substack/post.py @@ -1,18 +1,166 @@ +""" + +Post Utilities + +""" + import json -from typing import Dict +import re +from typing import Dict, List + +__all__ = ["Post", "parse_inline"] + +from substack.exceptions import SectionNotExistsException + + +def parse_inline(text: str) -> List[Dict]: + """ + Convert inline Markdown in a text string into a list of tokens + for use in the post content. + + Supported formatting: + - **Bold**: Text wrapped in double asterisks. + - *Italic*: Text wrapped in single asterisks. + - [Links]: Text wrapped in square brackets followed by URL in parentheses. + + Args: + text: Text string containing inline Markdown formatting. + + Returns: + List of token dictionaries with content and marks. + + Example: + >>> parse_inline("This is **bold** and this is [a link](https://example.com)") + [{'content': 'This is '}, {'content': 'bold', 'marks': [{'type': 'strong'}]}, {'content': ' and this is '}, {'content': 'a link', 'marks': [{'type': 'link', 'attrs': {'href': 'https://example.com'}}]}] + """ + if not text: + return [] + + tokens = [] + # Process text character by character to handle nested formatting + # We'll use regex to find all markdown patterns, then process them in order + + # Find all markdown patterns: links, bold, italic + # Pattern order: links first (to avoid conflicts), then bold, then italic + link_pattern = r'\[([^\]]+)\]\(([^)]+)\)' + bold_pattern = r'\*\*([^*]+)\*\*' + italic_pattern = r'(? 0 and text[match.start()-1:match.start()+1] != "![": + matches.append((match.start(), match.end(), "link", match.group(1), match.group(2))) + + for match in re.finditer(bold_pattern, text): + # Check if this range is already covered by a link + if not any(start <= match.start() < end for start, end, _, _, _ in matches): + matches.append((match.start(), match.end(), "bold", match.group(1), None)) + + for match in re.finditer(italic_pattern, text): + # Check if this range is already covered by a link or bold + if not any(start <= match.start() < end for start, end, _, _, _ in matches): + matches.append((match.start(), match.end(), "italic", match.group(1), None)) + + # Sort matches by position + matches.sort(key=lambda x: x[0]) + + # Build tokens + last_pos = 0 + for start, end, match_type, content, url in matches: + # Add text before this match + if start > last_pos: + tokens.append({"content": text[last_pos:start]}) + + # Add the formatted content + if match_type == "link": + tokens.append({ + "content": content, + "marks": [{"type": "link", "attrs": {"href": url}}] + }) + elif match_type == "bold": + tokens.append({ + "content": content, + "marks": [{"type": "strong"}] + }) + elif match_type == "italic": + tokens.append({ + "content": content, + "marks": [{"type": "em"}] + }) + + last_pos = end + + # Add remaining text + if last_pos < len(text): + tokens.append({"content": text[last_pos:]}) + + # Filter out empty tokens + tokens = [t for t in tokens if t.get("content")] + + return tokens class Post: + """ + + Post utility class - def __init__(self, title, subtitle, user_id): + """ + + def __init__( + self, + title: str, + subtitle: str, + user_id, + audience: str = None, + write_comment_permissions: str = None, + ): + """ + + Args: + title: + subtitle: + user_id: + audience: possible values: everyone, only_paid, founding, only_free + write_comment_permissions: none, only_paid, everyone (this field is a mess) + """ self.draft_title = title self.draft_subtitle = subtitle self.draft_body = {"type": "doc", "content": []} self.draft_bylines = [{"id": int(user_id), "is_guest": False}] + self.audience = audience if audience is not None else "everyone" + self.draft_section_id = None + self.section_chosen = True + + # TODO better understand the possible values and combinations with audience + if write_comment_permissions is not None: + self.write_comment_permissions = write_comment_permissions + else: + self.write_comment_permissions = self.audience + + def set_section(self, name: str, sections: list): + """ + + Args: + name: + sections: + + Returns: + + """ + section = [s for s in sections if s.get("name") == name] + if len(section) != 1: + raise SectionNotExistsException(name) + section = section[0] + self.draft_section_id = section.get("id") def add(self, item: Dict): """ + Add item to draft body. + Args: item: @@ -20,12 +168,20 @@ def add(self, item: Dict): """ - self.draft_body["content"] = self.draft_body.get("content", []) + [{"type": item.get("type")}] + self.draft_body["content"] = self.draft_body.get("content", []) + [ + {"type": item.get("type")} + ] content = item.get("content") if item.get("type") == "captionedImage": self.captioned_image(**item) + elif item.get("type") == "embeddedPublication": + self.draft_body["content"][-1]["attrs"] = item.get("url") elif item.get("type") == "youtube2": self.youtube(item.get("src")) + elif item.get("type") == "subscribeWidget": + self.subscribe_with_caption(item.get("message")) + elif item.get("type") == "codeBlock": + self.code_block(item.get("content"), item.get("attrs", {})) else: if content is not None: self.add_complex_text(content) @@ -40,12 +196,30 @@ def add(self, item: Dict): return self def paragraph(self, content=None): + """ + + Args: + content: + + Returns: + + """ item = {"type": "paragraph"} if content is not None: item["content"] = content return self.add(item) - def heading(self, content=None, level=1): + def heading(self, content=None, level: int = 1): + """ + + Args: + content: + level: + + Returns: + + """ + item = {"type": "heading"} if content is not None: item["content"] = content @@ -53,29 +227,43 @@ def heading(self, content=None, level=1): return self.add(item) def horizontal_rule(self): + """ + + Returns: + + """ return self.add({"type": "horizontal_rule"}) def attrs(self, level): + """ + + Args: + level: + + Returns: + + """ content_attrs = self.draft_body["content"][-1].get("attrs", {}) content_attrs.update({"level": level}) self.draft_body["content"][-1]["attrs"] = content_attrs return self - def captioned_image(self, - src: str, - fullscreen: bool = False, - imageSize: str = "normal", - height: int = 819, - width: int = 1456, - resizeWidth: int = 728, - bytes: str = None, - alt: str = None, - title: str = None, - type: str = None, - href: str = None, - belowTheFold: bool = False, - internalRedirect: str = None - ): + def captioned_image( + self, + src: str, + fullscreen: bool = False, + imageSize: str = "normal", + height: int = 819, + width: int = 1456, + resizeWidth: int = 728, + bytes: str = None, + alt: str = None, + title: str = None, + type: str = None, + href: str = None, + belowTheFold: bool = False, + internalRedirect: str = None, + ): """ Add image to body. @@ -97,26 +285,30 @@ def captioned_image(self, """ content = self.draft_body["content"][-1].get("content", []) - content += [{"type": "image2", "attrs": { - "src": src, - "fullscreen": fullscreen, - "imageSize": imageSize, - "height": height, - "width": width, - "resizeWidth": resizeWidth, - "bytes": bytes, - "alt": alt, - "title": title, - "type": type, - "href": href, - "belowTheFold": belowTheFold, - "internalRedirect": internalRedirect - - }}] + content += [ + { + "type": "image2", + "attrs": { + "src": src, + "fullscreen": fullscreen, + "imageSize": imageSize, + "height": height, + "width": width, + "resizeWidth": resizeWidth, + "bytes": bytes, + "alt": alt, + "title": title, + "type": type, + "href": href, + "belowTheFold": belowTheFold, + "internalRedirect": internalRedirect, + }, + } + ] self.draft_body["content"][-1]["content"] = content return self - def text(self, value): + def text(self, value: str): """ Add text to the last paragraph. @@ -133,52 +325,313 @@ def text(self, value): return self def add_complex_text(self, text): + """ + + Args: + text: + """ if isinstance(text, str): self.text(text) else: for chunk in text: if chunk: - self.text(chunk.get("content")).marks(chunk.get("marks")) + self.text(chunk.get("content")).marks(chunk.get("marks", [])) def marks(self, marks): + """ + + Args: + marks: + + Returns: + + """ content = self.draft_body["content"][-1].get("content", [])[-1] content_marks = content.get("marks", []) for mark in marks: new_mark = {"type": mark.get("type")} if mark.get("type") == "link": href = mark.get("href") - new_mark.update({"attrs": { - "href": href - }}) + new_mark.update({"attrs": {"href": href}}) content_marks.append(new_mark) content["marks"] = content_marks return self def remove_last_paragraph(self): + """Remove last paragraph""" del self.draft_body.get("content")[-1] def get_draft(self): + """ + + Returns: + + """ out = vars(self) out["draft_body"] = json.dumps(out["draft_body"]) return out - def subscribe_with_caption(self, value): - content = self.draft_body["content"][-1].get("content", []) - content += [{"type": "subscribeWidget", - "attrs": {"url": "%%checkout_url%%", "text": "Subscribe"}, - "content": [ - { - "type": "ctaCaption", - "content": [{"type": "text", - "text": f"""Thanks for reading {value}! - Subscribe for free to receive new posts and support my work."""}] - } - ]}] - self.draft_body["content"][-1]["content"] = content + def subscribe_with_caption(self, message: str = None): + """ + + Add subscribe widget with caption + + Args: + message: + + Returns: + + """ + + if message is None: + message = """Thanks for reading this newsletter! + Subscribe for free to receive new posts and support my work.""" + + subscribe = self.draft_body["content"][-1] + subscribe["attrs"] = { + "url": "%%checkout_url%%", + "text": "Subscribe", + "language": "en", + } + subscribe["content"] = [ + { + "type": "ctaCaption", + "content": [ + { + "type": "text", + "text": message, + } + ], + } + ] return self - def youtube(self, value): + def youtube(self, value: str): + """ + + Add youtube video to post. + + Args: + value: youtube url + + Returns: + + """ content_attrs = self.draft_body["content"][-1].get("attrs", {}) content_attrs.update({"videoId": value}) self.draft_body["content"][-1]["attrs"] = content_attrs return self + + def code_block(self, content, attrs=None): + """ + Add code block to post. + + Args: + content: String containing code or list of text nodes + attrs: Optional attributes like language + + Returns: + + """ + if attrs is None: + attrs = {} + + # Handle content - can be list of text nodes or a string + if isinstance(content, str): + # Convert string to list of text nodes + code_content = [{"type": "text", "text": content}] + elif isinstance(content, list): + code_content = content + else: + code_content = [] + + # Set up the code block structure + code_block = self.draft_body["content"][-1] + code_block["content"] = code_content + if attrs: + code_block["attrs"] = attrs + + return self + + def from_markdown(self, markdown_content: str, api=None): + """ + Parse Markdown content and add it to the post. + + Supported Markdown features: + - Headings: Lines starting with '#' characters (1-6 levels) + - Images: Markdown image syntax ![Alt](URL) + - Linked images: [![Alt](image_url)](link_url) - images that are also links + - Links: [text](url) - inline links in paragraphs + - Code blocks: Fenced code blocks with ```language or ``` + - Paragraphs: Regular text blocks + - Bullet lists: Lines starting with '*' or '-' + - Inline formatting: **bold** and *italic* within paragraphs + + Args: + markdown_content: Markdown string to parse and add to the post. + api: Optional Api instance for uploading local images. If provided, + local image paths will be uploaded via api.get_image(). + + Returns: + Self for method chaining. + + Example: + >>> post = Post("Title", "Subtitle", user_id) + >>> post.from_markdown("# Heading\\n\\nThis is **bold** text with [a link](https://example.com).") + """ + lines = markdown_content.split("\n") + blocks = [] + current_block: List[str] = [] + in_code_block = False + code_block_language = None + + for line in lines: + # Check for fenced code block start/end + if line.strip().startswith("```"): + if in_code_block: + # End of code block + if current_block: + blocks.append({ + "type": "code", + "language": code_block_language, + "content": "\n".join(current_block) + }) + current_block = [] + in_code_block = False + code_block_language = None + else: + # Start of code block + if current_block: + blocks.append({"type": "text", "content": "\n".join(current_block)}) + current_block = [] + # Extract language if specified + language = line.strip()[3:].strip() + code_block_language = language if language else None + in_code_block = True + continue + + if in_code_block: + # Inside code block - collect lines as-is + current_block.append(line) + else: + # Regular content + if line.strip() == "": + # Empty line - end current block if it has content + if current_block: + blocks.append({"type": "text", "content": "\n".join(current_block)}) + current_block = [] + else: + current_block.append(line) + + # Add any remaining content + if current_block: + if in_code_block: + blocks.append({ + "type": "code", + "language": code_block_language, + "content": "\n".join(current_block) + }) + else: + blocks.append({"type": "text", "content": "\n".join(current_block)}) + + # Process blocks + for block in blocks: + if block["type"] == "code": + # Add code block + code_content = block.get("content", "").strip() + if code_content: + # Substack uses "codeBlock" type + code_attrs = {} + if block.get("language"): + code_attrs["language"] = block["language"] + self.add({ + "type": "codeBlock", + "content": code_content, # Pass as string, code_block method will handle it + "attrs": code_attrs + }) + else: + # Process text block + text_content = block.get("content", "").strip() + if not text_content: + continue + + # Process headings (lines starting with '#' characters) + if text_content.startswith("#"): + level = len(text_content) - len(text_content.lstrip("#")) + heading_text = text_content.lstrip("#").strip() + if heading_text: # Only add if there's actual text + self.heading(content=heading_text, level=min(level, 6)) + + # Process images using Markdown image syntax: ![Alt](URL) + # Also handle linked images: [![Alt](image_url)](link_url) + elif text_content.startswith("!") or (text_content.startswith("[") and "![" in text_content): + # Check for linked image first: [![alt](img)](link) + linked_image_match = re.match(r'\[!\[([^\]]*)\]\(([^)]+)\)\]\(([^)]+)\)', text_content) + if linked_image_match: + # Linked image - create image with href + alt_text = linked_image_match.group(1) + image_url = linked_image_match.group(2) + link_url = linked_image_match.group(3) + + # Adjust image URL if it starts with a slash + image_url = image_url[1:] if image_url.startswith("/") else image_url + + # If api is provided and image_url is a local file, upload it + if api is not None: + try: + image = api.get_image(image_url) + image_url = image.get("url") + except Exception: + # If upload fails, use original URL + pass + + self.add({ + "type": "captionedImage", + "src": image_url, + "alt": alt_text, + "href": link_url + }) + else: + # Regular image: ![Alt](URL) + match = re.match(r"!\[.*?\]\((.*?)\)", text_content) + if match: + image_url = match.group(1) + # Adjust image URL if it starts with a slash + image_url = image_url[1:] if image_url.startswith("/") else image_url + + # If api is provided and image_url is a local file, upload it + if api is not None: + try: + image = api.get_image(image_url) + image_url = image.get("url") + except Exception: + # If upload fails, use original URL + pass + + self.add({"type": "captionedImage", "src": image_url}) + + # Process paragraphs or bullet lists + else: + if "\n" in text_content: + # Process each line separately (for bullet lists) + for line in text_content.split("\n"): + line = line.strip() + if not line: + continue + # Remove bullet marker if present + if line.startswith("* "): + line = line[2:].strip() + elif line.startswith("- "): + line = line[2:].strip() + elif line.startswith("*") and not line.startswith("**"): + line = line[1:].strip() + + if line: + tokens = parse_inline(line) + self.add({"type": "paragraph", "content": tokens}) + else: + # Single paragraph + tokens = parse_inline(text_content) + self.add({"type": "paragraph", "content": tokens}) + + return self diff --git a/tests/substack/test_api.py b/tests/substack/test_api.py index e0cadf6..0d76597 100644 --- a/tests/substack/test_api.py +++ b/tests/substack/test_api.py @@ -18,7 +18,6 @@ def test_login(self): api = Api( email=os.getenv("EMAIL"), password=os.getenv("PASSWORD"), - publication_url=os.getenv("PUBLICATION_URL"), ) self.assertIsNotNone(api) @@ -31,7 +30,6 @@ def test_get_drafts(self): api = Api( email=os.getenv("EMAIL"), password=os.getenv("PASSWORD"), - publication_url=os.getenv("PUBLICATION_URL"), ) drafts = api.get_drafts() self.assertIsNotNone(drafts) @@ -40,7 +38,6 @@ def test_post_draft(self): api = Api( email=os.getenv("EMAIL"), password=os.getenv("PASSWORD"), - publication_url=os.getenv("PUBLICATION_URL"), ) posted_draft = api.post_draft([{"id": os.getenv("USER_ID"), "is_guest": False}]) self.assertIsNotNone(posted_draft) @@ -49,7 +46,6 @@ def test_publication_users(self): api = Api( email=os.getenv("EMAIL"), password=os.getenv("PASSWORD"), - publication_url=os.getenv("PUBLICATION_URL"), ) users = api.get_publication_users() self.assertIsNotNone(users) @@ -58,7 +54,6 @@ def test_put_draft(self): api = Api( email=os.getenv("EMAIL"), password=os.getenv("PASSWORD"), - publication_url=os.getenv("PUBLICATION_URL"), ) posted_draft = api.put_draft("") self.assertIsNotNone(posted_draft)