43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
import os, sys
|
|
|
|
from sqlalchemy import create_engine
|
|
from instagrapi import Client
|
|
# from dotenv import load_dotenv
|
|
|
|
from utils import shareclass
|
|
from ig import IG
|
|
from db import pgclass
|
|
from grpc import grpcServer
|
|
from utils.const import DEBUG
|
|
|
|
# load_dotenv()
|
|
|
|
# Database
|
|
PG_HOST = os.environ.get("PG_HOST", None).strip()
|
|
PG_PORT = os.environ.get("PG_PORT", None).strip()
|
|
PG_NAME = os.environ.get("PG_NAME", None).strip()
|
|
PG_USER = os.environ.get("PG_USER", None).strip()
|
|
PG_PASS = os.environ.get("PG_PASS", None).strip()
|
|
engine = create_engine('postgresql+psycopg2://%s:%s@%s:%s/%s'%(PG_USER, PG_PASS, PG_HOST, PG_PORT, PG_NAME))
|
|
pgclass.Base.metadata.create_all(engine)
|
|
print("[V] Database Connected")
|
|
|
|
# IG Login
|
|
cl = Client()
|
|
shareclass.Shared(cl, engine) # Shared Class
|
|
if not DEBUG and not IG.login():
|
|
sys.exit(0)
|
|
|
|
# grpc server should have...
|
|
# - Get account info (a kind of checkalive)
|
|
# - Get media info (a kind of checkalive)
|
|
# - Upload media (預設客戶端給我id)
|
|
# - Delete media
|
|
# - Login
|
|
|
|
# IG統一保存code
|
|
|
|
# run grpc
|
|
if __name__ == "__main__":
|
|
grpcServer.serve()
|