youtube summarizor

By Highlight User
18 Users

summarizes youtube

Prompt

import re

regex = r"^(Summarize|...)(?:the |...)?(?:["'](.*?)["'])?(?:[:.,-]? )?(?:https?:\/\/(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+))"

test_strings = [
    "Summarize this https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "Give me a summary of 'How to bake a cake' https://youtu.be/abcdef12345",
    "Recap the video on the topic of 'Quantum Physics': https://youtube.com/watch?v=xyz123abc78",
    "TL;DR https://m.youtube.com/watch?v=somethingElse", #Does not capture mobile youtube links
    "Summarize 'Cooking with John' - https://www.youtube.com/watch?v=testVideo",
    "Summarize this random text", #Doesn't match, as it does not have a youtube link
]

for test_string in test_strings:
    match = re.match(regex, test_string)
    if match:
        print("Match found!")
        print("Full match:", match.group(0))
        print("Topic (if any):", match.group(1)) #Captures the topic in quotes
        print("Video ID:", match.group(2)) #Captures the video ID
    else:
        print("No match.")
    print("-" * 20)

More like this


How it works