YouTube Viewer

# GTK YouTube Viewer

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

gtk-youtube-viewer

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

"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 --uploads=s      : list videos uploaded by a specific channel or user
   -pv --popular=s      : list the most popular videos from a specific channel
   -uf --favorites=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
   -sv --search-videos  : search for YouTube videos (default mode)

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

* Activities
   -ua --activities:s : show activity events for a given channel

* Trending
   --trending:s       : show trending videos in a given category ID or name
                        use the `--within=s` option to restrict the results

 * Channels
   -sc --channels     : search for Youtube channels

* Comments
   --comments=s         : display comments for a video by ID or URL
   --comments-order=s   : change the order of YouTube comments
                          valid values: relevance, time

 * 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=s         : search only for videos in a specific category name/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, Nw, 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 number
   --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: best, 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
   -U  --uploads:s       : show the uploads from your channel *
   -P  --playlists:s     : show the playlists from your channel *
   -F  --favorites:s     : show the latest favorited videos *
   -S  --subscriptions:s : show the subscribed channels *
   -SV --subs-videos:s   : show the subscription videos (slow) *
       --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 given channel ID or username *
   --favorite=s         : favorite a 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!  : play videos in fullscreen mode
   -n  --audio!       : play audio only, without displaying video
   --append-arg=s     : append some command-line parameters to the media player
   --player=s         : select a player to stream videos
                        available players: mplayer, mpv, vlc


== Download Options ==

 * Download
   -d  --download!       : activate the download mode
   -dp --dl-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 (recommended)
       --skip-if-exists! : don't download videos which already exist (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)
       --mkv-merge!      : merge audio and video into an MKV container
       --merge-captions! : include closed-captions in the MKV container

 * 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 the video results in order
   -B  --backwards!      : play the video results in reverse order
   -s  --shuffle!        : shuffle the results of videos
   -I  --interactive!    : interactive mode, prompting for user input
       --autoplay!       : autoplay mode, automatically playing related videos
       --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
       --get-term-width! : allow youtube-viewer to read your terminal width
       --autohide!       : automatically hide watched videos
       --skip-watched!   : don't play already watched videos
       --highlight!      : remember and highlight selected videos
       --confirm!        : show a confirmation message after each play
       --prefer-mp4!     : prefer videos in MP4 format, instead of WEBM

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

 * Config
   --update-config!     : update the configuration file

 * Output
   -C  --colorful!      : use colors to delimit the video results
   -D  --details!       : display the results with extra details
   -W  --fixed-width!   : adjust the results to fit inside the term width
       --custom-layout! : display the results using a custom layout (see conf)
   -i  --info=s         : show information for a video ID or URL
   -e  --extract=s      : extract information from videos (see: -T)
       --extract-file=s : extract 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
       --video-info!    : show video information before playing
       --escape-info!   : quotemeta() the fields of the `--extract`
       --use-colors!    : enable or disable the ANSI colors for text

 * Other
   --invidious!         : use the API of invidio.us to get the streaming URLs
   --proxy=s            : set HTTP(S)/SOCKS proxy: 'proto://domain.tld:port/'
                          If authentication required,
                          use 'proto://user:pass@domain.tld:port/'
   --dash!              : include or exclude the DASH itags
   --dash-mp4a!         : include or exclude the itags for MP4 audio streams
   --dash-segmented!    : include or exclude segmented DASH streams


Help options:
   -T  --tricks         : show more 'hidden' features of youtube-viewer
   -E  --examples       : show several usage examples of 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..3     : see behind the scenes

NOTES:
    *    -> 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

Github: https://github.com/trizen/youtube-viewer
AUR: https://aur.archlinux.org/packages/gtk-youtube-viewer-git/

Comments

  1. This comment has been removed by the author.

    ReplyDelete
    Replies
    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)
      HAYASHI/Term-ReadLine-Gnu-1.26.tar.gz
      /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 ? richard.kuenz@student.uibk.ac.at


      thank you very much, multumesc!

      Delete
    2. A private email has been sent.

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

    ReplyDelete
  3. Can't locate File/ShareDir.pm 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?

    ReplyDelete
  4. dont work in debian wheezy, no serach results appears

    ReplyDelete
    Replies
    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).

      Delete
  5. How do i add this channel to the "youtube_users.txt" file = https://www.youtube.com/channel/UC8TwvLX_zCnhsm6JauPZIxw - its different than the other channels like - https://www.youtube.com/user/1Veritasium

    ReplyDelete
    Replies
    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!

      Delete

Post a Comment