-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
54 lines (43 loc) · 1.6 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import os
import sys
from dotenv import load_dotenv
from lib.content import generate_content, guess_title
from lib.instagram import publish
from lib.image_generator import generate_image
from lib.post_generator import generate_post, generate_image_post
arguments = sys.argv
if len(arguments) < 2:
params = ""
elif len(arguments) == 2:
params = arguments[1]
else:
params = arguments[1:]
def generate_post_content():
if type(params) != list:
print("Generating content for you!")
post_text = generate_content()
post_title = guess_title(post_text).upper()
post_subtitle = guess_title(post_text).title()
else:
post_title = params[0].upper()
post_subtitle = params[1].title()
post_text = params[2]
print(f"Title: {post_title}")
print(f"Subtitle: {post_subtitle}")
print(f"Text: {post_text}")
return [post_title, post_subtitle, post_text]
if __name__ == '__main__':
if params == "publish":
print("Publishing post on Instagram")
publish()
elif params == "template":
[post_title, post_subtitle, post_text] = generate_post_content()
print("Generating Instagram post")
generate_post(post_title, post_subtitle, post_text)
else:
[post_title, post_subtitle, post_text] = generate_post_content()
image_flavour = os.environ.get('IMAGE_FLAVOUR') or "Cosmic spiritual"
print(f"Generating {image_flavour} image for post")
generate_image(f"{image_flavour} {post_title} {post_subtitle}")
print("Generating Instagram post")
generate_image_post(post_text)