Enhance video metadata extraction and update player template to display additional information
This commit is contained in:
@@ -49,7 +49,37 @@ def player():
|
||||
proxy_hls_url=proxy_hls_url,
|
||||
direct_url=stream_info.get("direct_url"),
|
||||
title=stream_info.get("title", "Video"),
|
||||
thumbnail=stream_info.get("thumbnail")
|
||||
thumbnail=stream_info.get("thumbnail"),
|
||||
# Pass all metadata to template
|
||||
description=stream_info.get("description"),
|
||||
uploader=stream_info.get("uploader"),
|
||||
uploader_url=stream_info.get("uploader_url"),
|
||||
duration=stream_info.get("duration"),
|
||||
duration_string=stream_info.get("duration_string"),
|
||||
upload_date=stream_info.get("upload_date"),
|
||||
view_count=stream_info.get("view_count"),
|
||||
like_count=stream_info.get("like_count"),
|
||||
dislike_count=stream_info.get("dislike_count"),
|
||||
comment_count=stream_info.get("comment_count"),
|
||||
age_limit=stream_info.get("age_limit"),
|
||||
categories=stream_info.get("categories"),
|
||||
tags=stream_info.get("tags"),
|
||||
language=stream_info.get("language"),
|
||||
license=stream_info.get("license"),
|
||||
channel=stream_info.get("channel"),
|
||||
channel_url=stream_info.get("channel_url"),
|
||||
channel_id=stream_info.get("channel_id"),
|
||||
extractor=stream_info.get("extractor"),
|
||||
extractor_key=stream_info.get("extractor_key"),
|
||||
display_id=stream_info.get("display_id"),
|
||||
url=stream_info.get("url"),
|
||||
fulltitle=stream_info.get("fulltitle"),
|
||||
resolution=stream_info.get("resolution"),
|
||||
format=stream_info.get("format"),
|
||||
format_note=stream_info.get("format_note"),
|
||||
filesize=stream_info.get("filesize"),
|
||||
filesize_approx=stream_info.get("filesize_approx"),
|
||||
hls_url=hls_url
|
||||
)
|
||||
except Exception as e:
|
||||
logger.error(f"Error getting stream info: {e}")
|
||||
|
||||
@@ -138,14 +138,47 @@ def _get_video_info(video_url: str) -> dict:
|
||||
|
||||
|
||||
def get_stream_info(video_url: str) -> dict:
|
||||
"""Get video info (title, hls_url, thumbnail)."""
|
||||
"""Get video info with all available metadata."""
|
||||
info = _get_video_info(video_url)
|
||||
return {
|
||||
|
||||
# Extract useful metadata from raw_info
|
||||
raw = info.get("raw_info", {})
|
||||
metadata = {
|
||||
"title": info["title"],
|
||||
"hls_url": info["hls_url"],
|
||||
"direct_url": info.get("direct_url"),
|
||||
"thumbnail": info["thumbnail"],
|
||||
"hls_url": info.get("hls_url"),
|
||||
"direct_url": info.get("direct_url"),
|
||||
# Additional metadata
|
||||
"description": raw.get("description"),
|
||||
"uploader": raw.get("uploader"),
|
||||
"uploader_url": raw.get("uploader_url"),
|
||||
"duration": raw.get("duration"),
|
||||
"upload_date": raw.get("upload_date"),
|
||||
"view_count": raw.get("view_count"),
|
||||
"like_count": raw.get("like_count"),
|
||||
"dislike_count": raw.get("dislike_count"),
|
||||
"comment_count": raw.get("comment_count"),
|
||||
"age_limit": raw.get("age_limit"),
|
||||
"categories": raw.get("categories"),
|
||||
"tags": raw.get("tags"),
|
||||
"language": raw.get("language"),
|
||||
"license": raw.get("license"),
|
||||
"channel": raw.get("channel"),
|
||||
"channel_url": raw.get("channel_url"),
|
||||
"channel_id": raw.get("channel_id"),
|
||||
"extractor": raw.get("extractor"),
|
||||
"extractor_key": raw.get("extractor_key"),
|
||||
"display_id": raw.get("display_id"),
|
||||
"url": raw.get("url"),
|
||||
"fulltitle": raw.get("fulltitle"),
|
||||
"duration_string": raw.get("duration_string"),
|
||||
"resolution": raw.get("resolution"),
|
||||
"format": raw.get("format"),
|
||||
"format_note": raw.get("format_note"),
|
||||
"filesize": raw.get("filesize"),
|
||||
"filesize_approx": raw.get("filesize_approx"),
|
||||
}
|
||||
return metadata
|
||||
|
||||
|
||||
def get_hls_playlist(video_url: str) -> str:
|
||||
|
||||
+182
-3
@@ -7,17 +7,18 @@
|
||||
<link rel="stylesheet" href="https://unpkg.com/mvp.css">
|
||||
<style>
|
||||
body {
|
||||
max-width: 900px;
|
||||
max-width: 1100px;
|
||||
margin: 0 auto;
|
||||
padding: 1rem;
|
||||
}
|
||||
h1 {
|
||||
margin-bottom: 1rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
.video-container {
|
||||
width: 100%;
|
||||
background: #000;
|
||||
aspect-ratio: 16 / 9;
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
video {
|
||||
width: 100%;
|
||||
@@ -27,16 +28,194 @@
|
||||
display: inline-block;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.metadata {
|
||||
background: #f5f5f5;
|
||||
padding: 1rem;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.metadata h2 {
|
||||
margin-top: 0;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
.metadata-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
||||
gap: 0.75rem;
|
||||
}
|
||||
.metadata-item {
|
||||
word-break: break-word;
|
||||
}
|
||||
.metadata-label {
|
||||
font-weight: bold;
|
||||
color: #666;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
.metadata-value {
|
||||
color: #333;
|
||||
}
|
||||
.thumbnail {
|
||||
max-width: 100%;
|
||||
max-height: 200px;
|
||||
margin: 1rem 0;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.description {
|
||||
background: #f9f9f9;
|
||||
padding: 1rem;
|
||||
border-radius: 8px;
|
||||
margin-bottom: 1rem;
|
||||
white-space: pre-wrap;
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<a href="/" class="back-link">← Back</a>
|
||||
|
||||
{% if thumbnail %}
|
||||
<img src="{{ thumbnail }}" alt="{{ title }}" class="thumbnail">
|
||||
{% endif %}
|
||||
|
||||
<h1>{{ title }}</h1>
|
||||
|
||||
<div class="video-container">
|
||||
<video controls id="video">
|
||||
Your browser does not support video playback.
|
||||
</video>
|
||||
</div>
|
||||
|
||||
{% if description %}
|
||||
<div class="description">
|
||||
<h3>Description</h3>
|
||||
{{ description }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="metadata">
|
||||
<h2>Video Information</h2>
|
||||
<div class="metadata-grid">
|
||||
{% if uploader %}
|
||||
<div class="metadata-item">
|
||||
<div class="metadata-label">Uploader</div>
|
||||
<div class="metadata-value">{{ uploader }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if channel %}
|
||||
<div class="metadata-item">
|
||||
<div class="metadata-label">Channel</div>
|
||||
<div class="metadata-value">{{ channel }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if duration_string %}
|
||||
<div class="metadata-item">
|
||||
<div class="metadata-label">Duration</div>
|
||||
<div class="metadata-value">{{ duration_string }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if upload_date %}
|
||||
<div class="metadata-item">
|
||||
<div class="metadata-label">Upload Date</div>
|
||||
<div class="metadata-value">{{ upload_date }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if view_count %}
|
||||
<div class="metadata-item">
|
||||
<div class="metadata-label">Views</div>
|
||||
<div class="metadata-value">{{ "{:,}".format(view_count) }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if like_count %}
|
||||
<div class="metadata-item">
|
||||
<div class="metadata-label">Likes</div>
|
||||
<div class="metadata-value">{{ "{:,}".format(like_count) }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if comment_count %}
|
||||
<div class="metadata-item">
|
||||
<div class="metadata-label">Comments</div>
|
||||
<div class="metadata-value">{{ "{:,}".format(comment_count) }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if categories %}
|
||||
<div class="metadata-item">
|
||||
<div class="metadata-label">Categories</div>
|
||||
<div class="metadata-value">{% for cat in categories %}{{ cat }}{% if not loop.last %}, {% endif %}{% endfor %}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if language %}
|
||||
<div class="metadata-item">
|
||||
<div class="metadata-label">Language</div>
|
||||
<div class="metadata-value">{{ language }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if extractor %}
|
||||
<div class="metadata-item">
|
||||
<div class="metadata-label">Source</div>
|
||||
<div class="metadata-value">{{ extractor }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if resolution %}
|
||||
<div class="metadata-item">
|
||||
<div class="metadata-label">Resolution</div>
|
||||
<div class="metadata-value">{{ resolution }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if format %}
|
||||
<div class="metadata-item">
|
||||
<div class="metadata-label">Format</div>
|
||||
<div class="metadata-value">{{ format }}{% if format_note %} ({{ format_note }}){% endif %}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if filesize_approx %}
|
||||
<div class="metadata-item">
|
||||
<div class="metadata-label">Size (approx)</div>
|
||||
<div class="metadata-value">{{ filesize_approx }}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if tags %}
|
||||
<div class="metadata">
|
||||
<h2>Tags</h2>
|
||||
<div class="metadata-value">
|
||||
{% for tag in tags %}
|
||||
<span style="display: inline-block; background: #e0e0e0; padding: 2px 8px; border-radius: 4px; margin: 2px;">{{ tag }}</span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if hls_url %}
|
||||
<div class="metadata">
|
||||
<h2>Stream URLs</h2>
|
||||
<div class="metadata-item">
|
||||
<div class="metadata-label">HLS URL</div>
|
||||
<div class="metadata-value" style="word-break: break-all; font-size: 0.85rem;">{{ hls_url[:200] }}{% if hls_url|length > 200 %}...{% endif %}</div>
|
||||
</div>
|
||||
{% if direct_url %}
|
||||
<div class="metadata-item">
|
||||
<div class="metadata-label">Direct URL</div>
|
||||
<div class="metadata-value" style="word-break: break-all; font-size: 0.85rem;">{{ direct_url[:200] }}{% if direct_url|length > 200 %}...{% endif %}</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
|
||||
<script>
|
||||
const video = document.getElementById('video');
|
||||
@@ -64,4 +243,4 @@
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
Reference in New Issue
Block a user