cd /news/artificial-intelligence/automatically-attaching-youtube-vide… · home topics artificial-intelligence article
[ARTICLE · art-23139] src=dev.to pub= topic=artificial-intelligence verified=true sentiment=· neutral

Automatically Attaching YouTube Video Footers to AI Tutorial Questions: Gemini LLM & YouTube Search Service Integration

A developer integrated Gemini LLM and YouTube Search services to automatically attach relevant video footers to AI tutorial questions. The system initially struggled when Gemini extracted overly general keywords from ambiguous queries, but the developer resolved this by modifying prompts to generate more specific search terms and adding filtering logic to YouTube Search for tutorial-appropriate videos.

read3 min publishedJun 6, 2026

Automatically Attaching YouTube Video Footers to Tutorial-Style Questions: An Integration Log of gemini_llm_service & youtube_search_service

I've been developing a feature to automatically attach YouTube video footers to AI tutorial questions. My initial thought was simple: find a YouTube video relevant to the question and display it as a footer.

My first approach was to have gemini_llm_service

understand the intent of the question and then use those keywords to search for videos via youtube_search_service

. However, this turned out to be harder than I expected.

When questions were a bit ambiguous, gemini_llm_service

often extracted irrelevant keywords. For example, for a question like "How to build a website with Python," just searching with the keyword "website" would yield overly general results.

from gemini_llm_service import GeminiLLM
from youtube_search_service import YouTubeSearch

gemini = GeminiLLM()
youtube = YouTubeSearch()

question = "Tell me how to build a simple website with Python"
keywords = gemini.extract_keywords(question) # Problem often occurred here

search_results = youtube.search(keywords)

During this process, the accuracy of keywords returned by gemini_llm_service

was low, repeatedly leading to youtube_search_service

failing to find the desired videos. I probably spent about 3 hours just struggling with this part.

Ultimately, the problem was that gemini_llm_service

wasn't fully grasping the context of the question and was extracting overly general keywords. I realized that especially for tutorial-style questions, it's difficult to find the right video based solely on keywords.

So, I modified the prompt to instruct gemini_llm_service

to generate more specific search keywords only when it clearly identifies the question as a tutorial request. I also implemented additional filtering logic in youtube_search_service

to improve the relevance of search results.

prompt = f"""
You are an AI assistant that helps users find relevant YouTube tutorials.
Given the following user question, extract specific keywords that would be ideal for searching YouTube for a tutorial.
Focus on the core topic and any specific technologies or methods mentioned.
If the question is clearly a request for a tutorial, be more specific in your keyword extraction.

User Question: "{user_question}"
Keywords:
"""

def search_and_filter_tutorials(query):
    results = youtube_search_service.search(query)
    filtered_results = [video for video in results if is_likely_tutorial(video)]
    return filtered_results

def is_likely_tutorial(video):
    title = video.get('title', '').lower()
    description = video.get('description', '').lower()
    duration = video.get('duration_seconds', 0)

    if any(keyword in title for keyword in ['tutorial', 'how to', 'guide']):
        return True
    if 'python' in description and 'web development' in description: # Example
        return True
    if 300 < duration < 3600: # Videos between 5 minutes and 1 hour
        return True
    return False

By integrating gemini_llm_service

and youtube_search_service

more closely and adjusting the logic to suit each service's characteristics, the system started working much more stably.

gemini_llm_service

and youtube_search_service

.

── more in #artificial-intelligence 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/automatically-attach…] indexed:0 read:3min 2026-06-06 ·