Skip to content

Commit

Permalink
Merge pull request #182 from vmx/recording-details
Browse files Browse the repository at this point in the history
feat(videos): add video recording details
  • Loading branch information
MerleLiuKun authored Sep 9, 2024
2 parents 748b98c + 7716a13 commit e8c2d18
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pyyoutube/models/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,17 @@ class VideoStatus(BaseModel, DatetimeTimeMixin):
selfDeclaredMadeForKids: Optional[bool] = field(default=None, repr=False)


@dataclass
class VideoRecordingDetails(BaseModel, DatetimeTimeMixin):
"""
A class representing the video recording details.
Refer: https://developers.google.com/youtube/v3/docs/videos#recordingDetails
"""

recordingDate: Optional[str] = field(default=None, repr=False)


@dataclass
class VideoLiveStreamingDetails(BaseModel, DatetimeTimeMixin):
"""
Expand Down Expand Up @@ -251,6 +262,7 @@ class Video(BaseResource):
statistics: Optional[VideoStatistics] = field(default=None, repr=False)
topicDetails: Optional[VideoTopicDetails] = field(default=None, repr=False)
player: Optional[Player] = field(default=None, repr=False)
recordingDetails: Optional[VideoRecordingDetails] = field(default=None, repr=False)
liveStreamingDetails: Optional[VideoLiveStreamingDetails] = field(
default=None, repr=False
)
Expand Down
1 change: 1 addition & 0 deletions pyyoutube/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"statistics",
"status",
"topicDetails",
"recordingDetails",
"liveStreamingDetails",
}

Expand Down
3 changes: 3 additions & 0 deletions testdata/modeldata/videos/video_recording_details.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recordingDate": "2024-07-03T00:00:00Z"
}
10 changes: 10 additions & 0 deletions tests/models/test_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class VideoModelTest(unittest.TestCase):
VIDEO_INFO = json.loads(f.read().decode("utf-8"))
with open(BASE_PATH + "video_api_response.json", "rb") as f:
VIDEO_API_RESPONSE = json.loads(f.read().decode("utf-8"))
with open(BASE_PATH + "video_recording_details.json", "rb") as f:
RECORDING_DETAILS = json.loads(f.read().decode("utf-8"))

def testVideoContentDetails(self) -> None:
m = models.VideoContentDetails.from_dict(self.CONTENT_DETAILS_INFO)
Expand Down Expand Up @@ -97,3 +99,11 @@ def testVideoListResponse(self) -> None:
self.assertEqual(m.kind, "youtube#videoListResponse")
self.assertEqual(m.pageInfo.totalResults, 1)
self.assertEqual(m.items[0].id, "D-lhorsDlUQ")

def testVideoRecordingDetails(self) -> None:
m = models.VideoRecordingDetails.from_dict(self.RECORDING_DETAILS)

self.assertEqual(
m.string_to_datetime(m.recordingDate).isoformat(),
"2024-07-03T00:00:00+00:00",
)

0 comments on commit e8c2d18

Please sign in to comment.