mcp-server-youtube-info 0.1.1__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mcp_server_youtube_info-0.1.1 → mcp_server_youtube_info-0.1.2}/PKG-INFO +3 -1
- {mcp_server_youtube_info-0.1.1 → mcp_server_youtube_info-0.1.2}/pyproject.toml +8 -2
- mcp_server_youtube_info-0.1.2/src/mcp_server_youtube_info/server.py +99 -0
- {mcp_server_youtube_info-0.1.1 → mcp_server_youtube_info-0.1.2}/uv.lock +2 -2
- mcp_server_youtube_info-0.1.1/src/mcp_server_youtube_info/server.py +0 -61
- {mcp_server_youtube_info-0.1.1 → mcp_server_youtube_info-0.1.2}/.gitignore +0 -0
- {mcp_server_youtube_info-0.1.1 → mcp_server_youtube_info-0.1.2}/README.md +0 -0
- {mcp_server_youtube_info-0.1.1 → mcp_server_youtube_info-0.1.2}/src/mcp_server_youtube_info/__init__.py +0 -0
- {mcp_server_youtube_info-0.1.1 → mcp_server_youtube_info-0.1.2}/src/mcp_server_youtube_info/__main__.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: mcp-server-youtube-info
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.2
|
4
4
|
Summary: A YouTube information retrieval server implementation for Model Context Protocol (MCP)
|
5
5
|
Project-URL: Homepage, https://github.com/yareyaredesuyo/mcp-servers
|
6
6
|
Project-URL: Repository, https://github.com/yareyaredesuyo/mcp-servers.git
|
@@ -18,6 +18,8 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
18
18
|
Requires-Python: >=3.10
|
19
19
|
Requires-Dist: argparse>=1.4.0
|
20
20
|
Requires-Dist: fastmcp>=2.5.2
|
21
|
+
Requires-Dist: httpx>=0.28.1
|
22
|
+
Requires-Dist: pillow>=11.2.1
|
21
23
|
Requires-Dist: yt-dlp>=2025.5.22
|
22
24
|
Description-Content-Type: text/markdown
|
23
25
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "mcp-server-youtube-info"
|
3
|
-
version = "0.1.
|
3
|
+
version = "0.1.2"
|
4
4
|
description = "A YouTube information retrieval server implementation for Model Context Protocol (MCP)"
|
5
5
|
readme = "README.md"
|
6
6
|
requires-python = ">=3.10"
|
@@ -15,7 +15,13 @@ classifiers = [
|
|
15
15
|
"Programming Language :: Python :: 3.10",
|
16
16
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
17
17
|
]
|
18
|
-
dependencies = [
|
18
|
+
dependencies = [
|
19
|
+
"argparse>=1.4.0",
|
20
|
+
"fastmcp>=2.5.2",
|
21
|
+
"httpx>=0.28.1",
|
22
|
+
"pillow>=11.2.1",
|
23
|
+
"yt-dlp>=2025.5.22",
|
24
|
+
]
|
19
25
|
|
20
26
|
[project.urls]
|
21
27
|
Homepage = "https://github.com/yareyaredesuyo/mcp-servers"
|
@@ -0,0 +1,99 @@
|
|
1
|
+
from fastmcp import FastMCP, Image
|
2
|
+
import yt_dlp
|
3
|
+
import io
|
4
|
+
import httpx
|
5
|
+
from PIL import Image as PILImage
|
6
|
+
|
7
|
+
mcp = FastMCP("MCP YouTube Info Server", dependencies=["httpx", "Pillow"])
|
8
|
+
|
9
|
+
def extract_info(video_id: str) -> dict:
|
10
|
+
"""YouTubeの動画情報を取得します。
|
11
|
+
|
12
|
+
Args:
|
13
|
+
video_id (str): YouTube動画ID
|
14
|
+
|
15
|
+
Returns:
|
16
|
+
dict: 動画情報
|
17
|
+
"""
|
18
|
+
ydl_opts = {
|
19
|
+
'quiet': True,
|
20
|
+
'no_warnings': True,
|
21
|
+
'extract_flat': True,
|
22
|
+
}
|
23
|
+
|
24
|
+
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
25
|
+
try:
|
26
|
+
url = f"https://www.youtube.com/watch?v={video_id}"
|
27
|
+
info = ydl.extract_info(url, download=False)
|
28
|
+
return info
|
29
|
+
except Exception as e:
|
30
|
+
raise Exception(f"動画情報の取得に失敗しました: {str(e)}")
|
31
|
+
|
32
|
+
@mcp.tool()
|
33
|
+
def metainfo(video_id: str) -> dict:
|
34
|
+
"""YouTube動画のメタ情報を取得します。
|
35
|
+
|
36
|
+
Args:
|
37
|
+
video_id (str): YouTube動画ID
|
38
|
+
|
39
|
+
Returns:
|
40
|
+
dict: yt-dlpから取得した生のメタ情報
|
41
|
+
"""
|
42
|
+
try:
|
43
|
+
return extract_info(video_id)
|
44
|
+
except Exception as e:
|
45
|
+
raise Exception(f"メタ情報の取得に失敗しました: {str(e)}")
|
46
|
+
|
47
|
+
@mcp.tool()
|
48
|
+
def thumbnail(video_id: str) -> str:
|
49
|
+
"""YouTubeのサムネイルURLを取得します。
|
50
|
+
|
51
|
+
Args:
|
52
|
+
video_id (str): YouTube動画ID
|
53
|
+
|
54
|
+
Returns:
|
55
|
+
str: サムネイル画像のURL
|
56
|
+
"""
|
57
|
+
try:
|
58
|
+
info = extract_info(video_id)
|
59
|
+
thumbnail_url = info.get('thumbnail')
|
60
|
+
if not thumbnail_url:
|
61
|
+
raise Exception("サムネイルURLが見つかりません")
|
62
|
+
return thumbnail_url
|
63
|
+
except Exception as e:
|
64
|
+
raise Exception(f"サムネイルの取得に失敗しました: {str(e)}")
|
65
|
+
@mcp.tool()
|
66
|
+
def download_thumbnail(video_id: str) -> Image:
|
67
|
+
"""
|
68
|
+
指定されたYouTube動画のサムネイルをダウンロードし、Imageとして返す。
|
69
|
+
|
70
|
+
Args:
|
71
|
+
video_id: ダウンロードするyoutubeサムネイルのvideo_id
|
72
|
+
Returns:
|
73
|
+
Image: ダウンロードした画像データ
|
74
|
+
"""
|
75
|
+
try:
|
76
|
+
info = extract_info(video_id)
|
77
|
+
thumbnail_url = info.get('thumbnail')
|
78
|
+
if not thumbnail_url:
|
79
|
+
raise Exception("サムネイルURLが見つかりません")
|
80
|
+
except Exception as e:
|
81
|
+
raise Exception(f"サムネイルの取得に失敗しました: {str(e)}")
|
82
|
+
|
83
|
+
try:
|
84
|
+
with httpx.Client() as client:
|
85
|
+
response = client.get(thumbnail_url)
|
86
|
+
response.raise_for_status()
|
87
|
+
|
88
|
+
# 画像を読み込んで圧縮
|
89
|
+
image = PILImage.open(io.BytesIO(response.content)).convert('RGB')
|
90
|
+
buffer = io.BytesIO()
|
91
|
+
image.save(buffer, format="JPEG", quality=60, optimize=True)
|
92
|
+
|
93
|
+
return Image(data=buffer.getvalue(), format="jpeg")
|
94
|
+
except httpx.HTTPStatusError as e:
|
95
|
+
raise Exception(f"HTTPエラー: {e.response.status_code}")
|
96
|
+
except PILImage.UnidentifiedImageError:
|
97
|
+
raise Exception("有効な画像ファイルではありません")
|
98
|
+
except Exception as e:
|
99
|
+
raise Exception(f"画像のダウンロードに失敗しました: {str(e)}")
|
@@ -185,7 +185,7 @@ wheels = [
|
|
185
185
|
|
186
186
|
[[package]]
|
187
187
|
name = "mcp-server-youtube-info"
|
188
|
-
version = "0.1.
|
188
|
+
version = "0.1.1"
|
189
189
|
source = { editable = "." }
|
190
190
|
dependencies = [
|
191
191
|
{ name = "argparse" },
|
@@ -199,7 +199,7 @@ dependencies = [
|
|
199
199
|
requires-dist = [
|
200
200
|
{ name = "argparse", specifier = ">=1.4.0" },
|
201
201
|
{ name = "fastmcp", specifier = ">=2.5.2" },
|
202
|
-
{ name = "httpx", specifier = ">=0.
|
202
|
+
{ name = "httpx", specifier = ">=0.28.1" },
|
203
203
|
{ name = "pillow", specifier = ">=11.2.1" },
|
204
204
|
{ name = "yt-dlp", specifier = ">=2025.5.22" },
|
205
205
|
]
|
@@ -1,61 +0,0 @@
|
|
1
|
-
from fastmcp import FastMCP
|
2
|
-
import yt_dlp
|
3
|
-
|
4
|
-
mcp = FastMCP("MCP YouTube Info Server")
|
5
|
-
|
6
|
-
def extract_info(video_id: str) -> dict:
|
7
|
-
"""YouTubeの動画情報を取得します。
|
8
|
-
|
9
|
-
Args:
|
10
|
-
video_id (str): YouTube動画ID
|
11
|
-
|
12
|
-
Returns:
|
13
|
-
dict: 動画情報
|
14
|
-
"""
|
15
|
-
ydl_opts = {
|
16
|
-
'quiet': True,
|
17
|
-
'no_warnings': True,
|
18
|
-
'extract_flat': True,
|
19
|
-
}
|
20
|
-
|
21
|
-
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
22
|
-
try:
|
23
|
-
url = f"https://www.youtube.com/watch?v={video_id}"
|
24
|
-
info = ydl.extract_info(url, download=False)
|
25
|
-
return info
|
26
|
-
except Exception as e:
|
27
|
-
raise Exception(f"動画情報の取得に失敗しました: {str(e)}")
|
28
|
-
|
29
|
-
@mcp.tool()
|
30
|
-
def thumbnail(video_id: str) -> str:
|
31
|
-
"""YouTubeのサムネイルURLを取得します。
|
32
|
-
|
33
|
-
Args:
|
34
|
-
video_id (str): YouTube動画ID
|
35
|
-
|
36
|
-
Returns:
|
37
|
-
str: サムネイル画像のURL
|
38
|
-
"""
|
39
|
-
try:
|
40
|
-
info = extract_info(video_id)
|
41
|
-
thumbnail_url = info.get('thumbnail')
|
42
|
-
if not thumbnail_url:
|
43
|
-
raise Exception("サムネイルURLが見つかりません")
|
44
|
-
return thumbnail_url
|
45
|
-
except Exception as e:
|
46
|
-
raise Exception(f"サムネイルの取得に失敗しました: {str(e)}")
|
47
|
-
|
48
|
-
@mcp.tool()
|
49
|
-
def metainfo(video_id: str) -> dict:
|
50
|
-
"""YouTube動画のメタ情報を取得します。
|
51
|
-
|
52
|
-
Args:
|
53
|
-
video_id (str): YouTube動画ID
|
54
|
-
|
55
|
-
Returns:
|
56
|
-
dict: yt-dlpから取得した生のメタ情報
|
57
|
-
"""
|
58
|
-
try:
|
59
|
-
return extract_info(video_id)
|
60
|
-
except Exception as e:
|
61
|
-
raise Exception(f"メタ情報の取得に失敗しました: {str(e)}")
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|