Scrape data about an entire Channel or just a Playlist, using Youtube API. No OAuth is required.
Following features are available :
- create_new :
- It creates a sqlite database to store all data.
- Database will be placed in the same folder as the project file, named 'youtube.db'
- It will have 4 tables - tb_channel, tb_playlist, tb_videos, video_history
- You can use programs like DB Browser , which is lightweight, to view the database.
- Oldest Video on A Topic :
- It is an isolate program, that can be run independently.
- It doesn't depend on main code or any database.
- Scrape A Channel:
- Allows to scrape Channel Details and it's playlists.
- It can also scrape details for each video of that channel.
- If this option is not chosen, the playlist table won't have Playlist Duration.
- Scrape A Single Playlist:
- Allows to scrape info about a single Playlist and details about all it's videos.
- Load Your History:
- Make sure you have downloaded google Takeouts for your account to the PWD.
- Make sure you have follwing path './takeout/history/watch-history.html'
- Option to keep videos of your history on a separate table or integrate them with main table tb_videos
- In order to use next features, you have to integrate them.
- Most Watched Video:
- You can list your most watched 'n' videos
- Early Viewed:
- You can list 'n' videos, which you saw earliest after they were uploaded.
- There are some discrepencies, as many videos are reuploaded after you have seen it.
- Program ignores those
- It now only works when you watched it in IST.
- Generate Download List:
- This will create a text file, that will list Youtube URLs that can be downloaded by Youtube-DL or IDM etc.
- It will select videos which are marked 'Worth = 1' i the database.
- This operation is to be done by the user directly on the database (using DB Browser or such)
- There is option to list videos of a single Channel or from entire DAtabase.
- Caution : Once a video is processed by this function, it will be marked 'Is_Downloaded = 1'. Next time this function is run, new video IDs will be considered.
- Hence User must make sure, all videos in download_list.txt are downloaded before rewriting the file.
Below is a detailed guide on setting up the environment.
First you need to have you Youtube API key. Below is a link of a video, that will guide you. Watch from 0:00 - 5:30
- Note - Youtube API is rate limited to 10000 hits/day.
- You can view your quotas at here - console
- Cost of operations is decribed here -Youtube API docs
- Code has been optimized to decrease quota usage. You can easily work with 50000 videos/day. For more please check your quota limit.
You need to install google-api-python-client to run this project. github API link Install this library in a virtualenv using pip.
pip3 install virtualenv
virtualenv venv
. venv/bin/activate
pip3 install -r requirements.txt
pip3 install virtualenv
virtualenv venv
venv\Scripts\activate
pip3 install -r requirements.txt
- Get Your Youtube API key as shown in above video.
- Pip install the requirements.txt
- Run the program YT_Scrape.py
The script will ask for required data in the command line and is pretty self-explanatory (Once it runs)
There are several ways to help.
-
Spread the word: More users means more possible people testing and contributing to the app which in turn means better stability and possibly more and better features. You can or share it on LinkedIn. Every little bit helps !
-
Make a feature or improvement request: Something can be be done better? Something essential missing? Let us know!
-
Contribute: You don't have to be programmer to help.
- Treat Me A Coffee Instead Paypal
Pull requests are of course very welcome! Please make sure to also include the issue number in your commit message, if you're fixing a particular issue (e.g.: feat: add nice feature with the number #31
).