mcp-server-youtube-info 0.1.1__py3-none-any.whl → 0.1.2__py3-none-any.whl
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/server.py +49 -11
- {mcp_server_youtube_info-0.1.1.dist-info → mcp_server_youtube_info-0.1.2.dist-info}/METADATA +3 -1
- mcp_server_youtube_info-0.1.2.dist-info/RECORD +7 -0
- mcp_server_youtube_info-0.1.1.dist-info/RECORD +0 -7
- {mcp_server_youtube_info-0.1.1.dist-info → mcp_server_youtube_info-0.1.2.dist-info}/WHEEL +0 -0
- {mcp_server_youtube_info-0.1.1.dist-info → mcp_server_youtube_info-0.1.2.dist-info}/entry_points.txt +0 -0
@@ -1,7 +1,10 @@
|
|
1
|
-
from fastmcp import FastMCP
|
1
|
+
from fastmcp import FastMCP, Image
|
2
2
|
import yt_dlp
|
3
|
+
import io
|
4
|
+
import httpx
|
5
|
+
from PIL import Image as PILImage
|
3
6
|
|
4
|
-
mcp = FastMCP("MCP YouTube Info Server")
|
7
|
+
mcp = FastMCP("MCP YouTube Info Server", dependencies=["httpx", "Pillow"])
|
5
8
|
|
6
9
|
def extract_info(video_id: str) -> dict:
|
7
10
|
"""YouTubeの動画情報を取得します。
|
@@ -26,6 +29,21 @@ def extract_info(video_id: str) -> dict:
|
|
26
29
|
except Exception as e:
|
27
30
|
raise Exception(f"動画情報の取得に失敗しました: {str(e)}")
|
28
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
|
+
|
29
47
|
@mcp.tool()
|
30
48
|
def thumbnail(video_id: str) -> str:
|
31
49
|
"""YouTubeのサムネイルURLを取得します。
|
@@ -44,18 +62,38 @@ def thumbnail(video_id: str) -> str:
|
|
44
62
|
return thumbnail_url
|
45
63
|
except Exception as e:
|
46
64
|
raise Exception(f"サムネイルの取得に失敗しました: {str(e)}")
|
47
|
-
|
48
65
|
@mcp.tool()
|
49
|
-
def
|
50
|
-
"""
|
51
|
-
|
66
|
+
def download_thumbnail(video_id: str) -> Image:
|
67
|
+
"""
|
68
|
+
指定されたYouTube動画のサムネイルをダウンロードし、Imageとして返す。
|
69
|
+
|
52
70
|
Args:
|
53
|
-
video_id
|
54
|
-
|
71
|
+
video_id: ダウンロードするyoutubeサムネイルのvideo_id
|
55
72
|
Returns:
|
56
|
-
|
73
|
+
Image: ダウンロードした画像データ
|
57
74
|
"""
|
58
75
|
try:
|
59
|
-
|
76
|
+
info = extract_info(video_id)
|
77
|
+
thumbnail_url = info.get('thumbnail')
|
78
|
+
if not thumbnail_url:
|
79
|
+
raise Exception("サムネイルURLが見つかりません")
|
60
80
|
except Exception as e:
|
61
|
-
raise Exception(f"
|
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)}")
|
{mcp_server_youtube_info-0.1.1.dist-info → mcp_server_youtube_info-0.1.2.dist-info}/METADATA
RENAMED
@@ -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
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
mcp_server_youtube_info/__init__.py,sha256=KD9wJz_1DlOz4LWl_zjMosWuGt_45YImmAEY4rFAHcY,1638
|
2
|
+
mcp_server_youtube_info/__main__.py,sha256=uqSLNeSh8GpjfJjyKqL_tvsDIryo3G_SYCmTqtDnPhs,58
|
3
|
+
mcp_server_youtube_info/server.py,sha256=OvaBA5uVsbCkBwXpIolJJGl8rGqqNYBwxIsUCzjAhqQ,3200
|
4
|
+
mcp_server_youtube_info-0.1.2.dist-info/METADATA,sha256=p4NzIERgY3_87s9NAuGMsn22Q7rXmska3qufuhLdwB0,3749
|
5
|
+
mcp_server_youtube_info-0.1.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
6
|
+
mcp_server_youtube_info-0.1.2.dist-info/entry_points.txt,sha256=CVOJ38APpxqkwNxKV4Bb7kHLC_Zbg8ZjnAevxUONEkk,73
|
7
|
+
mcp_server_youtube_info-0.1.2.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
mcp_server_youtube_info/__init__.py,sha256=KD9wJz_1DlOz4LWl_zjMosWuGt_45YImmAEY4rFAHcY,1638
|
2
|
-
mcp_server_youtube_info/__main__.py,sha256=uqSLNeSh8GpjfJjyKqL_tvsDIryo3G_SYCmTqtDnPhs,58
|
3
|
-
mcp_server_youtube_info/server.py,sha256=w7QU7hr_BO5uaiAXl4gd0ZQ-5kMOToc0HGrejyrdUTk,1655
|
4
|
-
mcp_server_youtube_info-0.1.1.dist-info/METADATA,sha256=ia1nvP44mF7vBDUt8tO3PFVtdkf3GdGWovRewsSol_I,3690
|
5
|
-
mcp_server_youtube_info-0.1.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
6
|
-
mcp_server_youtube_info-0.1.1.dist-info/entry_points.txt,sha256=CVOJ38APpxqkwNxKV4Bb7kHLC_Zbg8ZjnAevxUONEkk,73
|
7
|
-
mcp_server_youtube_info-0.1.1.dist-info/RECORD,,
|
File without changes
|
{mcp_server_youtube_info-0.1.1.dist-info → mcp_server_youtube_info-0.1.2.dist-info}/entry_points.txt
RENAMED
File without changes
|