Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import json
|
|
| 3 |
import plotly.express as px
|
| 4 |
import pandas as pd
|
| 5 |
from groq import Groq
|
| 6 |
-
from fpdf2 import FPDF
|
| 7 |
from youtube_comment_downloader import YoutubeCommentDownloader
|
| 8 |
import re
|
| 9 |
import os
|
|
@@ -79,15 +79,6 @@ def fetch_youtube_comments(url, limit=120):
|
|
| 79 |
print(f"Error fetching YouTube: {e}")
|
| 80 |
return []
|
| 81 |
|
| 82 |
-
def fetch_comments_from_url(url):
|
| 83 |
-
if not url or not url.strip():
|
| 84 |
-
return []
|
| 85 |
-
url_lower = url.lower()
|
| 86 |
-
if any(x in url_lower for x in ["youtube", "youtu.be", "pie.yt"]):
|
| 87 |
-
return fetch_youtube_comments(url)
|
| 88 |
-
else:
|
| 89 |
-
return ["[Please use a valid YouTube link]"]
|
| 90 |
-
|
| 91 |
def analyze_comments_with_groq(comments, post_context=""):
|
| 92 |
try:
|
| 93 |
client = Groq(api_key=GROQ_API_KEY)
|
|
@@ -180,7 +171,7 @@ with gr.Blocks(title="CommentSurvey AI", theme=gr.themes.Soft()) as demo:
|
|
| 180 |
if not url or not url.strip():
|
| 181 |
return None, "**❌ Please paste a YouTube URL**", None, None, None, None
|
| 182 |
|
| 183 |
-
comments =
|
| 184 |
|
| 185 |
if len(comments) == 0:
|
| 186 |
return None, "**❌ Could not fetch comments.** Try a different public YouTube video.", None, None, None, None
|
|
|
|
| 3 |
import plotly.express as px
|
| 4 |
import pandas as pd
|
| 5 |
from groq import Groq
|
| 6 |
+
from fpdf2 import FPDF # Correct import
|
| 7 |
from youtube_comment_downloader import YoutubeCommentDownloader
|
| 8 |
import re
|
| 9 |
import os
|
|
|
|
| 79 |
print(f"Error fetching YouTube: {e}")
|
| 80 |
return []
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
def analyze_comments_with_groq(comments, post_context=""):
|
| 83 |
try:
|
| 84 |
client = Groq(api_key=GROQ_API_KEY)
|
|
|
|
| 171 |
if not url or not url.strip():
|
| 172 |
return None, "**❌ Please paste a YouTube URL**", None, None, None, None
|
| 173 |
|
| 174 |
+
comments = fetch_youtube_comments(url)
|
| 175 |
|
| 176 |
if len(comments) == 0:
|
| 177 |
return None, "**❌ Could not fetch comments.** Try a different public YouTube video.", None, None, None, None
|