mcp-server-youtube-info 0.1.0__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.
@@ -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の動画情報を取得します。
@@ -27,32 +30,70 @@ def extract_info(video_id: str) -> dict:
27
30
  raise Exception(f"動画情報の取得に失敗しました: {str(e)}")
28
31
 
29
32
  @mcp.tool()
30
- def thumbnail(video_id: str) -> str:
31
- """YouTubeのサムネイル画像URLを取得します。
33
+ def metainfo(video_id: str) -> dict:
34
+ """YouTube動画のメタ情報を取得します。
32
35
 
33
36
  Args:
34
37
  video_id (str): YouTube動画ID
35
38
 
36
39
  Returns:
37
- str: サムネイル画像のURL
40
+ dict: yt-dlpから取得した生のメタ情報
38
41
  """
39
42
  try:
40
- info = extract_info(video_id)
41
- return info.get('thumbnail')
43
+ return extract_info(video_id)
42
44
  except Exception as e:
43
- raise Exception(f"サムネイルの取得に失敗しました: {str(e)}")
45
+ raise Exception(f"メタ情報の取得に失敗しました: {str(e)}")
44
46
 
45
47
  @mcp.tool()
46
- def metainfo(video_id: str) -> dict:
47
- """YouTube動画のメタ情報を取得します。
48
+ def thumbnail(video_id: str) -> str:
49
+ """YouTubeのサムネイルURLを取得します。
48
50
 
49
51
  Args:
50
52
  video_id (str): YouTube動画ID
51
53
 
52
54
  Returns:
53
- dict: yt-dlpから取得した生のメタ情報
55
+ str: サムネイル画像のURL
54
56
  """
55
57
  try:
56
- return extract_info(video_id)
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
57
63
  except Exception as e:
58
- raise Exception(f"メタ情報の取得に失敗しました: {str(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)}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-server-youtube-info
3
- Version: 0.1.0
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,7 +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: pytube>=15.0.0
21
+ Requires-Dist: httpx>=0.28.1
22
+ Requires-Dist: pillow>=11.2.1
22
23
  Requires-Dist: yt-dlp>=2025.5.22
23
24
  Description-Content-Type: text/markdown
24
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=gwMJf8AWHttuY6x8f-iwUDGjAOdkBDUFtbpz-RNouEg,1519
4
- mcp_server_youtube_info-0.1.0.dist-info/METADATA,sha256=uYkGsfmHpJHE58PGm_NBPrxgtmcoBIxjXoTOnixnaQo,3720
5
- mcp_server_youtube_info-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
6
- mcp_server_youtube_info-0.1.0.dist-info/entry_points.txt,sha256=CVOJ38APpxqkwNxKV4Bb7kHLC_Zbg8ZjnAevxUONEkk,73
7
- mcp_server_youtube_info-0.1.0.dist-info/RECORD,,