YouTube Viewer

# GTK YouTube Viewer

This application came to life in 12 September 2010 as my first GTK2/Glade learning project.


Its scope is to search and play YouTube videos in a native player. 
It comes with various search options; it can search for videos, playlists and/or channels. The videos are streamed directly in a selected video player at the best resolution (customizable) and with closed-captions (if available).

By default, the application supports three video players: MPV (recommended), MPlayer and VLC, but it allows the addition of more players inside the configuration file.

For a better experience, the application also comes with built-in authentication support, using the OAuth 2.0 mechanism. After inserting the authentication token, a new tab will appear, named "My panel", which has the following buttons:
  • Subscriptions
  • Favorited videos
  • Liked videos
  • Disliked videos
  • Uploads
  • Playlists
  • Log out
For more details (+screenshots), see also:

# CLI Youtube Viewer

Inside the package, we can also find a CLI version, called "youtube-viewer", which includes the functionality of GTK Youtube Viewer, and more.

"youtube-viewer" can be described as a semi-automatic tool for browsing YouTube. It has lots of advanced options, including search-based filtering on various criteria and support for selecting videos matched by a regular expression.

usage: youtube-viewer [options] ([url] | [keywords])

== Base ==
   [URL]             : play an YouTube video by URL
   [keywords]        : search for YouTube videos
   [playlist URL]    : display a playlist of YouTube videos

== YouTube Options ==

 * Categories
   -c  --categories     : display the available YouTube categories
   -hl --catlang=s      : language for categories (default: en_US)

 * Region
   --region=s           : set the region code (default: US)

 * Videos
   -uv --user-vid=s     : list videos uploaded by a specific user
   -cv --channel-vid=s  : list videos uploaded to a specific channel
   -uf --user-fav=s     : list the videos favorited by a specific user
   -id --videoids=s,s   : play YouTube videos by their IDs
   -rv --related=s      : show related videos for a video ID or URL
       --search=s       : search for YouTube videos (default mode)

 * Playlists
   -p  --playlists    : search for playlists of videos
       --pid=s        : list a playlist of videos by playlistID
       --pp=s,s       : play the videos from the given playlist IDs
       --ps=s         : add videos by ID or URL to a post-selected playlist
                        or in a given playlistID specified with `--pid`
       --position=i   : the position in a playlist where to add a video
   -up --user-pl=s    : list the playlists created by a specific user
   -cp --channel-pl=s : list the playlists belonging to a specific channel ID

 * Channels
   --channels         : search for Youtube channels

* Comments
   --comments=s         : display comments for a YouTube video by ID or URL

 * Filtering
   --author=s           : search in videos uploaded by a specific user
   --channel-id=s       : search in videos belonging to a specific channel ID
   --duration=s         : filter search results based on video length
                          valid values are: short, medium, long
   --caption=s          : only videos with/without closed captions
                          valid values are: any, closedCaption, none
   --category=i         : search only for videos in a specific category ID
   --safe-search=s      : YouTube will skip restricted videos for your location
                          valid values are: none, moderate, strict
   --order=s            : order the results using a specific sorting method
                          valid values: date rating viewCount title videoCount
   --within=s           : show only videos uploaded within the specified time
                          valid values are: Nd, Nm, Ny, where N is a number
   --hd!                : search only for videos available in at least 720p
   --vd=s               : set the video definition (any, high or standard)
   --page=i             : get results starting with a specific page
   --results=i          : how many results to display per page (max: 50)
   -2  -3  -4  -7  -1   : resolutions: 240p, 360p, 480p, 720p and 1080p
   --resolution=s       : supported resolutions: original, 2160p, 1440p,
                          1080p, 720p, 480p, 360p, 240p, 144p, audio.

 * Account
   --login              : will prompt for authentication (OAuth 2.0)
   --logout             : will delete the authentication key

 * [GET] Personal
   -F  --favorites:s     : show the latest favorited videos *
   -S  --subscriptions:s : show the subscribed channels *
   -SV --subs-videos:s   : show the subscription videos *
       --subs-order=s    : change the subscription order
                           valid values: alphabetical, relevance, unread
   -L  --likes           : show the videos that you liked on YouTube *
       --dislikes        : show the videos that you disliked on YouTube *

* [POST] Personal
   --subscribe=s        : subscribe to a channel *
   --user-subscribe=s   : subscribe to a channel via username *
   --favorite=s         : favorite a YouTube video by URL or ID *
   --like=s             : send a 'like' rating to a video URL or ID *
   --dislike=s          : send a 'dislike' rating to a video URL or ID *

== Player Options ==

 * Arguments
   -f  --fullscreen!  : set the fullscreen mode for the selected video player
   -n  --novideo!     : play the music only without a video in the foreground
   --vo=s             : specify the video output for MPlayer
   --af=s             : specify an audio filter for MPlayer
   --append-arg=s     : append some command-line parameters to the media player
   --video-player=s   : select a video player to stream videos
                        available players: mpv, mplayer, vlc

== Download Options ==

 * Download
   -d  --download!       : activate the download mode
   -dp --downl-play!     : play the video after download (with -d)
   -rp --rem-played!     : delete a local video after played (with -dp)
       --wget-dl!        : download videos with wget (default: LWP)
       --dl-parallel     : download multiple videos at once
       --clobber!        : overwrite an existent video (with -d)
       --skip-if-exists! : don't download videos which already exists (with -d)
       --copy-caption!   : copy and rename the caption for downloaded videos
       --downloads-dir=s : downloads directory (set: '.')
       --filename=s      : set a custom format for the video filename (see: -T)
       --fat32safe!      : makes filenames FAT32 safe (includes Unicode)

 * Convert
   --convert-cmd=s      : command for converting videos after download
                          which include the *IN* and *OUT* tokens
   --convert-to=s       : convert video to a specific format (with -d)
   --keep-original!     : keep the original video after converting

== Other Options ==

 * Behavior
   -A  --all!            : play all the video results in order
   -B  --backwards!      : play all video results in reverse order
   -s  --shuffle!        : shuffle the results of videos and playlists
   -I  --interactive!    : interactive mode, prompting for user input
       --std-input=s     : use this value as the first standard input
       --max-seconds=i   : ignore videos longer than i seconds
       --min-seconds=i   : ignore videos shorter than i seconds
       --combine-multi!  : combine multiple videos into one play instance
       --get-term-width! : allow youtube-viewer to read your terminal width
       --autohide!       : automatically hide watched videos
       --highlight!      : remember and highlight selected videos
       --confirm!        : show a confirmation message after each play

 * Closed-captions
   --get-captions!      : download the closed captions for videos
   --auto-captions!     : include or exclude auto-generated captions
   --captions-dir=s     : the directory where to download the .srt files

 * Config
   -U  --update-config! : update the configuration file before exit

 * Output
   -C  --colorful!      : use colors to delimit the video results
   -D  --details!       : a new look for the results, with more details
   -W  --fixed-width!   : adjust the results to fit inside the term width
   -i  --info=s         : show some info for a videoID or URL
   -e  --extract=s      : extract information from videos (see: -T)
       --extract-file=s : extract the information from videos in this file
       --dump=format    : dump metadata information in `videoID.format` files
                          valid formats: json, perl
   -q  --quiet          : do not display any warning
       --really-quiet   : do not display any warning or output
       --escape-info!   : quotemeta() the fields of the `--extract`
       --use-colors!    : enable or disable the ANSI colors for text

 * Other
   --http_proxy=s       : HTTP proxy to use, format 'http://domain.tld:port/'.
                          If authentication required,
                          use 'http://user:pass@domain.tld:port/'
   --dash!              : include or exclude the DASH itags
   --dash-mp4a!         : include or exclude the itags for MP4 audio streams

Help options:
   -T  --tricks         : show more 'hidden' features of youtube-viewer
   -E  --examples       : show some useful usage examples for youtube-viewer
   -H  --stdin-help     : show the valid stdin options for youtube-viewer
   -v  --version        : print version and exit
   -h  --help           : print help and exit
       --debug:[1,2]    : see behind the scenes

    *    -> requires authentication
    !    -> the argument can be negated with '--no'
    =i   -> requires an integer argument
    =s   -> requires an argument
    :s   -> can take an optional argument
    =s,s -> can take more arguments separated by commas

# Availability



  1. This comment has been removed by the author.

    1. hello daniel,

      i tried to compile youtube-viewer on PPC Powerbook G4 with OSX Tiger 10.4.11. Had to install XCode, Subversion and Git. Then update Perl to 5.12 (ActivePerl).
      Then i tried to follow your routine
      but when i do

      perl Build.PL --destdir /my/dir

      (after ./build installdeps)

      i get following error

      The libreadline you are using is the libedit library. Use the GNU Readline Library.
      Warning: No success on command[/usr/local/ActivePerl-5.12/bin/perl Makefile.PL INSTALLDIRS=site]
      CPAN: YAML::XS loaded ok (v0.34)
      /usr/local/ActivePerl-5.12/bin/perl Makefile.PL INSTALLDIRS=site -- NOT OK
      Running make test
      Make had some problems, won't test
      Running make install
      Make had some problems, won't install

      can you help me here please ?

      thank you very much, multumesc!

    2. A private email has been sent.

  2. Great app! I use obmenu gen as well. thanx.

  3. Posted a bit of an ad for this on my blog

  4. Can't locate File/ in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at /usr/local/bin/gtk-youtube-viewer line 37.
    BEGIN failed--compilation aborted at /usr/local/bin/gtk-youtube-viewer line 37. ¿Can you help me?

  5. dont work in debian wheezy, no serach results appears

    1. Can you post, please, the error messages from File->"Warnings Console" and your version of Perl? (perl -v)

      A generic fix would be to remove the configuration file (rm ~/.config/gtk-youtube-viewer/gtk-youtube-viewer.conf) and/or (re)install the 'XML::Fast' module (cpan XML::Fast).

  6. How do i add this channel to the "youtube_users.txt" file = - its different than the other channels like -

    1. Currently, this is not possible as it accepts only YouTube usernames and not channel IDs, but I will consider adding an way to do this in the future. Thanks for noticing!


Post a Comment