|
|
2 лет назад | |
|---|---|---|
| .. | ||
| .gitignore | 2 лет назад | |
| README.md | 2 лет назад | |
| db_model.py | 2 лет назад | |
| model.py | 2 лет назад | |
| requirements.txt | 2 лет назад | |
| session_sample.json | 2 лет назад | |
| youtube_info_fetch.py | 2 лет назад | |
| youtube_model.py | 2 лет назад | |
Given a list of Video IDs, fetch them and store them to a SQLite3 DB cache for subsequent fetches.
Store them by authorized user and with a timestamp, so they can be fetched with a max age.
A YouTube API project with client info stored in .data/yt-client-secret.json,
and optionally channel config stured in .data/session_{channel_id}.json where
channel_id is configured in youtube_info_fetch.py as AUTH_CHANNEL_ID.
A template of the format for .data/session_{channel_id}.json config
can be found in session_sample.json. It it's not present then it uses app
level access, which is sufficient.
It doesn't handle login or refresh token, which I think an earlier dev practice
covered. The credentials is the flow.credentials from
google_auth_oauthlib.flow.Flow.from_client_secrets_file after fetch_token is
called.
Run python youtube_info_fetch.py after setting video_ids and optionally AUTH_CHANNEL_ID at the top of the file.
Add more video_ids between runs to see cache behavior.
Data is stored in .data/youtube.db and can be inspected with any SQLite3 library.
This is a dev practice that touches on these themes:
It's about the 5th practice I've done where I've broken the code into a "model" layer.