{"id":18405733,"url":"https://github.com/pybites-open-source/youtube-infinite-scroll","last_synced_at":"2025-04-07T08:32:11.177Z","repository":{"id":46523386,"uuid":"405615259","full_name":"PyBites-Open-Source/youtube-infinite-scroll","owner":"PyBites-Open-Source","description":null,"archived":false,"fork":false,"pushed_at":"2024-02-06T13:05:16.000Z","size":43120,"stargazers_count":11,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-22T15:12:06.530Z","etag":null,"topics":["hacktoberfest","htmx","pytest","selenium","sqlmodel","vcr","youtube"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PyBites-Open-Source.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-12T10:49:34.000Z","updated_at":"2025-01-07T04:14:25.000Z","dependencies_parsed_at":"2024-11-06T03:14:25.937Z","dependency_job_id":"ac0bcddc-0488-4209-aa05-67f50a18826a","html_url":"https://github.com/PyBites-Open-Source/youtube-infinite-scroll","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PyBites-Open-Source%2Fyoutube-infinite-scroll","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PyBites-Open-Source%2Fyoutube-infinite-scroll/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PyBites-Open-Source%2Fyoutube-infinite-scroll/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PyBites-Open-Source%2Fyoutube-infinite-scroll/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PyBites-Open-Source","download_url":"https://codeload.github.com/PyBites-Open-Source/youtube-infinite-scroll/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247620260,"owners_count":20968171,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","htmx","pytest","selenium","sqlmodel","vcr","youtube"],"created_at":"2024-11-06T03:04:30.327Z","updated_at":"2025-04-07T08:32:11.168Z","avatar_url":"https://github.com/PyBites-Open-Source.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YouTube infinite scroll\n\nThis demo uses [SQLModel](https://sqlmodel.tiangolo.com/) and [htmx](https://htmx.org/) to generate an [infinite scroll](https://htmx.org/examples/infinite-scroll/) of videos of a YouTube videos.\n\n## Setup\n\nMake a virtual environment and install the requirements:\n\n```\n$ make install\npython3.9 -m venv venv \u0026\u0026 source venv/bin/activate \u0026\u0026 pip install -r requirements-dev.txt\n```\n\nThen go to [Google Cloud Platform \u003e YouTube Data API v3](https://console.cloud.google.com/apis/library/youtube.googleapis.com?project=top-repos) and hit the blue ENABLE button, then generate your API key:\n\n![enable the API](assets/youtube-api1.png)\n\n![create an API key](assets/youtube-api2.png)\n\nNext set up your `.env` file:\n\n```\ncp .env-example .env\n```\n\nPopulate it with the following environment variables:\n\n- `YT_CHANNEL`: the YouTube channel to use this on, to try it out with PyBites you can use `UCBn-uKDGsRBfcB0lQeOB_gA` or for PyCon use `UCMjMBMGt0WJQLeluw6qNJuA` (demo below).\n\n- `YOUTUBE_API_KEY`: the API key you just created.\n\n- `DATABASE_URL`: create a database and point to it (in case of `sqlite` all you need to do is specify one like this: `sqlite:///db.sqlite3`)\n\nNext let's cache the YouTube channel's data (all videos' metadata) to not exhaust the YouTube API rate limit.\n\nRun the following command with your virtual environment enabled (this example uses PyCon's YouTube channel):\n\n```\n$ make dbsetup\nsource venv/bin/activate \u0026\u0026 python -m youtube.db\nTotal records: 172 (newly inserted: 172)\n```\n\nResult:\n\n\u003cvideo src=\"https://user-images.githubusercontent.com/387927/133118592-87d5b8d3-a87c-4be3-81f1-8457c0eb182c.mp4\" controls=\"controls\" style=\"max-width: 730px;\"\u003e\n\u003c/video\u003e\n\nLastly run the app:\n\n```\nmake run\n```\n\nNavigate to [localhost:8000](http://localhost:8000/) and you should see something like this:\n\n\u003cvideo src=\"https://user-images.githubusercontent.com/387927/133118934-29655671-8d4e-4483-8a3e-cdffe0fabbd4.mp4\" controls=\"controls\" style=\"max-width: 730px;\"\u003e\n\u003c/video\u003e\n\n## Testing\n\nThere are unit and functional tests for this project.\n\nThe unit tests use \"cassettes\" (cached API responses) so they are fast:\n\n\u003cvideo src=\"https://user-images.githubusercontent.com/387927/133856835-408899a1-4e57-4bce-8bfd-d22f32b4f37b.mp4\" controls=\"controls\" style=\"max-width: 730px;\"\u003e\n\u003c/video\u003e\n\nThe functional (end-to-end) test uses the real DB that is configured in `.env` and Selenium to scroll to the bottom of the infinite scroll, then compare the amount of table rows on the page vs the amount of entries in the DB. This test requires FastAPI to be running.\n\nSo in terminal 1 run:\n\n```\nmake run\n```\n\nThen in terminal 2 run the test:\n\n\u003cvideo src=\"https://user-images.githubusercontent.com/387927/133856764-1b8e776f-5c43-4910-ad4d-7c53172a3f43.mp4\" controls=\"controls\" style=\"max-width: 730px;\"\u003e\n\u003c/video\u003e\n\nOf course you can also run all tests in one go with `make test`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpybites-open-source%2Fyoutube-infinite-scroll","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpybites-open-source%2Fyoutube-infinite-scroll","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpybites-open-source%2Fyoutube-infinite-scroll/lists"}