add time in logging and remove some shit

This commit is contained in:
horhik 2021-11-14 23:24:59 +03:00
parent 535ea46f24
commit 4847a5e870
4 changed files with 19 additions and 8 deletions

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import datetime
from colorama import Fore, Back, Style from colorama import Fore, Back, Style
def process_arguments(args, defaults): def process_arguments(args, defaults):
count = 1 count = 1
@ -28,14 +29,8 @@ def process_arguments(args, defaults):
else: else:
print(Fore.RED + '❗ -> Wrong Argument Name!...') print(Fore.RED + '❗ -> Wrong Argument Name!...')
print(Style.RESET_ALL) print(Style.RESET_ALL)
print(datetime.datetime.now())
count +=2 count +=2
return defaults 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!!!!!!!!!

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from colorama import Fore, Back, Style from colorama import Fore, Back, Style
import datetime
def split_array(arr, size): def split_array(arr, size):
count = len(arr) // size + 1 count = len(arr) // size + 1
@ -15,9 +16,10 @@ def try_to_get_carousel(array, post):
return urls return urls
print(Fore.GREEN + "🎠 > Found carousel!") print(Fore.GREEN + "🎠 > Found carousel!")
print(Style.RESET_ALL) print(Style.RESET_ALL)
print(datetime.datetime.now())
except Exception as e: except Exception as e:
print(Fore.RED + "🎠💥 > No carousel :( \n", e) print(Fore.RED + "🎠💥 > No carousel :( \n", e)
print(Style.RESET_ALL) print(Style.RESET_ALL)
print(datetime.datetime.now())
return array return array

View File

@ -2,6 +2,7 @@
import os import os
import sys import sys
import time import time
import datetime
import json import json
from mastodon import Mastodon from mastodon import Mastodon
from colorama import Fore, Back, Style from colorama import Fore, Back, Style
@ -53,12 +54,14 @@ mastodon_carousel_size = settings["carousel-limit"]
print(Fore.GREEN + '🚀 > Connecting to Instagram...') print(Fore.GREEN + '🚀 > Connecting to Instagram...')
print(Style.RESET_ALL) print(Style.RESET_ALL)
print(datetime.datetime.now())
L = Instaloader() L = Instaloader()
profile = Profile.from_username(L.context, fetched_user) profile = Profile.from_username(L.context, fetched_user)
print(Fore.GREEN + '🚀 > Connecting to Mastodon/Pixelfed...') print(Fore.GREEN + '🚀 > Connecting to Mastodon/Pixelfed...')
print(Style.RESET_ALL) print(Style.RESET_ALL)
print(datetime.datetime.now())
mastodon = Mastodon( mastodon = Mastodon(
access_token = mastodon_token, access_token = mastodon_token,
api_base_url = mastodon_instance api_base_url = mastodon_instance

View File

@ -2,6 +2,7 @@
from colorama import Fore, Back, Style from colorama import Fore, Back, Style
import requests import requests
import time import time
import datetime
from already_posted import already_posted, mark_as_posted from already_posted import already_posted, mark_as_posted
from converters import split_array, try_to_get_carousel from converters import split_array, try_to_get_carousel
import hashlib import hashlib
@ -10,36 +11,43 @@ def get_image(url):
try: try:
print(Fore.YELLOW + "🚀 > Downloading Image...", url) print(Fore.YELLOW + "🚀 > Downloading Image...", url)
print(Style.RESET_ALL) print(Style.RESET_ALL)
print(datetime.datetime.now())
response = requests.get(url) response = requests.get(url)
response.raw.decode_content = True response.raw.decode_content = True
print(Fore.GREEN + "✨ > Downloaded!") print(Fore.GREEN + "✨ > Downloaded!")
print(Style.RESET_ALL) print(Style.RESET_ALL)
print(datetime.datetime.now())
return response.content return response.content
except Exception as e: except Exception as e:
print(Fore.RED + "💥 > Failed to download image. \n", e) print(Fore.RED + "💥 > Failed to download image. \n", e)
print(Style.RESET_ALL) print(Style.RESET_ALL)
print(datetime.datetime.now())
def upload_image_to_mastodon(url, mastodon): def upload_image_to_mastodon(url, mastodon):
try: try:
print(Fore.YELLOW + "🐘 > Uploading Image...") print(Fore.YELLOW + "🐘 > Uploading Image...")
print(Style.RESET_ALL) 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 media = mastodon.media_post(media_file = get_image(url), mime_type = "image/jpeg") # sending image to mastodon
print(Fore.GREEN + "✨ > Uploaded!") print(Fore.GREEN + "✨ > Uploaded!")
print(Style.RESET_ALL) print(Style.RESET_ALL)
print(datetime.datetime.now())
return media["id"] return media["id"]
except Exception as e: except Exception as e:
print(Fore.RED + "💥 > failed to upload image to mastodon. \n", e) print(Fore.RED + "💥 > failed to upload image to mastodon. \n", e)
print(Style.RESET_ALL) print(Style.RESET_ALL)
print(datetime.datetime.now())
def toot(urls, title, mastodon, fetched_user ): def toot(urls, title, mastodon, fetched_user ):
try: try:
print(Fore.YELLOW + "🐘 > Creating Toot...", title) print(Fore.YELLOW + "🐘 > Creating Toot...", title)
print(Style.RESET_ALL) print(Style.RESET_ALL)
print(datetime.datetime.now())
ids = [] ids = []
for url in urls: for url in urls:
ids.append(upload_image_to_mastodon(url, mastodon)) ids.append(upload_image_to_mastodon(url, mastodon))
@ -52,6 +60,7 @@ def toot(urls, title, mastodon, fetched_user ):
except Exception as e: except Exception as e:
print(Fore.RED + "😿 > Failed to create toot \n", e) print(Fore.RED + "😿 > Failed to create toot \n", e)
print(Style.RESET_ALL) 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): 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() 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): if already_posted(str(post.mediaid), already_posted_path):
print(Fore.YELLOW + "🐘 > Already Posted ", post.url) print(Fore.YELLOW + "🐘 > Already Posted ", post.url)
print(Style.RESET_ALL) print(Style.RESET_ALL)
print(datetime.datetime.now())
continue continue
print("Posting... ", post.url) print("Posting... ", post.url)
print(datetime.datetime.now())
if using_mastodon: if using_mastodon:
urls_arr = split_array(url_arr, carousel_size) urls_arr = split_array(url_arr, carousel_size)
for urls in urls_arr: for urls in urls_arr: