|
9 | 9 |
|
10 | 10 | from contextlib import asynccontextmanager |
11 | 11 | from dataclasses import dataclass |
12 | | -from datetime import datetime, timedelta |
| 12 | +from datetime import datetime, timedelta, timezone |
13 | 13 | from functools import lru_cache, partial |
14 | 14 | from itertools import islice |
15 | 15 | from typing import AsyncIterator, Tuple |
|
22 | 22 | from mcp import ServerSession |
23 | 23 | from mcp.server import FastMCP |
24 | 24 | from mcp.server.fastmcp import Context |
25 | | -from pydantic import Field, BaseModel |
| 25 | +from pydantic import Field, BaseModel, AwareDatetime |
26 | 26 | from youtube_transcript_api import YouTubeTranscriptApi, FetchedTranscriptSnippet |
27 | 27 | from youtube_transcript_api.proxies import WebshareProxyConfig, GenericProxyConfig, ProxyConfig |
28 | 28 | from yt_dlp import YoutubeDL |
@@ -83,14 +83,14 @@ class VideoInfo(BaseModel): |
83 | 83 | title: str = Field(description="Title of the video") |
84 | 84 | description: str = Field(description="Description of the video") |
85 | 85 | uploader: str = Field(description="Uploader of the video") |
86 | | - upload_date: datetime = Field(description="Upload date of the video") |
| 86 | + upload_date: AwareDatetime = Field(description="Upload date of the video") |
87 | 87 | duration: str = Field(description="Duration of the video") |
88 | 88 |
|
89 | 89 |
|
90 | 90 | def _parse_time_info(date: int, timestamp: int, duration: int) -> Tuple[datetime, str]: |
91 | 91 | parsed_date = datetime.strptime(str(date), "%Y%m%d").date() |
92 | 92 | parsed_time = datetime.strptime(str(timestamp), "%H%M%S%f").time() |
93 | | - upload_date = datetime.combine(parsed_date, parsed_time) |
| 93 | + upload_date = datetime.combine(parsed_date, parsed_time, timezone.utc) |
94 | 94 | duration_str = humanize.naturaldelta(timedelta(seconds=duration)) |
95 | 95 | return upload_date, duration_str |
96 | 96 |
|
|
0 commit comments