Example #1
0
def feed(update, context):
    fullmsg = update.message.text

    if fullmsg == "/feed":
        update.message.reply_text(
            '/feed [instagram username]\nPlease read /help')
    else:
        msg = fullmsg.replace("/feed ", "")

        if "@" in msg.lower():
            query = msg.replace("@", "")
        else:
            query = msg

    L = Instaloader(dirname_pattern=query,
                    download_comments=False,
                    download_video_thumbnails=False,
                    save_metadata=False,
                    download_geotags=True,
                    compress_json=True,
                    post_metadata_txt_pattern=None,
                    storyitem_metadata_txt_pattern=None)
    profile = Profile.from_username(L.context, query)

    media = profile.mediacount
    update.message.reply_text(
        "Cooking your request ๐Ÿ‘จโ€๐Ÿณ\nProfile : " + query + "\nMedia Count : " +
        str(media) +
        "\nThis may take longer, take a nap I can handle this without you.")

    posts = profile.get_posts()
    try:
        L.posts_download_loop(posts, query)
    except Exception as e:
        context.bot.send_message(chat_id=update.message.chat_id,
                                 text="<b>ERROR\n" + str(e),
                                 parse_mode=telegram.ParseMode.HTML)
        return

    update.message.reply_text("Download Completed.\n๐Ÿ—„ Archiving files...")

    zf = zipfile.ZipFile(f"{query}.zip", "w")
    for dirname, subdirs, files in os.walk(query):
        zf.write(query)
        for filename in files:
            zf.write(os.path.join(dirname, filename))
    zf.close()

    update.message.reply_text("Uploading to Telegram...")

    for zip_file in glob.glob("*.zip"):
        context.bot.send_document(chat_id=update.message.chat_id,
                                  document=open(zip_file, 'rb'))

    try:
        shutil.rmtree(query)
        os.remove(f"{query}.zip")
    except Exception:
        pass
Example #2
0
def igtv(update, context):
    user = context.bot.get_chat_member(
        chat_id='-1001225141087', user_id=update.message.chat_id)
    status = user["status"]
    if(status == 'left'):
        context.bot.send_message(chat_id=update.message.chat_id,
                                 text="To use to bot you need to be a member of @MBNUpdates in order to stay updated with the latest developments.")
        return
    else:
        fullmsg = update.message.text

        if fullmsg == "/igtv":
            update.message.reply_text(
                '/igtv [instagram username]\nPlease read /help')
        else:
            msg = fullmsg.replace("/igtv ", "")

            if "@" in msg.lower():
                query = msg.replace("@", "")
            else:
                query = msg

        L = Instaloader(dirname_pattern=query, download_comments=False,
                        download_video_thumbnails=False, save_metadata=False, download_geotags=True, compress_json=True, post_metadata_txt_pattern=None, storyitem_metadata_txt_pattern=None)

        profile = Profile.from_username(L.context, query)

        igtv_count = profile.igtvcount

        posts = profile.get_igtv_posts()

        update.message.reply_text("Cooking your request ๐Ÿ‘จโ€๐Ÿณ\nProfile : " + query + "\nIGTV Video Count : " + str(
            igtv_count) + "\nThis may take longer, take a nap I can handle this without you.")

        try:
            L.posts_download_loop(posts, query)
        except Exception as e:
            context.bot.send_message(chat_id=update.message.chat_id, text="<b>ERROR</b>\n"+str(
                e), parse_mode=telegram.ParseMode.HTML)
            return

        src_dir = query

        for vidfile in glob.iglob(os.path.join(src_dir, "*.mp4")):
            context.bot.send_video(
                chat_id=update.message.chat_id, video=open(vidfile, 'rb'))

        bot.send_message(
            text="Thanks for using @xIGDLBot\nPlease /donate to keep this service alive!", chat_id=update.message.chat_id)

        try:
            shutil.rmtree(query)
        except Exception:
            pass
Example #3
0
def igtv(update, context):
    fullmsg = update.message.text

    if fullmsg == "/igtv":
        update.message.reply_text(
            '/igtv [instagram username]\nPlease read /help')
    else:
        msg = fullmsg.replace("/igtv ", "")

        if "@" in msg.lower():
            query = msg.replace("@", "")
        else:
            query = msg

    L = Instaloader(dirname_pattern=query,
                    download_comments=False,
                    download_video_thumbnails=False,
                    save_metadata=False,
                    download_geotags=True,
                    compress_json=True,
                    post_metadata_txt_pattern=None,
                    storyitem_metadata_txt_pattern=None)

    profile = Profile.from_username(L.context, query)

    igtv_count = profile.igtvcount

    posts = profile.get_igtv_posts()

    update.message.reply_text(
        "Cooking your request ๐Ÿ‘จโ€๐Ÿณ\nProfile : " + query +
        "\nIGTV Video Count : " + str(igtv_count) +
        "\nThis may take longer, take a nap I can handle this without you.")

    try:
        L.posts_download_loop(posts, query)
    except Exception as e:
        context.bot.send_message(chat_id=update.message.chat_id,
                                 text="<b>ERROR รฒ_รด</b>\n" + str(e),
                                 parse_mode=telegram.ParseMode.HTML)
        return

    src_dir = query

    for vidfile in glob.iglob(os.path.join(src_dir, "*.mp4")):
        context.bot.send_video(chat_id=update.message.chat_id,
                               video=open(vidfile, 'rb'))

    try:
        shutil.rmtree(query)
    except Exception:
        pass