suil0109's picture
first commit
e7251ed
import datetime
import traceback
def keyword_prompt(video_info, summarization):
keyword_prompt = f"""
You are given a summary of a YouTube video.
Your task is to identify the **main subject (person, company, or concept)** that the video is about.
Only return a **single keyword** (preferably a named entity such as a person, brand, or organization).
Video Info:
{video_info}
Video Summary:
{summarization}
Return only one keyword that best represents the **main focus** of the video content.
"""
return keyword_prompt
def analysis_prompt(video_info, summarization, news, comments_text):
analysis_prompt = f"""
Analyze YouTube video information, summary, comments, and related latest news to create a Markdown format report.
Video Info: {video_info}
Video Summary:
{summarization}
Latest News:
{news}
Comments:
{comments_text}
Please write in the following format:
# 🎬 YouTube Video Analysis Report
## πŸ“Œ Key Keywords
`keyword`
## 🎯 Video Overview
[Summary of main video content]
## πŸ’¬ Comment Sentiment Analysis
### πŸ“Š Sentiment Distribution
- **Positive**: X%
- **Negative**: Y%
- **Neutral**: Z%
### πŸ” Key Comment Insights
1. **Positive Reactions**: [Summary of main positive comments]
2. **Negative Reactions**: [Summary of main negative comments]
3. **Core Issues**: [Main topics found in comments]
### πŸ” Comments
1. Positive Comments: [Positive comments with sentiment classification and reasoning]
2. Negative Comments: [Negative comments with sentiment classification and reasoning]
3. Neutral Comments: [Neutral comments with sentiment classification and reasoning]
## πŸ“° Latest News Relevance
[Analysis of correlation between news and video/comments]
## πŸ’‘ Key Insights
1. [First major finding]
2. [Second major finding]
3. [Third major finding]
# ## 🎯 Business Intelligence
# ### Opportunity Factors
# - [Business opportunity 1]
# - [Business opportunity 2]
# ### Risk Factors
# - [Potential risk 1]
# - [Potential risk 2]
# ## πŸ“ˆ Recommended Actions
# 1. **Immediate Actions**: [Actions needed within 24 hours]
# 2. **Short-term Strategy**: [Execution plan within 1 week]
# 3. **Long-term Strategy**: [Long-term plan over 1 month]
---
**Analysis Completed**: {datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}
"""
return analysis_prompt
def analysis_prompt(video_info, summarization, news, comments_text):
analysis_prompt = f"""
Analyze YouTube video information, summary, comments, and related latest news to create a Markdown format report.
Video Info: {video_info}
Video Summary:
{summarization}
Latest News:
{news}
Comments:
{comments_text}
Please write in the following format:
# 🎬 YouTube Video Analysis Report
## πŸ“Œ Key Keywords
`keyword`
## 🎯 Video Overview
[Summary of main video content]
## πŸ’¬ Comment Sentiment Analysis
### πŸ“Š Sentiment Distribution
- **Positive**: X%
- **Negative**: Y%
- **Neutral**: Z%
### πŸ” Key Comment Insights
1. **Positive Reactions**: [Summary of main positive comments]
2. **Negative Reactions**: [Summary of main negative comments]
3. **Core Issues**: [Main topics found in comments]
### πŸ” Comments
1. Positive Comments: [Positive comments with sentiment classification and reasoning]
2. Negative Comments: [Negative comments with sentiment classification and reasoning]
3. Neutral Comments: [Neutral comments with sentiment classification and reasoning]
## πŸ“° Latest News Relevance
[Analysis of correlation between news and video/comments]
## πŸ’‘ Key Insights
1. [First major finding]
2. [Second major finding]
3. [Third major finding]
# ## 🎯 Business Intelligence
# ### Opportunity Factors
# - [Business opportunity 1]
# - [Business opportunity 2]
# ### Risk Factors
# - [Potential risk 1]
# - [Potential risk 2]
# ## πŸ“ˆ Recommended Actions
# 1. **Immediate Actions**: [Actions needed within 24 hours]
# 2. **Short-term Strategy**: [Execution plan within 1 week]
# 3. **Long-term Strategy**: [Long-term plan over 1 month]
---
**Analysis Completed**: {datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}
"""
return analysis_prompt
def error_message(video_id):
error_msg = f"""
# ❌ Analysis Failed
**Error Message:** {str(e)}
**Debug Information:**
- Video ID: {video_id}
- Time: {datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}
**Check Items:**
1. Verify YouTube Video ID is correct
2. Verify API key is valid
3. Check network connection
**Detailed Error:**
```
{traceback.format_exc()}
```
"""
return error_msg
def analysis_prompt2(content_type, all_comments ):
analysis_prompt = f"""
Please analyze the sentiment of the following {content_type} comments in detail:
{all_comments}
Please write detailed analysis results in the following format:
### πŸ“Š Sentiment Distribution
- **Positive**: X% (specific numbers)
- **Negative**: Y% (specific numbers)
- **Neutral**: Z% (specific numbers)
### πŸ” Sentiment-based Comment Analysis
#### 😊 Positive Comments
**Representative Comment Examples:**
- "Actual comment 1" β†’ Reason for positive classification
- "Actual comment 2" β†’ Reason for positive classification
- "Actual comment 3" β†’ Reason for positive classification
**Main Positive Keywords:** keyword1, keyword2, keyword3
#### 😑 Negative Comments
**Representative Comment Examples:**
- "Actual comment 1" β†’ Reason for negative classification
- "Actual comment 2" β†’ Reason for negative classification
- "Actual comment 3" β†’ Reason for negative classification
**Main Negative Keywords:** keyword1, keyword2, keyword3
#### 😐 Neutral Comments
**Representative Comment Examples:**
- "Actual comment 1" β†’ Reason for neutral classification
- "Actual comment 2" β†’ Reason for neutral classification
**Main Neutral Keywords:** keyword1, keyword2, keyword3
### πŸ’‘ Key Insights
1. **Sentiment Trends**: [Overall sentiment trend analysis]
2. **Main Topics**: [Most mentioned issues in comments]
3. **Viewer Reactions**: [Main interests or reactions of viewers]
### πŸ“ˆ Summary
**One-line Summary:** [Summarize overall comment sentiment and main content in one sentence]"""
return analysis_prompt
def channel_markdown_result(videos, total_video_views, avg_video_views, videos_text, shorts, total_shorts_views, avg_shorts_views, shorts_text, video_sentiment, shorts_sentiment):
markdown_result = f"""# πŸ“Š YouTube Channel Analysis Report
## 🎬 Latest Regular Videos ({len(videos)} videos)
**Total Views**: {total_video_views:,} | **Average Views**: {avg_video_views:,.0f}
{videos_text}
---
## 🎯 Latest Shorts ({len(shorts)} videos)
**Total Views**: {total_shorts_views:,} | **Average Views**: {avg_shorts_views:,.0f}
{shorts_text}
---
## πŸ’¬ Comment Sentiment Analysis
### πŸ“Ί Regular Video Comment Reactions
{video_sentiment}
### πŸ“± Shorts Comment Reactions
{shorts_sentiment}
---
## πŸ’‘ Key Insights
- **Regular Video Average**: {avg_video_views:,.0f} views
- **Shorts Average**: {avg_shorts_views:,.0f} views
- **Performance Comparison**: {"Regular videos perform better" if avg_video_views > avg_shorts_views else "Shorts perform better" if avg_shorts_views > avg_video_views else "Similar performance"}
---
**Analysis Completed**: {datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}
"""
return markdown_result