Lurker News
yt-fts is a simple python script that uses yt-dlp to scrape all of a youtube channels subtitles and load them into an sqlite database that is searchable from the command line. It allows you to query a channel for specific key word or phrase and will generate time stamped youtube urls to the video containing the keyword.

Comments (165) 32 threads

Earlier comments
theo_champion1 reply#
I have actually been working on a full blow full-text search engine for youtube by transcripts as a web application: https://clipbase.xyz

I'd love to know what y'all think!

harryvederci#
Nice. Possible (?) improvement: provide a bit of context with each clip. For example: 2 seconds before the searched bit, and 2 seconds after.
monkeydust2 replies#
Nice work. You could encode the text, load this into a vector database and allow semantic search.
monkeydust#
Yes in theory although they are pretty expensive. I am doing something like this at work as I wanted to unlock the wealth of information we have in our tutorials, webinars etc.
pknerd1 reply#
Pardon my ignorance as I have not worked on Vector DBs yet, could you come up with an example how it'd be different than a full text search?
bigzyg33k1 reply#
Here's a (kinda) ELI5: you would use a language model to create "embeddings" of the text, which you can think of as a set of numbers representing the "meaning" of a set of characters.

These numbers can be plotted as points in a space, and embeddings of things with similar meanings are plotted close to each other. So things like "exam preparation" would have embeddings close to things like "top study tips".
Say you have created embeddings for a large corpus of text (in this case all youtube captions) once. If you create embeddings for a user query, you can search for embeddings close to it, and these will be "semantically" similar to the query.
The advantage is that unlike traditional full-text search, the user doesn't need a query that includes words present in the text.

cced4 replies#
Do you have any resources that might guide one on doing something like this from scratch?

Continue this thread — 4 replies

DyslexicAtheist1 reply#

   python3 yt_fts.py download https://www.youtube.com/@PerspectiveArts/videos --channel-id UCUCN8V_pO0xOFKLL4XG1tshnw
   Downloading channel
   Saving vtt files to /tmp/user/1000/tmpm4xoskpo
   Traceback (most recent call last):
   File "/home/user/src/yt-fts/yt_fts.py", line 273, in
     cli()
   File "/home/user/src/yt-fts/.env/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
     return self.main(*args, \*kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/home/user/src/yt-fts/.env/lib/python3.11/site-packages/click/core.py", line 1055, in main
     rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
   File "/home/user/src/yt-fts/.env/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
     return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/home/user/src/yt-fts/.env/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
     return ctx.invoke(self.callback, \*ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/home/user/src/yt-fts/.env/lib/python3.11/site-packages/click/core.py", line 760, in invoke
     return __callback(*args, \*kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/home/user/src/yt-fts/yt_fts.py", line 31, in download
     download_channel(channel_id)
   File "/home/user/src/yt-fts/yt_fts.py", line 82, in download_channel
     channel_name = get_channel_name(channel_id)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   File "/home/user/src/yt-fts/yt_fts.py", line 191, in get_channel_name
     data = json.loads(script.string)
                      ^^^^^^^^^^^^^
   AttributeError: 'NoneType' object has no attribute 'string'
lfconsult#
Fixed.

Load more comments