mirror of
https://github.com/Horhik/Instagram2Fedi.git
synced 2025-01-15 05:16:40 +00:00
add time in logging and remove some shit
This commit is contained in:
parent
535ea46f24
commit
4847a5e870
|
@ -1,4 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
from colorama import Fore, Back, Style
|
||||
def process_arguments(args, defaults):
|
||||
count = 1
|
||||
|
@ -28,14 +29,8 @@ def process_arguments(args, defaults):
|
|||
else:
|
||||
print(Fore.RED + '❗ -> Wrong Argument Name!...')
|
||||
print(Style.RESET_ALL)
|
||||
print(datetime.datetime.now())
|
||||
|
||||
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!!!!!!!!!
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from colorama import Fore, Back, Style
|
||||
import datetime
|
||||
|
||||
def split_array(arr, size):
|
||||
count = len(arr) // size + 1
|
||||
|
@ -15,9 +16,10 @@ def try_to_get_carousel(array, post):
|
|||
return urls
|
||||
print(Fore.GREEN + "🎠 > Found carousel!")
|
||||
print(Style.RESET_ALL)
|
||||
print(datetime.datetime.now())
|
||||
except Exception as e:
|
||||
print(Fore.RED + "🎠💥 > No carousel :( \n", e)
|
||||
print(Style.RESET_ALL)
|
||||
print(datetime.datetime.now())
|
||||
return array
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import os
|
||||
import sys
|
||||
import time
|
||||
import datetime
|
||||
import json
|
||||
from mastodon import Mastodon
|
||||
from colorama import Fore, Back, Style
|
||||
|
@ -53,12 +54,14 @@ mastodon_carousel_size = settings["carousel-limit"]
|
|||
|
||||
print(Fore.GREEN + '🚀 > Connecting to Instagram...')
|
||||
print(Style.RESET_ALL)
|
||||
print(datetime.datetime.now())
|
||||
|
||||
L = Instaloader()
|
||||
profile = Profile.from_username(L.context, fetched_user)
|
||||
|
||||
print(Fore.GREEN + '🚀 > Connecting to Mastodon/Pixelfed...')
|
||||
print(Style.RESET_ALL)
|
||||
print(datetime.datetime.now())
|
||||
mastodon = Mastodon(
|
||||
access_token = mastodon_token,
|
||||
api_base_url = mastodon_instance
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from colorama import Fore, Back, Style
|
||||
import requests
|
||||
import time
|
||||
import datetime
|
||||
from already_posted import already_posted, mark_as_posted
|
||||
from converters import split_array, try_to_get_carousel
|
||||
import hashlib
|
||||
|
@ -10,36 +11,43 @@ def get_image(url):
|
|||
try:
|
||||
print(Fore.YELLOW + "🚀 > Downloading Image...", url)
|
||||
print(Style.RESET_ALL)
|
||||
print(datetime.datetime.now())
|
||||
|
||||
response = requests.get(url)
|
||||
response.raw.decode_content = True
|
||||
|
||||
print(Fore.GREEN + "✨ > Downloaded!")
|
||||
print(Style.RESET_ALL)
|
||||
print(datetime.datetime.now())
|
||||
|
||||
return response.content
|
||||
except Exception as e:
|
||||
|
||||
print(Fore.RED + "💥 > Failed to download image. \n", e)
|
||||
print(Style.RESET_ALL)
|
||||
print(datetime.datetime.now())
|
||||
|
||||
|
||||
def upload_image_to_mastodon(url, mastodon):
|
||||
try:
|
||||
print(Fore.YELLOW + "🐘 > Uploading Image...")
|
||||
print(Style.RESET_ALL)
|
||||
print(datetime.datetime.now())
|
||||
media = mastodon.media_post(media_file = get_image(url), mime_type = "image/jpeg") # sending image to mastodon
|
||||
print(Fore.GREEN + "✨ > Uploaded!")
|
||||
print(Style.RESET_ALL)
|
||||
print(datetime.datetime.now())
|
||||
return media["id"]
|
||||
except Exception as e:
|
||||
print(Fore.RED + "💥 > failed to upload image to mastodon. \n", e)
|
||||
print(Style.RESET_ALL)
|
||||
print(datetime.datetime.now())
|
||||
|
||||
def toot(urls, title, mastodon, fetched_user ):
|
||||
try:
|
||||
print(Fore.YELLOW + "🐘 > Creating Toot...", title)
|
||||
print(Style.RESET_ALL)
|
||||
print(datetime.datetime.now())
|
||||
ids = []
|
||||
for url in urls:
|
||||
ids.append(upload_image_to_mastodon(url, mastodon))
|
||||
|
@ -52,6 +60,7 @@ def toot(urls, title, mastodon, fetched_user ):
|
|||
except Exception as e:
|
||||
print(Fore.RED + "😿 > Failed to create toot \n", e)
|
||||
print(Style.RESET_ALL)
|
||||
print(datetime.datetime.now())
|
||||
|
||||
def get_new_posts(mastodon, profile, mastodon_carousel_size, post_limit, already_posted_path, using_mastodon, carousel_size, post_interval, fetched_user):
|
||||
posts = profile.get_posts()
|
||||
|
@ -63,8 +72,10 @@ def get_new_posts(mastodon, profile, mastodon_carousel_size, post_limit, already
|
|||
if already_posted(str(post.mediaid), already_posted_path):
|
||||
print(Fore.YELLOW + "🐘 > Already Posted ", post.url)
|
||||
print(Style.RESET_ALL)
|
||||
print(datetime.datetime.now())
|
||||
continue
|
||||
print("Posting... ", post.url)
|
||||
print(datetime.datetime.now())
|
||||
if using_mastodon:
|
||||
urls_arr = split_array(url_arr, carousel_size)
|
||||
for urls in urls_arr:
|
||||
|
|
Loading…
Reference in a new issue