mirror of
https://github.com/Horhik/Instagram2Fedi.git
synced 2024-11-22 08:11:26 +00:00
some updates
This commit is contained in:
parent
eaadf55a02
commit
9ddfab49d4
38
src/arguments.py
Normal file
38
src/arguments.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
from colorama import Fore, Back, Style
|
||||
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]
|
||||
|
||||
elif (args[count] == "--token"):
|
||||
defaults["token"] = args[count + 1]
|
||||
|
||||
elif (args[count] == "--check-interval"):
|
||||
defaults["check-interval"] = args[count + 1]
|
||||
|
||||
elif (args[count] == "--post-interval"):
|
||||
defaults["post-interval"] = args[count + 1]
|
||||
|
||||
elif (args[count] == "--fetch-count"):
|
||||
defaults["fetch-count"] = args[count + 1]
|
||||
|
||||
elif (args[count] == "--using-mastodon"):
|
||||
defaults["carousel-limit"] = int(args[count + 1])
|
||||
|
||||
else:
|
||||
print(Fore.RED + '❗ -> Wrong Argument Name!...')
|
||||
print(Style.RESET_ALL)
|
||||
|
||||
count +=2
|
||||
return defaults
|
||||
|
||||
#fuck this shit im out''
|
||||
#teenagers scare the living shit out of me
|
||||
#deeeespaaaacito quero esperanto de despacito
|
||||
#хорошо всё будет хорошо
|
||||
#и камнем вниииз
|
||||
#u kinda smell *smif* like a BAKA
|
||||
#Yeren Yegaaaaaaa!!!!!!!!!
|
35
src/main.py
35
src/main.py
|
@ -5,23 +5,42 @@ import json
|
|||
from mastodon import Mastodon
|
||||
from colorama import Fore, Back, Style
|
||||
from instaloader import Profile, Instaloader, LatestStamps
|
||||
from arguments import process_arguments
|
||||
|
||||
|
||||
from network import get_new_posts
|
||||
|
||||
|
||||
id_filename = "/app/already_posted.txt"
|
||||
with open(id_filename, "a") as f:
|
||||
f.write("\n")
|
||||
|
||||
fetched_user = sys.argv[1]
|
||||
mastodon_instance = sys.argv[2]
|
||||
mastodon_token = sys.argv[3]
|
||||
print(sys.argv)
|
||||
print("ARGUMENTS")
|
||||
default_settings = {
|
||||
"instance": None,
|
||||
"instagram-user": None,
|
||||
"token": None,
|
||||
"check-interval": 3600,
|
||||
"post-interval": 3600,
|
||||
"fetch-count" : 10,
|
||||
"carousel-limit": 4
|
||||
}
|
||||
|
||||
post_limit = 1
|
||||
time_interval_sec = 86400
|
||||
post_interval = 10
|
||||
settings = process_arguments(sys.argv, default_settings)
|
||||
|
||||
using_mastodon = True;
|
||||
mastodon_carousel_size = 4
|
||||
print(settings)
|
||||
|
||||
fetched_user = settings["instagram-user"]
|
||||
mastodon_instance = settings["instance"]
|
||||
mastodon_token = settings["token"]
|
||||
|
||||
post_limit = settings["fetch-count"]
|
||||
time_interval_sec = settings["check-interval"] #1d
|
||||
post_interval = settings["post-interval"]#1m
|
||||
|
||||
using_mastodon = settings["carousel-limit"] > 0;
|
||||
mastodon_carousel_size = settings["carousel-limit"]
|
||||
|
||||
print(Fore.GREEN + '🚀 > Connecting to Instagram...')
|
||||
print(Style.RESET_ALL)
|
||||
|
|
|
@ -44,8 +44,9 @@ def toot(urls, title, mastodon, fetched_user ):
|
|||
ids.append(upload_image_to_mastodon(url, mastodon))
|
||||
post_text = str(title) + "\n" + "crosposted from https://instagram.com/"+fetched_user # creating post text
|
||||
post_text = post_text[0:1000]
|
||||
print(ids)
|
||||
mastodon.status_post(post_text, media_ids = ids)
|
||||
if(ids):
|
||||
print(ids)
|
||||
mastodon.status_post(post_text, media_ids = ids)
|
||||
|
||||
except Exception as e:
|
||||
print(Fore.RED + "😿 > Failed to create toot \n", e)
|
||||
|
@ -69,7 +70,6 @@ def get_new_posts(mastodon, profile, mastodon_carousel_size, post_limit, already
|
|||
toot(urls, post.caption, mastodon, fetched_user)
|
||||
else:
|
||||
toot(url_arr, post.caption, mastodon, fetched_user)
|
||||
|
||||
mark_as_posted(str(post.mediaid), already_posted_path)
|
||||
time.sleep(post_interval)
|
||||
else:
|
||||
|
|
4
src/requipments.txt
Normal file
4
src/requipments.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
pyparsing==2.4.7
|
||||
tqdm==4.62.2
|
||||
urllib3==1.26.6
|
||||
colorama==
|
Loading…
Reference in a new issue