Youtube Queuer Update – 23.02.2017

Hello, today I’m giving a little update on what I’ve implemented in my Youtube Queuer project. The changeset isn’t very huge and consists mostly of improvements for easier future development.

Changes summary

First and most important, I’ve setup a dependency injection container, namely Autofac. I’ve decided to use it as this is the container I am the most familiar with. I was using it in my previous job, so I wanted to keep up to date with usage of this library.

I have also refined classes structure and their visibility. All of the service class in the YoutubeQueuer.Lib are now internal and only the interfaces are public. This way, I’ve enforced dependency injection, because the web component can’t just instantiate the classes themselves, as it was the case before. The code is now cleaner.

In the previous post about my project, I’ve talked about Google authorization. It was a simple, but working solution. At that point, the controller had to call the authorization method by itself:

2017-02-23 19_59_08-youtube-auto-queuer_HomeController.cs at 91c2640d76501dc5952c65b0ded570418886d0b.png
(source here)

Using such a workflow in just one place isn’t problematic, but I’ve started to create also other views, such as playlists and subscriptions views. Repeating this code in these places would be no good. So, following Ploeh’s advice, I’ve implemented the passive attribute pattern for the authorization process. The solution consists of two parts: an attribute applied to a method or controller and an action filter, which handles the authorization itself. With that, I just decorate the controller method with an attribute, like this:

2017-02-23 20_07_33-youtube-auto-queuer_PlaylistsController.cs at master · Jankowski-J_youtube-auto-.png
(source here)

And the authorization is handled in a declarative way, without controller explicitly knowing how to do the authorization. It has to know where to store the credential (for now it’s in session state), but it seems to me a better solution than having a service dependency in the controller.

If you are interested in the implementation details, the last commit with relevent changes is right there. I couldn’t make the GitHub see tag created by me in Git, so I added at least this.



Most of the changes right now were technical ones, but needed in order to keep my project tidy (and me sane dealing with in the long term).

That’s it for now, see you next time!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s