Skip to content

Server-side script to fetch the latest videos using YouTube API. The script will continuously be called in the background (async) with some interval (say 10 seconds) for fetching the latest videos for a predefined search query

License

Notifications You must be signed in to change notification settings

nikhil25803/yt-data-fetcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YT Data Fetcher

Server-side script to fetch the latest videos using YouTube API. The script will continuously be called in the background (async) with some interval (say 10 seconds) for fetching the latest videos for a predefined search query

Project Setup

  • Clone the repository
git clone https://github.com/nikhil25803/yt-data-fetcher.git
cd yt-data-fetcher
  • Virtual Environment Setup
python -m venv env

source env/Scripts/Activate
  • Download Requirements
pip install -r requirements.txt
  • Environment Variables Requirements
DJANG_SECRET_KEY=...
GOOGLE_API_KEY=...
GCP_CLIENT_ID=...
GCP_CLIENT_SECRET=...
KEYWORD=...
  • Make migrations (For DB functionality)
python manage.py makemigrations

python manage.py migrate
  • Run the server
python manage.py runserver

API Reference

  • GET /api/data
    • This endpoint will add data latest fetched YouTube video data of the keyword mentioned.
    • "cricket" by default

Response

{
    "message": "Successfully added the data in the DB"
}
  • GET /api/videos
    • This endpoint will return the data in paginated form (one can set the limit per-response)
    • Query params
      • limit
      • page
      • Example - /api/videos?limit=2&page=2

Respose

{
    "message": "All videos has been fetched",
    "totalCount": 25,
    "pageCount": 10,
    "next": "http://127.0.0.1:8000/api/videos?limit=2&page=2",
    "previous": null,
    "data": [
        {
            "publishedAt": "2024-02-16T20:49:02Z",
            "videoTitle": "The Importance of Python For IT Specialists | Google IT Support Certificate",
            "videoDescription": "Python is still important in today's IT industry. Python has been adopted drastically in the last few years because its language has ...",
            "thumbnailUrl": "https://i.ytimg.com/vi/RgcEylkiaXE/default.jpg",
            "channelTitle": "Google Career Certificates"
        },
        ...
    ]
}
  • POST api/key/add
    • Add new API key to the DB
    • This key will be used when the currently provided key will get expired or failed for any reason

Response

{
    "message": "API key has been added.",
    "data": {
        "key_name": "...",
        "key_value": "..."
    }
}

About

Server-side script to fetch the latest videos using YouTube API. The script will continuously be called in the background (async) with some interval (say 10 seconds) for fetching the latest videos for a predefined search query

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages