File size: 5,567 Bytes
cac9eab
56af34b
 
bc46207
7409805
1d72d1e
24b72ba
56af34b
dbfa8c2
 
68833e7
1d72d1e
56af34b
cc53428
 
51ff7fb
1d72d1e
 
 
 
 
 
56af34b
1d72d1e
 
 
 
56af34b
1d72d1e
 
 
56af34b
1d72d1e
 
 
 
 
56af34b
 
 
 
 
 
 
 
 
 
 
 
 
 
b5df9d3
1d72d1e
56af34b
1d72d1e
 
 
 
 
 
56af34b
1d72d1e
 
 
 
 
 
 
dbfa8c2
1d72d1e
 
 
 
 
 
 
56af34b
 
1d72d1e
56af34b
1d72d1e
56af34b
 
 
 
 
b5df9d3
56af34b
 
b5df9d3
 
56af34b
 
 
 
 
 
 
 
 
 
b5df9d3
56af34b
b5df9d3
56af34b
b5df9d3
 
 
56af34b
b5df9d3
 
56af34b
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import streamlit as st
st.set_page_config(page_title="Video Marketing Plan Generator", layout="wide")

import requests
import os
from bs4 import BeautifulSoup

# Configure OpenAI API (using OPENAI_API_KEY)
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
OPENAI_ENDPOINT = "https://api.openai.com/v1/chat/completions"

def scrape_website(url):
    """Scrapes business content from the given website URL."""
    if not url.startswith("http"):
        url = f"https://{url}"
    
    try:
        response = requests.get(url, timeout=10)
        response.raise_for_status()
        soup = BeautifulSoup(response.content, "html.parser")
        
        content = []
        # Extract meta description if available
        meta_description = soup.find("meta", {"name": "description"})
        if meta_description and meta_description.get("content"):
            content.append(meta_description["content"])
        
        # Extract text from h1, h2, and p tags
        for tag in ['h1', 'h2', 'p']:
            elements = soup.find_all(tag)
            content.extend([elem.get_text(strip=True) for elem in elements if elem.get_text(strip=True)])
            
        return " ".join(content[:1500])
    except Exception as e:
        st.error(f"Error scraping website: {str(e)}")
        return None

def generate_video_marketing_plan(business_info):
    """Generates a comprehensive video marketing plan using OpenAI GPT-4."""
    prompt = f"""As a leading video marketing strategist specializing in conversion optimization, create a comprehensive video marketing plan for the following business:
{business_info}

Your plan should include:
1. **Core Strategy:** Identify 3 unique angles or approaches that differentiate this business’s video content and showcase its unique value proposition.
2. **Funnel Architecture:** Provide detailed video content ideas for each stage of the funnel: Awareness, Consideration, Conversion, and Post-Purchase.
3. **Content Blueprints:** For the top 3 video concepts, include a content outline, key messaging points, attention-grabbing hooks, call-to-action strategy, ideal length/format, and platform-specific tips.
4. **Production Guidelines:** Recommend visual styles, music/sound design, text overlay strategies, and thumbnail design principles.
5. **Distribution Strategy:** Suggest primary platforms, posting frequency, cross-platform repurposing, hashtag/keyword recommendations, and community engagement tactics.
6. **Measurement Framework:** Define KPIs, engagement metrics, conversion tracking, and A/B testing recommendations to evaluate performance.

Format your response in clear markdown with headers and bullet points, and explain the strategic reasoning behind each recommendation."""
    
    headers = {
        "Authorization": f"Bearer {OPENAI_API_KEY}",
        "Content-Type": "application/json"
    }
    
    data = {
        "model": "gpt-4",  # Using OpenAI GPT-4 model
        "messages": [
            {"role": "system", "content": "You are a top-tier video marketing strategist with years of experience developing conversion-optimized video funnels."},
            {"role": "user", "content": prompt}
        ],
        "temperature": 0.7,
        "max_tokens": 4000
    }
    
    try:
        response = requests.post(OPENAI_ENDPOINT, json=data, headers=headers)
        response.raise_for_status()
        return response.json()["choices"][0]["message"]["content"]
    except Exception as e:
        st.error(f"API Error: {str(e)}")
        return None

# Streamlit UI
st.title("🎥 Video Marketing Plan Generator")
st.markdown("### Generate a comprehensive video marketing plan for your business.")

input_method = st.radio("Choose input method:", ["Enter business details manually", "Use website URL"])

if input_method == "Enter business details manually":
    business_name = st.text_input("Business Name*")
    business_description = st.text_area("What does your company do?*", help="Describe your products/services and what makes you unique.")
    ideal_client = st.text_area("Ideal Client Profile*", help="Include demographics, challenges they face, and why they need your solution.")
    marketing_goals = st.text_area("Marketing Goals (optional)", help="Describe your primary marketing objectives, target metrics, and any specific goals.")
    
    if st.button("Generate Marketing Plan"):
        if not all([business_name, business_description, ideal_client]):
            st.error("Please fill in all required fields marked with *")
        else:
            with st.spinner("Creating your custom video marketing plan..."):
                business_info = f"""
Business Name: {business_name}
Business Description: {business_description}
Ideal Client Profile: {ideal_client}
Marketing Goals: {marketing_goals if marketing_goals else 'Not provided'}
"""
                plan = generate_video_marketing_plan(business_info)
                if plan:
                    st.markdown(plan)
else:
    website_url = st.text_input("Enter your business website URL*", placeholder="e.g., www.example.com")
    
    if st.button("Generate Marketing Plan"):
        if not website_url:
            st.error("Please enter a valid website URL")
        else:
            with st.spinner("Extracting business details and generating your video marketing plan..."):
                website_content = scrape_website(website_url)
                if website_content:
                    plan = generate_video_marketing_plan(website_content)
                    if plan:
                        st.markdown(plan)