Giter VIP home page Giter VIP logo

toby's Introduction

Toby

NOTE: A rewrite of this project is underway using Blazor and can be found here

Toby is a simple YouTube player for the desktop.

Screenshots

Toby In Action:

Toby In Action

Toby Main UI:

Toby Main UI

Toby Video List:

Toby Video List

Toby Video List (Slim Grid)

Toby Video List (Slim Grid)

Toby Recently Played:

Toby Recently Played

Toby Manage Videos:

Toby Manage Videos

Toby Server Log:

Toby Server Log

Architecture

The old Toby architecture was geared towards an Electron deployment and I loaded all the code from the file system. The new architecture puts Toby behind an Express web application that is spawned from a regular Node process so that more deployment scenarios are possible.

Having Toby behind an Express app makes it fairly trivial to deploy to NW.js, Electron and support a regular web browser.

Toby is meant as a personal application running on a personal computer and it's web API is not password protected in any way and there has been no attempt to protect the data Toby collects. Toby only cares about a few things, namely YouTube video titles, YouTube video IDs and the groups you decide to store your favorite videos in.

Running The Latest Code

Clone the code using git and then add a folder named browsers with a copy of electron and/or nwjs. We'll use one of these to run Toby.

Dependencies

You Just Need One Of The Following:

Depending on what platform you want to run Toby in (Electron or NW.js) you'll need to make sure the main property in package.json is set accordingly:

NW.js
main: "./build/index.html"
Electron
main: "./build/electron.js"

In order to run Toby you'll need to download the dependencies and build the source code. Open a terminal to the source code repository and run the following commands.

Install Dependencies

npm install -g webpack webpack-cli typescript grunt bower
npm install
bower install

Building the Source Code

NOTE: You will need to supply your own YouTube API key. This needs to be placed in an environment variable called YOUTUBE_API_KEY. You will need a Google account to obtain one. Go [here (https://console.developers.google.com) to get an API key.

The server needs to be built using Grunt.

grunt

The front end needs to be build using Webpack.

webpack

Assuming all dependencies are downloaded and the source code has been compiled perform the following from a command line at the root of the Toby code repository:

NOTE: main will need to be updated in package.json to point to the correct starting point for your deployment scenario. If you are using Electron it will need to be set to build\electron.js or if you are using NW.js it'll need to be set to build\index.html. It should also be noted that the index.html contained in the root of the Toby repository will be copied to the build folder and used from there.

Running in NW.js

browsers\nwjs\nw.exe .

NOTE: You may want to replace the ffmpeg.dll that ships with NW.js with a more capable one from https://github.com/iteufel/nwjs-ffmpeg-prebuilt/releases. The ffmpeg.dll that ships with NW.js is crippled and won't play many of the YouTube videos you most likely will want to play.

Running in Electron

browsers\electron\electron .

Running in a Browser

Start the server up:

node.exe build\server.js

Then open a browser to http://127.0.0.1:62374

Running using the Toby Launcher

I've wrote a rudimentary launcher in C# .NET to assist with launching Toby easily. By default if you run the launcher without command line args it will run Toby using NW.js. There is only one command line option at this time.

After building the launcher copy the TobyLauncher.exe, NDesk.Options.dll and Newtonsoft.Json.dll files to the root of the Toby repository.

  • Command Line Options:
    • /p [nw, electron, web]

Examples:

Launching Toby in a web browser: TobyLauncher.exe /p web Launching Toby in Electron: TobyLauncher.exe /p electron

NOTE: The launcher is crude and there is not enough error checking yet. Things will likely go wrong if Toby is not set up correctly as stated above.

Usage

Important Key Combos:

F1 - Toggles server log F11 - Toggles fullscreen

In addition to keyboard shortcuts there are commands that can be typed into the search box that will perform various things.

Here is a list (there will be additional ones added soon):

  • [name hint] : Lists locally saved videos based on the [name hint]
  • [search term] : Searches YouTube for the [search term]
  • /local [search term] : Searches for locally saved videos
  • /g [group name] : Lists the videos for the [group name]
  • /list-all : List all videos contained in the database
  • /history : Lists the recently played videos
  • /rp or /recently-played : List last 30 recently played videos
  • /rps or /recently-played-search : Search recently played videos
  • /manage : Manage what groups videos are in and also provide ability to delete videos
  • /archive : Export the contents of the database to the data.txt file
  • /gv or /grid-view - Toggle slim grid view for search results
  • /dv or /default-view - Toggle default view for search results
  • /clear : Clears search results
  • /monochrome : (NW.js/Electron only) Short cut to set the monochrome video filter and thumbnails in search results
  • /saturate : (NW.js/Electron only) Short cut to set the saturated video filter and thumbnails in search results
  • /sepia : (NW.js/Electron only) Short cut to set the sepia video filter and thumbnails in search results
  • /normal : (NW.js/Electron only) Short cut to set the normal video filter and thumbnails in search results
  • /filter monochrome : (NW.js/Electron only) Short cut to set the monochrome video filter and thumbnails in search results
  • /filter saturate : (NW.js/Electron only) Short cut to set the saturated video filter and thumbnails in search results
  • /filter sepia : (NW.js/Electron only) Short cut to set the sepia video filter and thumbnails in search results

NOTE: You can refer to /src/toby-ui.tsx for the various short cuts available for these commands.

Wait, I used NW.js and some YouTube videos won't play

The FFMPEG library that ships with NW.js is less capable than the one that ships with Electron. The short answer is just copy the FFMPEG library from an Electron release replace the one that ships with NW.js. I've been doing this for a long time and it works well for me (on Windows).

The longer answer is you can compile your own FFMPEG library with the support you and there are a lot of resources already out there to handle this scenario.

NOTE: This technique does not work with NW.js 0.20.0-beta1 as the FFMPEG seems to be different than one that ships with Electron.

Looks like there are some alternate FFMPEG builds available which can take care of this: https://github.com/iteufel/nwjs-ffmpeg-prebuilt/releases

Features TODO

  • Usage info from within the app

Updating the data file

I've removed the ordinary data file as it was too cumbersome to get the parser correct. I've decided to just define some basic starting video data in the following code file /src/data.ts. If you are building from source feel free to edit this to your liking. If at anytime you edit this file and run Toby it will update your database importing any new videos you put there.

NOTE: Although it hasn't been done yet it'd be trivial to replace this with JSON data loaded from the filesystem.

Author(s)

Frank Hale <[email protected]> 24 November 2019

License

GNU GPL v3 - see LICENSE

toby's People

Contributors

dependabot[bot] avatar frankhale avatar gitter-badger avatar tcyrus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

toby's Issues

Info: Libchromiumcontent / Chromium patch to override HTTP referrer for all requests

This needs to be put in either the README or some other doc file so that it's easily found for those wanting to do this themselves. I'd like to eventually get this put into libchromiumcontent upstream.

TL;DR - VEVO videos will be blocked because the HTTP referrer is not set. The following patch will resolve that issue. Note that this is different than setting the HTTP referrer in a webview which Electron already supports. This overrides it for all requests so things like the YouTube iframe API will work nicely with an overridden referrer.

This adds a new switch called --override-http-referrer which will allow you to override the HTTP referrer for all requests.

Patch the SetReferrer function like so in the Chromium source:

location in Chromium source: net\url_request\url_request.cc

NOTE: This requires compling libchromiumcontent and then building Electron against it. Once you run python script\update on libchromiumcontent and it downloads and extracts the Chrome source code you can patch the file and then run the build.

NOTE: I've added the switch inline here for now but really want to put it in base\base_switches.h|.cc (eventually) but I got unresolved symbols doing that. I tried for several hours to track it down but couldn't figure it out yet. No idea what is going on so I dug into the gyp files but couldn't find a resolution yet.

#include "base/command_line.h"

...

void URLRequest::SetReferrer(const std::string& referrer) {
  DCHECK(!is_pending_);

  std::string _referrer = referrer;
  const std::string& override_http_referrer_switch = "override-http-referrer";
  auto command_line = base::CommandLine::ForCurrentProcess();

  if(command_line->HasSwitch(override_http_referrer_switch)) {
    _referrer = command_line->GetSwitchValueASCII(
      override_http_referrer_switch);
  }

  GURL referrer_url(_referrer);
  if (referrer_url.is_valid()) {
    referrer_ = referrer_url.GetAsReferrer().spec();
  } else {
    referrer_ = referrer;
  }
}

usage:

electron.exe --override-http-referrer=http://foobar.com

Or use the Electron API to set the switch in your app.

Sort search results

When displaying search results they should be sorted in alphabetical order

player core.cljs sends back video title on playback state too many times

There is a check to make sure we only send the video title information once the video title is changed but the code to check this is wrong. I use a Clojurescript atom to store the video title we know about against the one YT sends us. Instead of doing string equality I accidentally am checking the atom value against the title string value instead of the atom string value (deref) against the title string value.

Will fix this today.

Add binary release

In addition to adding instructions on how to run the app with Atom-Shell it would be nice to have a binary release that would make it easier for users to download and run.

Entering YouTube ID should play automatically

It doesn't make sense to enter a YouTube ID and then have to click in the drop down. This should automatically play when hitting enter in the search bar.

NOTE: I've seen instances where a YouTube ID returned more than one result. In this case list the results in the dropdown but if it's a single result which it will be most of the time then just play the video automatically.

syntax standardization for search

The syntax for various functions in the search input box is all over the map. I tell you you have to type 'youtube:' to search youtube and then tell you you have to type '%group-name%' to list all local files in a specific group you've predefined. Additionally I tell you that you must enter 'v=video_id' to search for a video on YouTube given it's specific video id. This is not acceptable and needs to be standardized.

Provide information for how to do a custom build

Since the clojurescript-rewrite branch will soon be merged I think it's important to provide some instructions on how to do a custom build for those that don't know.

Some basics up front:

  • need a Java development kit
  • need Leiningen (http://leiningen.org/)
  • need to make sure leiningen is in the path
  • open command prompt to cloned repo
  • bower install to download JS dependencies
  • npm install to download node dependencies
  • lein cljsbuild once (or auto to keep it open for continuous development)

But some verbiage needs to also wrote so the person knows that they need Electron and how to deploy an app using Electron.

Convert to YouTube API for video playing / other features

I think at this point we've pretty much done all we should do without using the actual YouTube API. I think it's time to convert to using the YouTube API so that we can do other things such as have a continuous playback of videos, Or random playback, etc... This requires knowing when videos when videos have finished playing.

The YouTube API will allow much more capabilities so I think it's time to use it!!!

https://developers.google.com/youtube/iframe_api_reference

Change the key combo used for developers to restart Toby

Currently the F3 key is used to restart Toby but it's too close to the F1 key and F5 key which are used frequently while playing videos. It would be easy to hit F3 and accidentally restart the app. I think it should probably be F11 because F12 is used to open the Developer Tools. You'd probably want to have both functions close together for development purposes.

Recently played videos should be persisted

Recently viewed videos should be persisted and be reloaded when the app loaded.

Here is the requirement:

  • Change the way the recently viewed UI works by showing only the top 10 or 20 (TBD)
    - [ ] Set up an interval that periodically saves the current state of the recently played videos to a file
  • Load the recently played videos when the application is launched

YouTube search results should be cached

Ref: The clojurescript-rewrite branch

If you search YouTube for something and then click one video, come back and search for the same thing, click another video that equals two searches currently. That is not practical. Search results should be cached for a period of time before we ask YouTube for new results.

Provide a UI to add new videos

In the first part a mechanism was added to allow a user to easily add new videos to the data.json file. The videos that could be added were the ones that show up after a video plays. YouTube provides a listing of similar videos that you may like after you watch a video. In Toby you just select one of those videos and then hit F5 if you like it to add it to your data.json.

In this issue I want to track adding a basic UI form to add new videos. This form will provide basic input elements and a submit button. You'll be required to enter a description (the video title) and the YouTube embed URL. This is key here. The embed URL is what provides the YT player when you select a video to play. If you enter a regular YT link to the video then you'll see the YT page pop up just as if you were inside your web browser.

Here is the requirement:

  • Provide keyboard shortcut to open the view
  • Provide input elements to cover the description and the Url
  • Provide a drop down list of all of the groups so that a group can be selected for this new video to be added to
  • Provide a submit button to add the video
  • Provide a user confirmation on the status of the addition of the video (eg. it was added successfully or it already exists, etc..)

Data.json not found on Mac OS X

Need to figure out how to properly set up the path so that it works on Windows, Linux and Mac

Uncaught Error: ENOENT: no such file or directory, open '//resources/app/data/data.json'

Prompt for group when adding new videos via F5 key

After searching YouTube you may want to add the video you just watched to your local data file by pressing F5. This issue calls for adding a way to select the group the video gets added to. Currently adding a new video just dumps into a "misc" group.

Create release for 0.14

I've taken the time to upgrade libchromiumcontent to Chrome version 43.0.2357.132 as well as Electron master to iojs 2.3.4. Everything appears to be working. I'll give it a couple days probably to see if all is well. Then I should make a new release.

Provide usage info inside app

It's great that information is provided via the README here but it'd be nice if there was usage information within the app somehow. For instance, if I didn't read the README how do I add new videos to my playlist, etc.. Need some way to provide that information within the app.

Provide ability to hide YouTube player and show alternate image(s)

This one needs some explanation. If you are like me and spend a good deal of time listening to electronic dance music on YouTube then you've no doubt came across 2 hour sets that have awful visuals. It'd be nice to have a feature that allowed you to hide the player and show an image or a slideshow of images from the local machine or from sites like Flickr to compensate for the lack of the video content creators originality.

Compile the JSX

While I don't think it's that big a deal for how small this app is I think it'd probably be best if the JSX was compiled.

Provide a UI to administrate the data.json file

A user may want to remove or edit videos or restructure the groups. Right now this has to be done manually by editing the data.json file. This issue will track the progress of constructing a UI to do this.

Here are the requirements

  • Provide keyboard shortcut to open up this view
  • Allow viewing of the structure of the data.json
  • Allow editing video entries to include changing the description or changing the Url.
  • Allow removing video entries
  • Allow moving a video from one group to another
  • Allow creation of new groups
  • Allow deletion of groups

All group listing in search results

This is similar to the %all% search term which returns all of the videos listed in the data.json file. However, this should list specific videos based on the group that they are in.

For instance:

If data.json declares that there is a 'trance' group then you should be able to type %trance% to see all the videos listed in that group. This feature should be available for all groups contained in the data.json file.

CSS / scrollbars / overflow

The CSS is not exactly how I want it. Ideally I don't want a scroll bar unless one is needed. Right now I'm sacrificing and there is one on the video search. When I fix this there will only be a scroll bar when there are search results large enough to overflow the main window.

Recently played videos

Currently the top 25 videos are taken for the recently played but the algorithm is not correct. The latest video need to be the first videos on the list rather than the last. This is currently screwing up the recently played list if you have the max number of videos already.

The last paragraph doesn't make a whole lot of sense. Videos are placed on the end of the recently played list. If the video is placed after the top 25 then it will be dropped. Videos that were just played need to be put on the top of the recently played list rather than the bottom.

Remove use of webview since it's no longer needed

So a bit of background here is needed. When I first started this I noticed a problem when playing some videos. Videos from VEVO were blocked from embedding locally since the HTTP referrer would be blank and apparently YouTube looks for that for at least VEVO videos to determine if playback is allowed.

I took some time to work on a patch to set the referrer for Electron's webview. This was great as I was using the embed URL for YouTube videos so it worked well for a while. Deep down I really wanted to use the YouTube API so that I could do more but had no way around setting a custom referrer as it used an iframe to attach the YT player to. So I side stepped it until recently.

Not even thinking about it I decided to just start using the YT API from a webview. Not even realizing that I already knew the referrer override wasn't going to work. That kind of forced me to take a look deep inside libchromiumcontent. So that is what I've been doing for a little over a week. While I don't have a way to expose overriding referrers on a larger scale than the webview provides to Electron (I'm working on just that) I do have a way to hard code it (unfortunately) but it allows me to continue work on Toby, play videos from VEVO and love life in the process!

So all that said I'm still using a webview to load in my page that uses the YT API to play videos. The use of the webview isn't needed anymore. However it'll take some effort to remove it as the design of the code will have to change to accomodate this.

This issue was created to remind me that I can remove the use of the webview later on.

Add notification when adding new video after pressing F5

A bit of background up front. At the end of video playback YouTube shows several other related videos. These videos can be watched by clicking on them. If you press F5 the video will be added to the local video data file so it can be watched again easily.

It would be nice to have a notification pop up after pressing the F5 key to add the new video so that the user gets feedback.

Allow users to add new videos to data.json from Toby (part 1)

Eventually I would like Toby to provide an interface to add new videos to the data.json. In lieu of that and to cover a use case that I had not previously thought about. I'm opening this issue as a first part to cover this feature.

The way the YouTube player works is that once you finish watching a video a series of new videos are listed that you can click on and watch. If you like any of these videos I want you to be able to add it to your data.json with just a press of a button. This way you'll have direct access to it later when searching through your videos.

Change window title for videos clicked on in YouTube player

After a video is played YouTube normally gives you a selection of other videos to play. When you click on one of these videos the titlebar should change. Currently Toby is not aware when a new video is clicked on from within the YouTube player.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.