File size: 7,789 Bytes
e7251ed |
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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
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 |