Skip to content
/ ytq Public

A media search tool that gathers urls and other metadata from popular media platforms. Currently only supports YouTube

License

Notifications You must be signed in to change notification settings

decent-man/ytq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ytq

YouTube-Query.

Perform queries to youtube from the terminal.

Returns formatted output containing urls which can be used in scripts.

Usage

ytq <args> <query>

where:

  • <args> : Arguments to ytq
  • <query> : Query string to send to YouTube.

e.g ytq how to dance alt text

Speed varies from 0.3 seconds to 0.5 seconds ( tested using time)

Default behavior is to simply list the first 15-20 results from youtube's search page.

To display in special formatting, for scripting however, as of now three options are available:

  • Raw (-r|--raw)

    Format results in a handy way to be parsed by scripts. Lists results with a handy seperator () that is less likely to appear in output. alt text

  • First only (-f|--first)

    Useful when you don't want to process through the entire list and only want the first result. alt text

  • No Title (-not|--no-title)

    Skip printing the title. alt text

Applications

Requirements:

  1. a menu selector (e.g GUI: dmenu, rofi, gmrun, etc , CLI: select, fzf, sk, etc)

    Not required if you plan to use the first-only mode.

  2. a media player (e.g mpv, vlc, etc)

    EITHER: the media player being used needs streaming capabilities(especially the ability to stream from youtube)

    OR: the video needs to be downloaded and then passed to the media player to run. A program like youtube-dl can be used to download the video.

Implementation:

  1. Music Player ﱘ

    Using dmenu + mpv:

    Demonstration in progress :)

  2. Video Streaming

    Using dmenu + mpv:

    Demonstration in progress :)

Important

This is a simple program that fetches only the first 18 results and does not support multipage queries at the moment.

This program does not use the Google API to gather data, but rather relies on hacky html/json parsing to retrieve data and hence is limited in functionality and possibly prone to breaking if YouTube changes its response structure.

FAQ

Why is it default behavior to list results in a non script friendly manner?

To verify if the internal parser is generating valid output. So if any script breaks you can run ytq with the same query to check, if it is a problem with the script or the ytq parser.

Why only 15-20 results? Why not more?

Under the hood ytq does not use the Google API to get results, but rather relies on html that YouTube returns. By default YouTube returns only 18 results and this is all that ytq can parse at the moment.

Support

Email me @ decentman


Happy querying !!!

-- decentman

About

A media search tool that gathers urls and other metadata from popular media platforms. Currently only supports YouTube

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published