102 lines
4.3 KiB
Python
102 lines
4.3 KiB
Python
import yt_dlp
|
|
from rich.console import Console
|
|
from rich.panel import Panel
|
|
from rich.table import Table
|
|
from rich.text import Text
|
|
from rich import box
|
|
|
|
# Initialize the console for rich output
|
|
console = Console()
|
|
|
|
# Banner text
|
|
def show_banner():
|
|
banner_text = Text("""
|
|
██████╗ ██████╗ ███████╗ █████╗ ██████╗ ███████╗██╗ ██╗██╗
|
|
██╔══██╗██╔══██╗██╔════╝██╔══██╗██╔══██╗██╔════╝██║ ██║██║
|
|
██║ ██║██████╔╝█████╗ ███████║██║ ██║█████╗ ██║ ██║██║
|
|
██║ ██║██╔══██╗██╔══╝ ██╔══██║██║ ██║██╔══╝ ██║ ██║██║
|
|
██████╔╝██║ ██║███████╗██║ ██║██████╔╝██║ ╚██████╔╝███████╗
|
|
╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝ ╚═════╝ ╚══════╝
|
|
""", style="bold red")
|
|
|
|
# Create a yellow panel to wrap the banner text, centered manually
|
|
banner_panel = Panel(banner_text,
|
|
border_style="yellow",
|
|
title="YouTube Video Info",
|
|
subtitle="Grab All Details",
|
|
style="green",
|
|
width=70, # Increased width for the banner
|
|
expand=False,
|
|
padding=(1, 2), # Adjusted padding for better appearance
|
|
)
|
|
|
|
# Print the banner
|
|
console.print(banner_panel)
|
|
|
|
def show_credits():
|
|
# Display credits in a box
|
|
credits_text = Text("Credits: Klez A.K.A Boomer", style="green")
|
|
console.print(Panel(credits_text, title="Credits", border_style="green"))
|
|
|
|
def get_video_info():
|
|
# Prompt the user to input the YouTube video ID
|
|
video_id = input("Enter the YouTube video ID: ")
|
|
|
|
# Prepare the URL from the video ID
|
|
url = f"https://www.youtube.com/watch?v={video_id}"
|
|
|
|
# Create a yt-dlp options dictionary
|
|
ydl_opts = {}
|
|
|
|
# Use yt-dlp to extract video information
|
|
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
|
info = ydl.extract_info(url, download=False)
|
|
|
|
# Extract all available data
|
|
title = info.get('title')
|
|
uploader = info.get('uploader')
|
|
upload_date = info.get('upload_date') # in format YYYYMMDD
|
|
view_count = info.get('view_count')
|
|
like_count = info.get('like_count')
|
|
duration = info.get('duration')
|
|
description = info.get('description')
|
|
categories = info.get('categories')
|
|
tags = info.get('tags')
|
|
channel_id = info.get('channel_id')
|
|
channel_url = f"https://www.youtube.com/channel/{channel_id}"
|
|
video_url = info.get('webpage_url')
|
|
|
|
# Format upload date to MM-DD-YYYY
|
|
formatted_date = f"{upload_date[4:6]}-{upload_date[6:]}-{upload_date[:4]}"
|
|
|
|
# Create a table with rich UI for displaying the data
|
|
table = Table(title="YouTube Video Information", box=box.DOUBLE_EDGE)
|
|
|
|
table.add_column("Attribute", style="yellow", no_wrap=True)
|
|
table.add_column("Value", style="green")
|
|
|
|
# Add rows to the table with the relevant data
|
|
table.add_row("Title", title)
|
|
table.add_row("Uploader", uploader)
|
|
table.add_row("Upload Date", formatted_date)
|
|
table.add_row("Views", str(view_count))
|
|
table.add_row("Likes", str(like_count))
|
|
table.add_row("Duration", f"{duration // 60} minutes {duration % 60} seconds")
|
|
table.add_row("Categories", ', '.join(categories) if categories else "N/A")
|
|
table.add_row("Tags", ', '.join(tags) if tags else "N/A")
|
|
table.add_row("Channel URL", channel_url)
|
|
table.add_row("Video URL", video_url)
|
|
|
|
# Display the table in a box
|
|
console.print(Panel(table, title="Video Information", border_style="yellow"))
|
|
|
|
# Display the full description in a green panel
|
|
console.print(Panel(Text(description, style="green"), title="Description", border_style="yellow"))
|
|
|
|
# Show banner and credits
|
|
show_banner()
|
|
show_credits()
|
|
|
|
# Call the function to get video info
|
|
get_video_info()
|