- Django
- DRF (Django-rest-framework)
- Celery (Used for periodic tasks)
- Database: Sqlite3
- There are 2 models
- Video : Used to store the vidoe data.
- Tag : Used to store keyword information about the videos.
- To fetch the videos related to a particular keyword, the admin can create an instance of Tag model using the Admin Panel.
- The added tag will be used next time when the videos are being fetched from youtube.
- Fetched videos from youtube will be added in the database, and a unique Id is given to the video, so that there are no duplicate entires.
- There is a paginated browsable API to get the vidoes from database based on a particular keyword.
GET /youtube/videos/?page=1&tag=football
: Returns the videos stored in the database related to the keyword "football".
Sample Response:
{
"count": 50,
"next": "http://localhost:8000/youtube/videos/?page=2&tag=football",
"previous": null,
"results": [
{
"id": 52,
"title": "Dallas Cowboys vs. San Fransisco 49ers | 2022 Divisional Round Game Highlights",
"published_date": "2023-01-23T02:58:23Z",
"description": "Check out our other channels: NFL Mundo https://www.youtube.com/mundonfl NFL Brasil ...",
"video_id": "CwaKooHmJOM",
"thumbnail_url": "https://i.ytimg.com/vi/CwaKooHmJOM/default.jpg",
"channel_title": "NFL",
"tag": 2
},
{
"id": 54,
"title": "LIVE SHOW: The Latest On Auburn Football Recruiting & The 2023 Recruiting Class | Auburn Live",
"published_date": "2023-01-23T02:07:19Z",
"description": "Jeffrey Lee, Cole Pinkston and \"Jhead\" discuss the latest news on the recruiting trail regarding Auburn Football & give their ...",
"video_id": "9168vAkaWLc",
"thumbnail_url": "https://i.ytimg.com/vi/9168vAkaWLc/default.jpg",
"channel_title": "Auburn Tigers on Auburn Live",
"tag": 2
}
]
}
- Admin Panel: For the admin user, there is an Admin Panel, using which they can effectively perform any operation such as View/Update/Delete/Create Tags and Videos
- Clone the repository.
- Create a new venv:
py -m venv venv
- Activate venv:
.\venv\Scripts\activate
- Install all the requiremetns using the given requirements.txt file :
pip install -r requirements.txt
- Create .env file using the .env.example file
- Run migrations:
py manage.py migrate
- Create superuser:
py manage.py createsuperuser
- Run the server:
py manage.py runserver
- Server will be accessible on
http://localhost:8000/
. Admin panel will be available onhttp://localhost:8000/admin
login with the superuser creds. - To run the celery worker, open new terminal and run the following command:
celery -A fampay_assignment worker -l info
- The project also requires celery beat for periodic tasks, so open a new terminal and run:
celery -A fampay_assignment beat -l info
- Now, youtube vidoes will be fetched every 10 seconds periodically.
Project Screenshots: Admin Panel: Browsable list of videos: Browsable API to get paginated videos list: