Cyber Detective💙💛 Profile picture
Every day I write about #osint (Open Source Intelligence) tools and techniques. Also little bit about forensics and cybersecurity in general. Work in @netlas_io

Oct 11, 2021, 10 tweets

To answer this question, I will create a small thread🧵

#python #youtube #osint

1. Get a list of video URLs

pip install youtube_search

Create file searchyoutube.py:

from youtube_search import YoutubeSearch
results = YoutubeSearch('osint', max_results=25).to_dict()
for v in results:
print('youtube.com' + v['url_suffix'])

Look at the indentation in the picture above (this is important), replace "osint" with your keyword and run the script:

python searchyoutube.py

If all went well, write the list of URLs to a file:

python searchyoutube.py >urls.txt

2. Download subtitles to files

Install special tool and try it:

git clone github.com/minhnd/youtube…
cd youtube-subtitle-downloader
python2 youtubesub.py

Replace the filename variable in two places with self.video_id in youtubesub.py (view pics).

This is to ensure that all subtitle files are named differently

Run the script for all the videos in the urls.txt list at once:

$ cat urls.txt | xargs -L1 python2 youtubesub.py

Now we have 3 subtitle files (.srt extension) in the script directory.

(not all videos have subtitles)

Now search for the keyword "level" in all files with the extension .srt in the current directory and write the results in the file result.txt:

grep -r --include=\*.srt 'level' >result.txt

All of these commands can be combined into one file, saved with a .sh extension, and run as needed:

bash automation.sh

(Just don't forget the above changes in the scripts source code)

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling