mccxiv / tc

A desktop chat client for Twitch
ISC License
188 stars 17 forks source link

Forced source quality for livestreamer, and executed twice? #319

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hello Tc devs. In issue #272 livestreamer default quality is now defined in the user settings, or else it resolves to 'best'. However, there is no default 'quality' or 'livestreamer' key in users.json (or in the settings menu in Tc itself) nor is any mention on how to add it manually.

The commit in question is 7e7a388 (file thumbnail.js). I admit I don't have any JS, electron or node knowledge, but for what I can see, there is no settings lookup for 'quality' in that file. Line 55 sets stream 'type' parameter to 'audio' or an empty string, and if the latter happens, livestreamer is executed without a quality parameter (as expected in line 65 when it then searches for 'Available streams' in livestreamer output). After this, another livestreamer process is executed, manually resolving to 'best' quality (this is always the case)

Aside from not being able to set a custom quality, I think the bigger problem is running livestreamer twice for no apparent reason, being a Python program and the fact that it does a few api calls to twitch, this adds quite a few seconds before you can actually start watching any stream.

Like I said before I'm no JS dev so maybe I got it all wrong, I apologize if that's the case. Thanks.

mccxiv commented 7 years ago

Hi @arielhr

I can explain. Let's look at the current version for reference.

Line 57 calls the function with either audio or empty string.

Line 61 executes Livestreamer with the above quality. Here's where the magic happens... If the user has a default quality in his local livestreamer settings, the default quality will be used. Otherwise Livestreamer will spit out a list of possible qualities. Line 65 checks for this case and executes it again, defaulting to best.

So in short, if you have a config file it should only execute once, otherwise it will run twice.

I'm open to suggestions if there's a way to do this in one go

mccxiv commented 7 years ago

To clarify... it's done this way so that we don't need to actually read (and most importantly, find) the config file, it's just a lot simpler and more robust this way even though it's slower to open

ghost commented 7 years ago

Ah, it was Livestreamer's config file, not Tc's one! Now it all makes sense. Sorry for opening the issue then, and thanks for the explanation.