-
Notifications
You must be signed in to change notification settings - Fork 0
Enhanced Breakdown of Changes in Instagram Thefty Poster V3.2
Instagram Thefty Poster V3.2 introduces several key enhancements and new functionalities to improve the automation process of scraping, uploading, and managing Instagram reels. Here’s a detailed breakdown of the changes:
Description: Added random waits between various actions (scraping, liking, commenting, and uploading) to better simulate human behavior and reduce the risk of detection by Instagram.
Implementation:
- Introduced random sleep intervals between actions.
- Added logging to record these wait times.
Example:
random_sleep(10, 60, action="next like/comment") # Random sleep before processing each reelDescription: Logged random wait times into a separate file (random-waits.json) for better tracking and debugging.
Implementation:
- Modified
random_sleepfunction to log the wait times. - Created a new log file
random-waits.jsonto store these times.
Example:
def random_sleep(min_time=5, max_time=30, action="waiting"):
sleep_time = random.uniform(min_time, max_time)
sleep(sleep_time)
log_random_wait_times(sleep_time, action)
logging.info(f"Sleeping for {sleep_time:.2f} seconds before {action}. Will resume at {datetime.now() + timedelta(seconds=sleep_time)}")
return sleep_timeDescription: The program now logs the actual comments posted on each reel for better traceability.
Implementation:
- Enhanced the
randomly_like_and_commentfunction to log comments.
Example:
comment = random.choice(COMMENTS)
client.media_comment(reel.id, comment)
logging.info(f"Commented on reel: {reel.pk} with comment: {comment}")Description: Enhanced error handling and logging to capture JSONDecodeError and other exceptions, making the script more robust.
Implementation:
- Added specific error handling for JSONDecodeError.
- Improved logging messages for better clarity.
Example:
except requests.exceptions.JSONDecodeError as e:
logging.error(f"JSONDecodeError: {e} - Retrying in {backoff_time} seconds")
sleep(backoff_time)
backoff_time *= 2 # Exponential backoff
continueDescription: Updated dashboard to display detailed information about scraping, uploading, and random wait times, as well as the next file to be uploaded.
Implementation:
- Added sections in the dashboard for random wait times and next file to upload.
- Enhanced table formatting for better readability.
Example:
# Random Wait Times
console.print("[bold]Random Wait Times (seconds)[/bold]")
for wait_time in random_waits[-10:]:
console.print(f"- {wait_time}")
# Next file to upload
next_file = status.get('next_file_to_upload', 'N/A')
console.print(f"[bold]Next File to Upload:[/bold] {next_file}")Random Waits Between Actions:
def random_sleep(min_time=5, max_time=30, action="waiting"):
sleep_time = random.uniform(min_time, max_time)
sleep(sleep_time)
log_random_wait_times(sleep_time, action)
logging.info(f"Sleeping for {sleep_time:.2f} seconds before {action}. Will resume at {datetime.now() + timedelta(seconds=sleep_time)}")
return sleep_timeEnhanced Main Function:
def main():
global last_scraped_timestamp
status = read_status()
# Initialize times if they are None
last_scrape_time = status.get("last_scrape_time") or (time() - (SCRAPE_INTERVAL_MINUTES * 60))
last_upload_time = status.get("last_upload_time") or (time() - (UPLOAD_INTERVAL_MINUTES * 60))
last_delete_time = status.get("last_delete_time") or 0
# Initialize last_scraped_timestamp from file if it exists
if os.path.exists(last_scraped_file):
with open(last_scraped_file, 'r') as file:
try:
last_scraped_timestamp = int(file.read().strip())
except ValueError:
last_scraped_timestamp = 0
while True:
current_time = time()
if (current_time - last_scrape_time) >= SCRAPE_INTERVAL_MINUTES * 60:
if SCRAPING_ENABLED:
for profile in config['scraping']['profiles'].split():
logging.info(f"Scraping profile: {profile}")
reels = scrape_reels(profile, num_reels=NUM_REELS)
for reel in reels:
random_sleep(10, 60, action="next like/comment") # Random sleep before processing each reel
randomly_like_and_comment(reel, cl)
last_scrape_time = current_time
update_status(last_scrape_time=last_scrape_time, next_scrape_time=current_time + SCRAPE_INTERVAL_MINUTES * 60)
logging.info("Finished scraping reels from profiles.")
wait_time = random_sleep(30, 120, action="uploading phase") # Wait before moving to uploading
logging.info(f"Waited for {wait_time:.2f} seconds before moving to the uploading phase.")
if (current_time - last_upload_time) >= UPLOAD_INTERVAL_MINUTES * 60:
if UPLOAD_ENABLED:
upload_reels_with_new_descriptions(get_unuploaded_reels())
last_upload_time = current_time
update_status(last_upload_time=last_upload_time, next_upload_time=current_time + UPLOAD_INTERVAL_MINUTES * 60)
# Check if it's time to run delete.py
if (current_time - last_delete_time) >= DELETE_INTERVAL_MINUTES * 60:
logging.info("Running delete.py")
subprocess.run(["python", "delete.py"])
last_delete_time = current_time
update_status(last_delete_time=last_delete_time)
sleep(60)
if __name__ == "__main__":
main()Displaying Random Wait Times and Next File to Upload:
def main():
status = read_status()
if not status:
return
uploads = read_upload_log()
random_upload_times = read_random_upload_times()
random_waits = read_random_waits()
total_files, uploaded_files, unuploaded_files, folder_size = get_file_counts()
console.print("=" * 80, justify="left")
console.print("[bold yellow]Instagram Thefty Poster Dashboard[/bold yellow]", justify="left")
console.print("=" * 80, justify="left")
# Scrape and Upload Status Table
table = Table(show_header=True, header_style="bold magenta")
table.add_column("Scrape Status", justify="center")
table.add_column("Upload Status", justify="center")
table.add_row(
f"Last Scrape Time: {format_time(status.get('last_scrape_time'))}\nNext Scrape Time: {format_time(status.get('next_scrape_time'))}",
f"Last Upload Time: {format_time(status.get('last_upload_time'))}\nNext Upload Time: {format_time(status.get('next_upload_time'))}"
)
console.print(table)
# File Counts Table
file_table = Table(show_header=True, header_style="bold magenta")
file_table.add_column("Metric", justify="center")
file_table.add_column("Value", justify="center")
file_table.add_row("Total .mp4 Files", str(total_files))
file_table.add_row("Uploaded .mp4 Files", str(uploaded_files))
file_table.add_row("Unuploaded .mp4 Files", str(unuploaded_files))
file_table.add_row("Downloads Folder Size (MB)", f"{folder_size:.2f}")
console.print(file_table)
# Last 10 Uploads
console.print("[bold]Last 10 Uploads[/bold]")
for upload in uploads[-10:]:
console.print(f"- {upload}")
# Reels Scraped
console.print("[bold]Reels Scraped[/bold]")
for reel in status.get('reels_scraped', []):
console.print(f"- {reel}")
# Random Upload Times
console.print("[bold]Random Upload Times (seconds)[/bold]")
for upload_time in random_upload_times[-10:]:
console.print(f"- {upload_time}")
# Random Wait Times
console.print("[bold]Random Wait Times (seconds)[/bold]")
for wait_time in random_waits[-10:]:
console.print(f"- {wait_time}")
# Story Upload and Deletion Status Table
table2 = Table(show_header=True, header_style="bold magenta")
table2.add_column("Story Upload Status", justify="center")
table2.add_column("Deletion Status", justify="center")
table2.add_row(
f"Last Story Upload Time: {format_time(status.get('last_story_upload_time'))}\nNext Story Upload Time: {format_time(status.get('next_story_upload_time'))}",
f"Last Deletion Time: {format_time(status.get('last_delete_time'))}\nNext Deletion Time: {format_time(status.get('next_delete_time'))}"
)
console.print(table2)
# Next file to upload
next_file = status.get('next_file
_to_upload', 'N/A')
console.print(f"[bold]Next File to Upload:[/bold] {next_file}")
if __name__ == "__main__":
main()Instagram Thefty Poster V3.2 enhances the previous version by adding more sophisticated random waits, improved error handling, detailed logging of comments, and a more informative dashboard. These improvements aim to provide a more human-like behavior, better traceability, and an overall more robust and user-friendly automation experience.