Blogen-V0.1 Added features. WIP

This commit is contained in:
AjaySi
2023-11-24 15:26:40 +05:30
parent 3ec74d22b5
commit 991a717a4e
5 changed files with 70 additions and 221 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 MiB

View File

@@ -41,9 +41,9 @@ image_dir = os.path.join(os.getcwd(), image_dir)
# TBD: This can come from config file.
output_path = "pseo_website/_posts/"
output_path = os.path.join(os.getcwd(), output_path)
wordpress_url = 'https://latestaitools.in/'
wordpress_username = 'upaudel750'
wordpress_password = 'YvCS VbzQ QSp8 4XZe 0DUw Myys'
wordpress_url = ''
wordpress_username = ''
wordpress_password = ''
def generate_youtube_blog(yt_url_list):

View File

@@ -1,73 +0,0 @@
# WIP - Work in Progress
## Required Python third-party packages
- requests==2.26.0
- pytest==6.2.5
- json==2.0.9
## Logic Analysis
- ['main.py', 'Main']
- ['wordpress_api.py', 'WordpressAPI']
- ['test_wordpress_api.py', 'TestWordpressAPI']
## Task list
'main.py' contains the main entry point of the program.
'wordpress_api.py' contains the implementation of the WordpressAPI class, which handles the integration with the Wordpress API.
'test_wordpress_api.py' contains unit tests for the WordpressAPI class.
## Implementation approach
To implement the wordpress API integration module, we will use the requests library, which is a popular open-source library for making HTTP requests in Python. This library provides a simple and intuitive way to send HTTP requests and handle responses. We will also use the json library to handle JSON data. Additionally, we will write unit tests using the pytest framework to ensure the functionality and quality of the module. The module will be designed to be easily integrated into existing Python codebases by providing clear usage instructions and documentation.
## Python package name
wordpress_api_integration
## File list
- main.py
- wordpress_api.py
- test_wordpress_api.py
## Data structures and interface definitions
classDiagram
class WordpressAPI{
+str base_url
+str username
+str password
+str token
+str authenticate()
+str upload_content(str content)
}
WordpressAPI "1" -- "1" Authentication: has
WordpressAPI "1" -- "1" ContentUpload: has
class Authentication{
+str authenticate()
}
class ContentUpload{
+str upload_content(str content)
}
## Program call flow
sequenceDiagram
participant M as Main
participant WP as WordpressAPI
participant A as Authentication
participant CU as ContentUpload
M->>WP: Create WordpressAPI instance
WP->>A: Create Authentication instance
A->>WP: Authenticate
WP->>CU: Create ContentUpload instance
CU->>WP: Upload content

View File

@@ -1,48 +0,0 @@
import requests
import json
def upload_blog_post(wix_site_id, wix_api_key, blog_post_title, blog_post_content):
""" Uploads a blog post to a Wix website.
Args:
wix_site_id: The ID of the Wix website.
wix_api_key: The API key for the Wix website.
blog_post_title: The title of the blog post.
blog_post_content: The content of the blog post.
Returns:
None.
"""
# Create the request body.
request_body = {
"title": blog_post_title,
"content": blog_post_content
}
# Make the request to the Wix API.
response = requests.post(
f"https://{wix_site_id}.wixsite.com/api/v1/blog/posts",
headers={"Authorization": f"Bearer {wix_api_key}"},
json=request_body
)
# Check the response status code.
if response.status_code != 200:
raise Exception(f"Failed to upload blog post: {response.status_code}")
# Print a success message.
print("Blog post uploaded successfully!")
###########################################################################################
# Example usage:
wix_site_id = ""
wix_api_key = ""
blog_post_title = "My first blog post"
blog_post_content = "This is my first blog post."
upload_blog_post(wix_site_id, wix_api_key, blog_post_title, blog_post_content)