subzeroid / instagrapi

🔥 The fastest and powerful Python library for Instagram Private API 2024 with HikerAPI SaaS
https://hikerapi.com/p/bkXQlaVe
MIT License
4.43k stars 691 forks source link

[BUG] Story Upload Issue with Mentions, Links, Hashtags, and Locations Not Appearing in Data #1760

Open Halphas opened 10 months ago

Halphas commented 10 months ago

Story Upload Issue with Mentions, Links, Hashtags, and Locations Not Appearing in Datastructure

Description When uploading a story to Instagram using the Instagrapi private API, the mentions, links, hashtags, and locations set in the configuration do not appear in the uploaded story. Only the photo is uploaded, and none of the additional information is included. Consequently, the mentioned users do not receive notifications, and the story lacks the intended links, hashtags, and location data.

To Reproduce

  1. Utilize the Instagrapi private API to upload a story on Instagram.

  2. Set mentions, links, hashtags, and location in the story configuration. To populate the data use:

    for mention in mentions_obj:
        mention.user = cl.user_info_by_username(mention.user.username)
    for hashtags in hashtags_obj:
        hashtags.hashtag = cl.hashtag_info(hashtags.hashtag.name

    locations are resolved by default(awesome)

  3. Observe the uploaded story on Instagram.

Traceback No specific Python traceback is available as the story upload completes successfully, but the additional configurations (mentions, links, hashtags, locations) are not applied.

Expected Behaviour The story uploaded to Instagram should include the configured mentions, links, hashtags, and location. Mentioned users should receive notifications, and the story should display the added mention information in "three dots(More menu)" under Add Mentions.

Screenshots Not applicable, as the issue pertains to missing elements in the uploaded story.

Desktop Information

Additional Context

I am utilizing the Instagrapi private API primarily for the purpose of promoting events through Instagram stories. This forms a crucial part of my marketing approach, with a focus on harnessing Instagram's story features - mentions, links, hashtags, and locations - to enhance audience engagement, reach, and provide ease of access to event information.

Key Components of Usage:

  1. Mentions of DJs and Artists: These are essential for engaging a broader audience and notifying fans of the involved artists and DJs.
  2. Location Tags: Vital for helping users easily locate and navigate to event venues.
  3. Link Stickers to Ticketing Pages: Offer a straightforward route for audience members to purchase tickets and obtain event details.

However, I am facing a significant challenge with the Instagrapi API. Despite following the standard procedures for story uploads, the uploaded stories are missing these crucial interactive elements, severely impacting the promotional effectiveness.

Efforts and Encountered Challenges:

Inquiries:

I am looking for insights to determine whether the challenges I am encountering are due to inherent limitations within Instagrapi or if they stem from issues specific to my application's setup. Understanding this is critical for deciding my subsequent actions, whether that involves further troubleshooting or exploring alternative solutions. Your guidance and insights on these matters would be highly valued.

fullbeats commented 4 months ago

I still encounter the same problem. I do not think they are specific to your application setup.

Halphas commented 4 months ago

@fullbeats I Really spent a long time trying to fix it but then I have developed my own Instagram connector solution. I just wanted to post stories automatically but I guess others just want to scrap Insta data so this is not really important to maintain I guess. Haha

sujay1599 commented 4 months ago

@fullbeats I Really spent a long time trying to fix it but then I have developed my own Instagram connector solution. I just wanted to post stories automatically but I guess others just want to scrap Insta data so this is not really important to maintain I guess. Haha

Same.

I created my own as well.

It allows for custom description building or using the default scrapped video description.

def build_description(original_description, use_original, custom_description, use_hashtags, hashtags_list, give_credit, profile_username): if not original_description: description = random.choice(DEFAULT_DESCRIPTIONS) else: description = original_description if use_original else (custom_description if custom_description else random.choice(DEFAULT_DESCRIPTIONS))

if use_hashtags:
    description += f"\n{hashtags_list}"

if give_credit:
    description += f"\nTaken from: @{profile_username}"

return description

def load_uploaded_reels(log_filename): uploaded_reels = set() if os.path.exists(log_filename): with open(log_filename, 'r') as log_file: uploaded_reels = set(line.strip() for line in log_file) return uploaded_reels

def upload_reels_with_new_descriptions(client, config, unuploaded_reels, uploaded_reels, log_filename): if not unuploaded_reels: console.print("[bold bright_red]No new reels to upload[/bold bright_red]") return

for reel_file in unuploaded_reels:
    reel_id = reel_file.split('_')[1].split('.')[0]
    profile_username = reel_file.split('_')[0]
    media_path = os.path.join('downloads', reel_file)
    description_path = os.path.join('downloads', f'{reel_id}.txt')
    console.print(f"[bold bright_green]Preparing to upload reel {reel_id} from profile {profile_username}[/bold bright_green]")

    if not os.path.exists(media_path) or f"{profile_username}_{reel_id}" in uploaded_reels:
        console.print(f"[bold bright_red]Media file {media_path} not found or already uploaded. Skipping upload for reel: {reel_id}[/bold bright_red]")
        continue

    if os.path.exists(description_path):
        with open(description_path, 'r', encoding='utf-8') as f:
            original_description = f.read()
            logging.debug(f"Read original description for reel {reel_id}")
    else:
        original_description = ""

    new_description = build_description(
        original_description,
        config['description']['use_original'],
        config['description'].get('custom_description', ''),
        config['hashtags']['use_hashtags'],
        config['hashtags'].get('hashtags_list', ''),
        config['credit']['give_credit'],
        profile_username
    )
    logging.debug(f"Built new description for reel {reel_id}")

    try:
        client.clip_upload(media_path, new_description)
        console.print(f"[bold bright_green]Uploaded reel: {profile_username}_{reel_id} with description:\n{new_description}[/bold bright_green]")
    except Exception as e:
        console.print(f"[bold bright_red]Failed to upload reel {reel_id}: {e}[/bold bright_red]")
        continue

    console.print("[bold bright_green]Displaying dashboard after reel upload[/bold bright_green]")
    subprocess.run(["python", "dashboard.py"])

Could use mine for inspiration:

https://github.com/sujay1599/InstagramTheftyScraperPosterHuman

sujay1599 commented 4 months ago

I still encounter the same problem. I do not think they are specific to your application setup.

See post above