mirror of
https://github.com/Horhik/Instagram2Fedi.git
synced 2024-11-22 00:11:26 +00:00
add more environment variables
This commit is contained in:
parent
497d04ad2d
commit
43d2ea6c01
16
Dockerfile
16
Dockerfile
|
@ -7,6 +7,20 @@ RUN pip install colorama
|
|||
COPY . /app
|
||||
WORKDIR /app
|
||||
|
||||
ENV USE_DOCKER=1
|
||||
ENV YOUR_CONTAINER_NAME="$YOUR_CONTAINER_NAME"
|
||||
ENV I2M_INSTAGRAM_USER="$I2M_INSTAGRAM_USER"
|
||||
ENV I2M_INSTANCE="$I2M_INSTANCE"
|
||||
ENV I2M_TOKEN="$I2M_TOKEN"
|
||||
|
||||
|
||||
ENV I2M_CHECK_INTERVAL "$I2M_CHECK_INTERVAL"
|
||||
ENV I2M_POST_INTERVAL "$I2M_POST_INTERVAL"
|
||||
ENV I2M_USE_MASTODON "$I2M_USE_MASTODON"
|
||||
ENV I2M_FETCH_COUNT "$I2M_FETCH_COUNT"
|
||||
|
||||
|
||||
|
||||
#ENTRYPOINT ["python", "/app/src/main.py", "--instagram-user", I2M_INSTAGRAM_USER, "--instance", I2M_INSTANCE, "--token", I2M_TOKEN, "--check-interval", I2M_CHECK_INTERVAL, "--post-interval", I2M_POST_INTERVAL, "--fetch-count", I2M_FETCH_COUNT, "--use-mastodon", I2M_USE_MASTODON]
|
||||
#ENTRYPOINT ["echo", "--instagram-user", I2M_INSTAGRAM_USER, "--instance", I2M_INSTANCE, "--token", I2M_TOKEN, "--check-interval", I2M_CHECK_INTERVAL, "--post-interval", I2M_POST_INTERVAL, "--fetch-count", I2M_FETCH_COUNT, "--use-mastodon", I2M_USE_MASTODON]
|
||||
ENTRYPOINT ["python", "/app/src/main.py"]
|
||||
|
||||
|
|
16
docker-compose.yaml
Normal file
16
docker-compose.yaml
Normal file
|
@ -0,0 +1,16 @@
|
|||
version: '3'
|
||||
services:
|
||||
bot:
|
||||
build:
|
||||
context: .
|
||||
image: "horhik/instagram2fedi:latest"
|
||||
environment:
|
||||
- YOUR_CONTAINER_NAME=innubis_crossposter
|
||||
- I2M_INSTAGRAM_USER=innubis
|
||||
- I2M_INSTANCE=mastodon.ml
|
||||
- I2M_TOKEN=y-Sz4sICYGwEkTI5UJz2U-58hvjGXec61YSLo2zascQ
|
||||
- I2M_CHECK_INTERVAL=3600 #1 hour
|
||||
- I2M_POST_INTERVAL=3600 #1 hour
|
||||
- I2M_USE_MASTODON=4 #max carouse - is 4, if there's no limit set to -1
|
||||
- I2M_FETCH_COUNT=5 # how many instagram posts to fetch per check_interval -
|
||||
|
|
@ -1,36 +1,49 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import datetime
|
||||
from colorama import Fore, Back, Style
|
||||
|
||||
|
||||
instagram_user = os.environ.get("I2M_INSTAGRAM_USER")
|
||||
instance = os.environ.get("I2M_INSTANCE")
|
||||
token = os.environ.get("I2M_TOKEN")
|
||||
check_interval = os.environ.get("I2M_CHECK_INTERVAL") #1 hour
|
||||
post_interval = os.environ.get("I2M_POST_INTERVAL") #1 hour
|
||||
use_mastodon = os.environ.get("I2M_USE_MASTODON") #max carouse is 4, if there's no limit set to -1
|
||||
fetch_count = os.environ.get("I2M_FETCH_COUNT") # how many instagram posts to fetch per check_interval
|
||||
print('instagram', instagram_user)
|
||||
print('instagram', instance)
|
||||
print(token)
|
||||
print(check_interval)
|
||||
print(post_interval)
|
||||
print(use_mastodon)
|
||||
print(fetch_count)
|
||||
|
||||
|
||||
|
||||
|
||||
def process_arguments(args, defaults):
|
||||
count = 1
|
||||
while (len(args) > count):
|
||||
if(args[count] == "--instance"):
|
||||
defaults["instance"] = args[count + 1]
|
||||
elif (args[count] == "--instagram-user"):
|
||||
defaults["instagram-user"] = args[count + 1]
|
||||
if(instance):
|
||||
defaults["instance"] = instance
|
||||
elif (instagram_user):
|
||||
defaults["instagram-user"] = instagram_user
|
||||
elif (token):
|
||||
defaults["token"] = token
|
||||
|
||||
elif (args[count] == "--token"):
|
||||
defaults["token"] = args[count + 1]
|
||||
elif (check_interval):
|
||||
defaults["check-interval"] = check_interval
|
||||
|
||||
elif (args[count] == "--check-interval"):
|
||||
defaults["check-interval"] = int(args[count + 1])
|
||||
elif (post_interval):
|
||||
defaults["post-interval"] = post_interval
|
||||
|
||||
elif (args[count] == "--post-interval"):
|
||||
defaults["post-interval"] = int(args[count + 1])
|
||||
elif (fetch_count):
|
||||
defaults["fetch-count"] = fetch_count
|
||||
|
||||
elif (args[count] == "--fetch-count"):
|
||||
defaults["fetch-count"] = int(args[count + 1])
|
||||
|
||||
elif (args[count] == "--use-mastodon"):
|
||||
defaults["carousel-limit"] = int(args[count + 1])
|
||||
elif (args[count] == "--use-docker"):
|
||||
defaults["use-docker"] = args[count + 1]
|
||||
|
||||
else:
|
||||
print(Fore.RED + '❗ -> Wrong Argument Name!...')
|
||||
print(Style.RESET_ALL)
|
||||
print(datetime.datetime.now())
|
||||
|
||||
count +=2
|
||||
elif (use_mastodon):
|
||||
defaults["carousel-limit"] = use_mastodon
|
||||
else:
|
||||
print(Fore.RED + '❗ -> Missing Argument ')
|
||||
print(Style.RESET_ALL)
|
||||
print(datetime.datetime.now())
|
||||
return defaults
|
||||
|
||||
|
|
|
@ -24,15 +24,14 @@ default_settings = {
|
|||
"post-interval": 3600,
|
||||
"fetch-count" : 10,
|
||||
"carousel-limit": 4,
|
||||
"use-docker": True
|
||||
}
|
||||
|
||||
settings = process_arguments(sys.argv, default_settings)
|
||||
|
||||
print(settings)
|
||||
print('FINAL SETTINGS' , settings)
|
||||
|
||||
agree = [1, True, "true", "True", "yes", "Yes"]
|
||||
if (agree.count(settings["use-docker"])):
|
||||
if (os.environ.get("USE_DOCKER")):
|
||||
id_filename = "/app/already_posted.txt"
|
||||
else:
|
||||
id_filename = "./already_posted.txt"
|
||||
|
|
Loading…
Reference in a new issue