import pptx
import requests

from pptx import Presentation
from io import BytesIO

prs = Presentation("src/resources/templates/proposal_template.pptx")
nro = 23

def replace_image(location, image):
    new_pptx_img = pptx.parts.image.Image.from_file(image)
    slide_part, rId = location.part, location._element.blip_rId
    image_part = slide_part.related_part(rId)
    image_part.blob = new_pptx_img._blob

a = prs.slides[nro].shapes[7].text_frame.paragraphs[0].runs[0].text = "PEPILLO XD"

for shape in prs.slides[nro].shapes:
    print("id: %s, type: %s" % (shape.shape_id, shape.shape_type))

url = "https://i.pinimg.com/originals/80/b5/81/80b5813d8ad81a765ca47ebc59a65ac3.jpg"

# replace_image(
# 	a,
# 	BytesIO(requests.get(url).content)
# )

prs.save("test.pptx")

# prs.slides[nro].shapes[6].text_frame.paragraphs[0].runs[0].text = "perro papito pariente1"
# prs.slides[nro].shapes[7].text_frame.paragraphs[0].runs[0].text = "perro papito pariente2"
# prs.slides[nro].shapes[8].text_frame.paragraphs[0].runs[0].text = "perro papito pariente3"
# prs.save("cacatua.pptx")