mem0
mem0 copied to clipboard
Fix_#1343: Correctly Store YouTube Video Publish Date with Timezone Support
Description
This PR resolves the issue where the publish date of YouTube videos was being stored as YYYY-MM-DD 00:00:00, without the time component. This caused issues when handling time zones. The fix ensures the publish date is stored with the correct time and in ISO 8601 format.
Fixes # (1343) file: embedchain/loaders/youtube_video.py
- Updated the code to properly handle the publishedAt field from the metadata.
- Ensured that the publishedAt timestamp is converted to an ISO 8601 format (e.g., 2024-04-15T14:30:00Z) to correctly store both the date and time, considering UTC timestamps.
- Introduced logic to replace the Z suffix with +00:00 for UTC timestamps, ensuring that the time zone is properly handled.
- Added error logging to capture any parsing issues with the publishedAt field.
- imported datetime
Type of change
- [-] Bug fix (non-breaking change which fixes an issue)
How Has This Been Tested?
Updated code to convert publishedAt timestamp to ISO 8601 format. Validated that timestamps are now stored with time and timezone, e.g., 2024-04-15T15:00:00Z. Manually tested the following cases: * Correct conversion for UTC (Z suffix) timestamps. * Conversion for time zone-aware timestamps (e.g., +02:00). * Ensured any invalid timestamps are logged with a warning.
Checklist:
- [-] My code follows the style guidelines of this project
- [-] I have performed a self-review of my own code
- [-] I have checked my code and corrected any misspellings
Maintainer Checklist
- [-] closes #1343
- [ ] Made sure Checks passed
Hey @hensikavar Thanks for the PR, can you please share an example here where the publication date is properly captured?
Changes in file: mem0/embedchain/embedchain/youtube_video
I have converted a publish date which is coming in ISO format and the data will be stored in proper format in metadata.
Thanks, @hensikavar! This looks great. Could you share a code example where a YouTube URL is passed in, a search call is made, and the output includes metadata? That would help us see it in action.
on running test_youtube_video.py module not found error is occurring:
Hey @hensikavar Please run it while being in the \embedchain directory. And the command would look like poetry run pytest tests\loaders\test_youtube_video.py.
I have made changes in test_youtube_video.py file to check the specific date format:
all the tests are passed and the sample test data is been shown in console:
@Dev-Khant this is what you required as example code or anything else?
If anything else is required please let me know
Hey @hensikavar Can you please run poetry lock [--no-update] because tests are failing? Thanks.
@hensikavar Can you please update the mem0 dependency in pyproject.toml to 0.1.48 and update .lock file. Tests are failing because of it.