From cd94bafc4af1d20892ebbe39c81916cd21be6f1c Mon Sep 17 00:00:00 2001 From: Jaton Justice Date: Sun, 18 Feb 2024 08:38:41 -0800 Subject: [PATCH] setup database structure --- apis/meta.py | 26 ++++++++++----------- config.yaml | 6 +++++ controller.py => controller/__init__.py | 0 database.sqlite3 | Bin 0 -> 36864 bytes scheduler.py | 29 +++++++++++++++++++++++- scheduler/win_scheduler.py | 0 6 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 config.yaml rename controller.py => controller/__init__.py (100%) create mode 100644 database.sqlite3 create mode 100644 scheduler/win_scheduler.py diff --git a/apis/meta.py b/apis/meta.py index 3b431ee..77de77b 100644 --- a/apis/meta.py +++ b/apis/meta.py @@ -1,5 +1,5 @@ import datetime -import awss3 +from apis import awss3 import requests import os @@ -8,39 +8,39 @@ This module is used to post pictures to Instagram and Facebook using the Facebook Graph API. # Variables required: -- ig_id: The Instagram account ID +- meta_id: The Instagram account ID - ig_access_token: The Instagram access token - method_of_access: The method of access to the pictures (aws or local) """ -def create_container(access_token, image_url, account, description, tags): +def create_container(meta_access_token, image_url, meta_id, description, tags): hashtags = " ".join([f"#{tag}" for tag in tags.split()]) caption = f"{description}\n\n{hashtags}" - url = f'https://graph.facebook.com/v17.0/{account}/media' + url = f'https://graph.facebook.com/v17.0/{meta_id}/media' payload = { "image_url": image_url, "caption": caption, - "access_token": access_token + "access_token": meta_access_token } response = requests.post(url, params=payload) data = response.json() print(data) return data["id"] -def publish_media(access_token, account, creation_id): - url = f'https://graph.facebook.com/v17.0/{account}/media_publish' +def publish_media(meta_access_token, meta_id, creation_id): + url = f'https://graph.facebook.com/v17.0/{meta_id}/media_publish' payload = { "creation_id": creation_id, - "access_token": access_token + "access_token": meta_access_token } response = requests.post(url, params=payload) data = response.json() print(data) -def PostToIG(ig_id, ig_access_token, method_of_access, base_url=None, image_data=None): +def PostToIG(meta_id, ig_access_token, method_of_access, base_url=None, image_data=None): if method_of_access == "aws": today = datetime.datetime.now() folder_name = today.strftime("%Y-%m-%d") # Use the current date as the folder name @@ -49,8 +49,8 @@ def PostToIG(ig_id, ig_access_token, method_of_access, base_url=None, image_data for file_name in image_files: image_url, description, tags = awss3.generate_url(file_name) - creation_id = create_container(ig_access_token, image_url, ig_id, description, tags) - publish_media(ig_access_token, ig_id, creation_id) + creation_id = create_container(ig_access_token, image_url, meta_id, description, tags) + publish_media(ig_access_token, meta_id, creation_id) elif method_of_access == "local": for image_info in image_data: # image_data is a list of dicts with image info @@ -59,7 +59,7 @@ def PostToIG(ig_id, ig_access_token, method_of_access, base_url=None, image_data description = image_info['description'] tags = image_info['tags'] - creation_id = create_container(ig_access_token, image_url, ig_id, description, tags) - publish_media(ig_access_token, ig_id, creation_id) + creation_id = create_container(ig_access_token, image_url, meta_id, description, tags) + publish_media(ig_access_token, meta_id, creation_id) return "Pictures posted to IG successfully!" \ No newline at end of file diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..310ad29 --- /dev/null +++ b/config.yaml @@ -0,0 +1,6 @@ +# Default Settings configuration +DefaultSettings: + mode: local + photo_path: "" + video_path: "" + diff --git a/controller.py b/controller/__init__.py similarity index 100% rename from controller.py rename to controller/__init__.py diff --git a/database.sqlite3 b/database.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..c02ed45aeebe2df75f247e9744040de6bdbe15f8 GIT binary patch literal 36864 zcmeI*-)`Dg90zbaBq6Y7RGKQ(<)WuIOVE;ye}T|mYz7R008aSRHfR%azz~-h12!b? zU7B^5eS^Kt9$@!-fNHn9sCKzy2Ta`1Hkw+gtG=`j@%iU-KIeCAtU{?A6l7f@ZFQ)K zI*Bm18J1;!B!poYiEf_B#?t3+=(b3=>BCHW-$P=)Ypkt$e`ee(uNdE+@3${2tJ1Bn zS6+EvdSAY;GV&n+0SG_<0ucCs0`z+PxBuZo_W4K`k4_|Qa6(@LX!@uns|{UJ`i*xb zds1bdtMa7EB?~-xOWh4GAx*WXOFg|Iw@9v3-J~faO&VU=ofgoIzC^106RXTLu_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