Загрузка данных


from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN
from pptx.enum.shapes import MSO_SHAPE

def create_avito_presentation():
    prs = Presentation()
    
    # Set slide size to 16:9
    prs.slide_width = Inches(13.333)
    prs.slide_height = Inches(7.5)
    
    # Colors
    WHITE = RGBColor(255, 255, 255)
    BLACK = RGBColor(0, 0, 0)
    DARK_GRAY = RGBColor(51, 51, 51)
    AVITO_GREEN = RGBColor(0, 170, 0)
    AVITO_BLUE = RGBColor(0, 102, 204)
    
    # Remove default slide
    if len(prs.slides) > 0:
        xml_slides = prs.slides._sldIdLst
        xml_slides.remove(xml_slides[0])
    
    # SLIDE 1 - Title Slide
    slide_layout = prs.slide_layouts[6]  # Blank layout
    slide = prs.slides.add_slide(slide_layout)
    slide.background.fill.solid()
    slide.background.fill.fore_color.rgb = WHITE
    
    # Title
    title = slide.shapes.add_textbox(Inches(0.5), Inches(1.5), Inches(12.333), Inches(1.5))
    tf = title.text_frame
    tf.word_wrap = True
    p = tf.paragraphs[0]
    p.text = "Авито Услуги: найди проверенного мастера за 5 минут"
    p.font.size = Pt(40)
    p.font.color.rgb = BLACK
    p.font.name = 'Arial'
    p.alignment = PP_ALIGN.CENTER
    
    # Subtitle
    subtitle = slide.shapes.add_textbox(Inches(0.5), Inches(3.2), Inches(12.333), Inches(0.8))
    tf = subtitle.text_frame
    p = tf.paragraphs[0]
    p.text = "Author: Dilan | Date: 09.10.2026"
    p.font.size = Pt(24)
    p.font.color.rgb = DARK_GRAY
    p.font.name = 'Arial'
    p.alignment = PP_ALIGN.CENTER
    
    # Placeholder for smartphone image
    img_placeholder = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, Inches(5), Inches(4.5), Inches(3.333), Inches(2)
    )
    img_placeholder.fill.solid()
    img_placeholder.fill.fore_color.rgb = WHITE
    img_placeholder.line.color.rgb = AVITO_GREEN
    img_placeholder.line.width = Pt(2)
    tf = img_placeholder.text_frame
    tf.text = "Image: Smartphone on table\n(Unsplash)"
    tf.paragraphs[0].font.size = Pt(14)
    tf.paragraphs[0].font.color.rgb = DARK_GRAY
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # SLIDE 2 - Problem
    slide = prs.slides.add_slide(slide_layout)
    slide.background.fill.solid()
    slide.background.fill.fore_color.rgb = WHITE
    
    title = slide.shapes.add_textbox(Inches(0.5), Inches(0.3), Inches(8), Inches(1))
    tf = title.text_frame
    p = tf.paragraphs[0]
    p.text = "Проблема"
    p.font.size = Pt(36)
    p.font.color.rgb = AVITO_GREEN
    p.font.name = 'Arial'
    
    # Bullet points
    bullets = slide.shapes.add_textbox(Inches(0.5), Inches(1.5), Inches(7), Inches(3))
    tf = bullets.text_frame
    tf.word_wrap = True
    
    points = [
        "Сложно найти хорошего сантехника или репетитора",
        "Много мошенников и некачественных услуг",
        "Долгий поиск в чатах и соцсетях без гарантий"
    ]
    
    for i, point in enumerate(points):
        if i == 0:
            p = tf.paragraphs[0]
        else:
            p = tf.add_paragraph()
        p.text = "• " + point
        p.font.size = Pt(24)
        p.font.color.rgb = DARK_GRAY
        p.font.name = 'Arial'
        p.space_after = Pt(20)
    
    # Image placeholder
    img_placeholder = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, Inches(8), Inches(1.5), Inches(4.833), Inches(4)
    )
    img_placeholder.fill.solid()
    img_placeholder.fill.fore_color.rgb = WHITE
    img_placeholder.line.color.rgb = AVITO_BLUE
    img_placeholder.line.width = Pt(2)
    tf = img_placeholder.text_frame
    tf.text = "Image: Person frustrated with phone\n(Unsplash)"
    tf.paragraphs[0].font.size = Pt(14)
    tf.paragraphs[0].font.color.rgb = DARK_GRAY
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # SLIDE 3 - Solution
    slide = prs.slides.add_slide(slide_layout)
    slide.background.fill.solid()
    slide.background.fill.fore_color.rgb = WHITE
    
    title = slide.shapes.add_textbox(Inches(0.5), Inches(0.3), Inches(8), Inches(1))
    tf = title.text_frame
    p = tf.paragraphs[0]
    p.text = "Решение"
    p.font.size = Pt(36)
    p.font.color.rgb = AVITO_GREEN
    p.font.name = 'Arial'
    
    bullets = slide.shapes.add_textbox(Inches(0.5), Inches(1.5), Inches(7), Inches(3.5))
    tf = bullets.text_frame
    tf.word_wrap = True
    
    points = [
        "Единая платформа с проверенными специалистами",
        "Реальные отзывы и рейтинги",
        "Безопасная сделка: деньги замораживаются до выполнения работы"
    ]
    
    for i, point in enumerate(points):
        if i == 0:
            p = tf.paragraphs[0]
        else:
            p = tf.add_paragraph()
        p.text = "• " + point
        p.font.size = Pt(24)
        p.font.color.rgb = DARK_GRAY
        p.font.name = 'Arial'
        p.space_after = Pt(20)
    
    img_placeholder = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, Inches(8), Inches(1.5), Inches(4.833), Inches(4)
    )
    img_placeholder.fill.solid()
    img_placeholder.fill.fore_color.rgb = WHITE
    img_placeholder.line.color.rgb = AVITO_GREEN
    img_placeholder.line.width = Pt(2)
    tf = img_placeholder.text_frame
    tf.text = "Image: Handshake or Happy client\n(Unsplash)"
    tf.paragraphs[0].font.size = Pt(14)
    tf.paragraphs[0].font.color.rgb = DARK_GRAY
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # SLIDE 4 - How It Works
    slide = prs.slides.add_slide(slide_layout)
    slide.background.fill.solid()
    slide.background.fill.fore_color.rgb = WHITE
    
    title = slide.shapes.add_textbox(Inches(0.5), Inches(0.3), Inches(12.333), Inches(1))
    tf = title.text_frame
    p = tf.paragraphs[0]
    p.text = "Как это работает (3 шага)"
    p.font.size = Pt(36)
    p.font.color.rgb = AVITO_GREEN
    p.font.name = 'Arial'
    
    steps = slide.shapes.add_textbox(Inches(0.5), Inches(1.5), Inches(6), Inches(4))
    tf = steps.text_frame
    tf.word_wrap = True
    
    step_list = [
        "1. Выбери категорию (ремонт, уборка, обучение)",
        "2. Сравни цены и отзывы",
        "3. Закажи услугу с гарантией возврата"
    ]
    
    for i, step in enumerate(step_list):
        if i == 0:
            p = tf.paragraphs[0]
        else:
            p = tf.add_paragraph()
        p.text = step
        p.font.size = Pt(24)
        p.font.color.rgb = DARK_GRAY
        p.font.name = 'Arial'
        p.space_after = Pt(30)
    
    img_placeholder = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, Inches(7), Inches(1.5), Inches(5.833), Inches(4)
    )
    img_placeholder.fill.solid()
    img_placeholder.fill.fore_color.rgb = WHITE
    img_placeholder.line.color.rgb = AVITO_BLUE
    img_placeholder.line.width = Pt(2)
    tf = img_placeholder.text_frame
    tf.text = "Image: Avito.ru services page screenshot"
    tf.paragraphs[0].font.size = Pt(14)
    tf.paragraphs[0].font.color.rgb = DARK_GRAY
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # SLIDE 5 - Target Audience
    slide = prs.slides.add_slide(slide_layout)
    slide.background.fill.solid()
    slide.background.fill.fore_color.rgb = WHITE
    
    title = slide.shapes.add_textbox(Inches(0.5), Inches(0.3), Inches(8), Inches(1))
    tf = title.text_frame
    p = tf.paragraphs[0]
    p.text = "Целевая аудитория"
    p.font.size = Pt(36)
    p.font.color.rgb = AVITO_GREEN
    p.font.name = 'Arial'
    
    bullets = slide.shapes.add_textbox(Inches(0.5), Inches(1.5), Inches(7), Inches(4))
    tf = bullets.text_frame
    tf.word_wrap = True
    
    points = [
        "Частные лица: нужен ремонт, уборка или репетитор",
        "Малый бизнес: поиск подрядчиков на разовые задачи",
        "Сами мастера: фрилансеры и самозанятые, ищущие заказы"
    ]
    
    for i, point in enumerate(points):
        if i == 0:
            p = tf.paragraphs[0]
        else:
            p = tf.add_paragraph()
        p.text = "• " + point
        p.font.size = Pt(24)
        p.font.color.rgb = DARK_GRAY
        p.font.name = 'Arial'
        p.space_after = Pt(20)
    
    img_placeholder = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, Inches(8), Inches(1.5), Inches(4.833), Inches(4)
    )
    img_placeholder.fill.solid()
    img_placeholder.fill.fore_color.rgb = WHITE
    img_placeholder.line.color.rgb = AVITO_GREEN
    img_placeholder.line.width = Pt(2)
    tf = img_placeholder.text_frame
    tf.text = "Image: Person working on laptop\n(Unsplash)"
    tf.paragraphs[0].font.size = Pt(14)
    tf.paragraphs[0].font.color.rgb = DARK_GRAY
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # SLIDE 6 - Competitors (Table)
    slide = prs.slides.add_slide(slide_layout)
    slide.background.fill.solid()
    slide.background.fill.fore_color.rgb = WHITE
    
    title = slide.shapes.add_textbox(Inches(0.5), Inches(0.3), Inches(12.333), Inches(1))
    tf = title.text_frame
    p = tf.paragraphs[0]
    p.text = "Конкуренты"
    p.font.size = Pt(36)
    p.font.color.rgb = AVITO_GREEN
    p.font.name = 'Arial'
    
    # Create table
    table = slide.shapes.add_table(5, 4, Inches(0.5), Inches(1.5), Inches(12.333), Inches(4.5)).table
    
    # Set column widths
    table.columns[0].width = Inches(3)
    table.columns[1].width = Inches(3)
    table.columns[2].width = Inches(3)
    table.columns[3].width = Inches(3.333)
    
    # Header row
    headers = ["Platform", "Master Base", "Safe Deal", "Price for Master"]
    for i, header in enumerate(headers):
        cell = table.cell(0, i)
        cell.text = header
        cell.text_frame.paragraphs[0].font.size = Pt(18)
        cell.text_frame.paragraphs[0].font.bold = True
        cell.text_frame.paragraphs[0].font.color.rgb = WHITE
        cell.fill.solid()
        cell.fill.fore_color.rgb = AVITO_BLUE
    
    # Data rows
    data = [
        ["Авито Услуги", "Very large", "Yes", "Low/Free"],
        ["Профи.ру", "Medium", "Yes", "High commission"],
        ["Яндекс.Услуги", "Large", "Partially", "Medium"]
    ]
    
    for row_idx, row_data in enumerate(data, 1):
        for col_idx, cell_data in enumerate(row_data):
            cell = table.cell(row_idx, col_idx)
            cell.text = cell_data
            cell.text_frame.paragraphs[0].font.size = Pt(16)
            cell.text_frame.paragraphs[0].font.color.rgb = DARK_GRAY
            if row_idx % 2 == 0:
                cell.fill.solid()
                cell.fill.fore_color.rgb = RGBColor(245, 245, 245)
    
    # SLIDE 7 - Technology
    slide = prs.slides.add_slide(slide_layout)
    slide.background.fill.solid()
    slide.background.fill.fore_color.rgb = WHITE
    
    title = slide.shapes.add_textbox(Inches(0.5), Inches(0.3), Inches(8), Inches(1))
    tf = title.text_frame
    p = tf.paragraphs[0]
    p.text = "Технологии"
    p.font.size = Pt(36)
    p.font.color.rgb = AVITO_GREEN
    p.font.name = 'Arial'
    
    bullets = slide.shapes.add_textbox(Inches(0.5), Inches(1.5), Inches(7), Inches(4))
    tf = bullets.text_frame
    tf.word_wrap = True
    
    points = [
        "Мобильное приложение (iOS и Android)",
        "ML-алгоритмы для умного ранжирования объявлений",
        "Автоматическая проверка паспортов и статуса самозанятого"
    ]
    
    for i, point in enumerate(points):
        if i == 0:
            p = tf.paragraphs[0]
        else:
            p = tf.add_paragraph()
        p.text = "• " + point
        p.font.size = Pt(24)
        p.font.color.rgb = DARK_GRAY
        p.font.name = 'Arial'
        p.space_after = Pt(20)
    
    img_placeholder = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, Inches(8), Inches(1.5), Inches(4.833), Inches(4)
    )
    img_placeholder.fill.solid()
    img_placeholder.fill.fore_color.rgb = WHITE
    img_placeholder.line.color.rgb = AVITO_BLUE
    img_placeholder.line.width = Pt(2)
    tf = img_placeholder.text_frame
    tf.text = "Image: Code screen or Server room\n(Unsplash)"
    tf.paragraphs[0].font.size = Pt(14)
    tf.paragraphs[0].font.color.rgb = DARK_GRAY
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # SLIDE 8 - Monetization
    slide = prs.slides.add_slide(slide_layout)
    slide.background.fill.solid()
    slide.background.fill.fore_color.rgb = WHITE
    
    title = slide.shapes.add_textbox(Inches(0.5), Inches(0.3), Inches(8), Inches(1))
    tf = title.text_frame
    p = tf.paragraphs[0]
    p.text = "Монетизация"
    p.font.size = Pt(36)
    p.font.color.rgb = AVITO_GREEN
    p.font.name = 'Arial'
    
    bullets = slide.shapes.add_textbox(Inches(0.5), Inches(1.5), Inches(7), Inches(4))
    tf = bullets.text_frame
    tf.word_wrap = True
    
    points = [
        "Платное продвижение объявлений для мастеров",
        "Комиссия с успешных безопасных сделок",
        "Подписка \"Профессионал\" для частых исполнителей"
    ]
    
    for i, point in enumerate(points):
        if i == 0:
            p = tf.paragraphs[0]
        else:
            p = tf.add_paragraph()
        p.text = "• " + point
        p.font.size = Pt(24)
        p.font.color.rgb = DARK_GRAY
        p.font.name = 'Arial'
        p.space_after = Pt(20)
    
    img_placeholder = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, Inches(8), Inches(1.5), Inches(4.833), Inches(4)
    )
    img_placeholder.fill.solid()
    img_placeholder.fill.fore_color.rgb = WHITE
    img_placeholder.line.color.rgb = AVITO_GREEN
    img_placeholder.line.width = Pt(2)
    tf = img_placeholder.text_frame
    tf.text = "Image: Credit card or Coins\n(Unsplash)"
    tf.paragraphs[0].font.size = Pt(14)
    tf.paragraphs[0].font.color.rgb = DARK_GRAY
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # SLIDE 9 - Team & Achievements
    slide = prs.slides.add_slide(slide_layout)
    slide.background.fill.solid()
    slide.background.fill.fore_color.rgb = WHITE
    
    title = slide.shapes.add_textbox(Inches(0.5), Inches(0.3), Inches(8), Inches(1))
    tf = title.text_frame
    p = tf.paragraphs[0]
    p.text = "Команда и достижения"
    p.font.size = Pt(36)
    p.font.color.rgb = AVITO_GREEN
    p.font.name = 'Arial'
    
    bullets = slide.shapes.add_textbox(Inches(0.5), Inches(1.5), Inches(7), Inches(4))
    tf = bullets.text_frame
    tf.word_wrap = True
    
    points = [
        "30+ млн пользователей ежемесячно",
        "Более 1000 категорий услуг",
        "Команда: разработчики, аналитики, служба поддержки"
    ]
    
    for i, point in enumerate(points):
        if i == 0:
            p = tf.paragraphs[0]
        else:
            p = tf.add_paragraph()
        p.text = "• " + point
        p.font.size = Pt(24)
        p.font.color.rgb = DARK_GRAY
        p.font.name = 'Arial'
        p.space_after = Pt(20)
    
    # Highlight numbers in green
    for paragraph in tf.paragraphs:
        text = paragraph.text
        if "30+" in text or "1000" in text:
            for run in paragraph.runs:
                if "30+" in run.text or "1000" in run.text:
                    run.font.color.rgb = AVITO_GREEN
                    run.font.bold = True
    
    img_placeholder = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, Inches(8), Inches(1.5), Inches(4.833), Inches(4)
    )
    img_placeholder.fill.solid()
    img_placeholder.fill.fore_color.rgb = WHITE
    img_placeholder.line.color.rgb = AVITO_BLUE
    img_placeholder.line.width = Pt(2)
    tf = img_placeholder.text_frame
    tf.text = "Image: Team meeting\n(Unsplash)"
    tf.paragraphs[0].font.size = Pt(14)
    tf.paragraphs[0].font.color.rgb = DARK_GRAY
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # SLIDE 10 - Call to Action
    slide = prs.slides.add_slide(slide_layout)
    slide.background.fill.solid()
    slide.background.fill.fore_color.rgb = WHITE
    
    title = slide.shapes.add_textbox(Inches(0.5), Inches(0.5), Inches(12.333), Inches(1.5))
    tf = title.text_frame
    p = tf.paragraphs[0]
    p.text = "Попробуй найти мастера уже сегодня!"
    p.font.size = Pt(40)
    p.font.color.rgb = AVITO_GREEN
    p.font.name = 'Arial'
    p.alignment = PP_ALIGN.CENTER
    
    cta_text = slide.shapes.add_textbox(Inches(0.5), Inches(2.2), Inches(12.333), Inches(1))
    tf = cta_text.text_frame
    p = tf.paragraphs[0]
    p.text = "Скачай приложение или перейди на сайт"
    p.font.size = Pt(28)
    p.font.color.rgb = DARK_GRAY
    p.font.name = 'Arial'
    p.alignment = PP_ALIGN.CENTER
    
    url_text = slide.shapes.add_textbox(Inches(0.5), Inches(3), Inches(12.333), Inches(1))
    tf = url_text.text_frame
    p = tf.paragraphs[0]
    p.text = "avito.ru/uslugi"
    p.font.size = Pt(32)
    p.font.color.rgb = AVITO_BLUE
    p.font.name = 'Arial'
    p.font.bold = True
    p.alignment = PP_ALIGN.CENTER
    
    # QR Code placeholder
    qr_placeholder = slide.shapes.add_shape(
        MSO_SHAPE.RECTANGLE, Inches(5), Inches(4.2), Inches(3.333), Inches(3.333)
    )
    qr_placeholder.fill.solid()
    qr_placeholder.fill.fore_color.rgb = WHITE
    qr_placeholder.line.color.rgb = BLACK
    qr_placeholder.line.width = Pt(2)
    tf = qr_placeholder.text_frame
    tf.text = "QR Code\n(avito.ru)"
    tf.paragraphs[0].font.size = Pt(18)
    tf.paragraphs[0].font.color.rgb = DARK_GRAY
    tf.paragraphs[0].alignment = PP_ALIGN.CENTER
    
    # Save presentation
    prs.save('Avito_Services_Presentation.pptx')
    print("Презентация успешно создана: Avito_Services_Presentation.pptx")

if __name__ == "__main__":
    create_avito_presentation()