Thhis is a Django, Django Rest Framework and Celery based project for fetching youtube public data based on certain pre-defined parameters.
-
Copy the contents of
.env.example
to.env
for environment variables and add your YOUTUBE API KEY. -
Run below command for docker
$ docker-compose build --no-cache --build-arg SECRET_KEY="<secret key from .env.example>"
-
The SECRET KEY is in the
.env.example
file. -
For running all the containers.
$ docker-compose up
- To stop the containers press
Ctrl + C
- Create migrations for Database
$ docker-compose run web python manage.py migrate
- Create a super user for django admin.
$ docker-compose run web python manage.py createsuperuser
-
Enter the details for creating the user.
-
Once the migrations are done, run the server
$ docker-compose up
- The server will be running on port
8000
.
Hooray! The project setup is complete ✨.
For testing the fucntionality of this project
- Run the server
$ docker-compose up
GET /videos/
This will provide all the youtube results with cursor pagination sorted in descending order of the published datetime.
GET /videos/?q=
Write the text you want to search after ?q=
, the searching will take place based on title and description.
This is an optimised searching using Trigram similarity, search rank and search vector.
- Celery task is running every 20 seconds to fetch the data from youtube API and storing the results in database.
- If you are running it on local machine then go to
http://127.0.0.1:8000/admin/
- Enter the user credential you created while setting up the project.
- You will see
Youtubes
in the admin panel which has all the data with searching based on title and youtube video ID.