doonze / EmbyUpdate

A python script for automatically updating Emby to the latest version on Linux distros.
GNU Lesser General Public License v3.0
15 stars 3 forks source link

Beta Releases #1

Closed wibuf closed 5 years ago

wibuf commented 5 years ago

Any chance of adding an option for beta releases?

doonze commented 5 years ago

Wow, I just realized I don't get notifications from github. So sorry for the slow response. While I SHOULD be able to do that, in practice I wasn't able to get that to work with python. Originally i wrote this as a bash script, and I could phrase the json fine with that, was even able to pull out the links with no issues. But I was having issues with other parts of the script. So I switched to python.

However I was never able to correctly search within the json with python. I can pull the latest version number, and that's about it. I can't pull the latest beta version, due to the way github does it's json. I may revisit this, but for now I can't.

wibuf commented 5 years ago

No problem, I just started a topic on the emby feature requests forum page to see if they could add a beta releases api path on github.

https://emby.media/community/index.php?/topic/66211-emby-beta-releases-github-api-path/

wibuf commented 5 years ago

doonze, can you use this to do beta releases?

https://api.github.com/repos/mediabrowser/Emby.releases/releases

doonze commented 5 years ago

Yes, I got it working after I replied. Mainly my problem was due to how pythons built in json reader works. If the first level of json is nestled it makes a list of dictionaries, instead of a dictionary of dictionaries. The latest release json doesn't have it's main json nestled, so it works as I was expecting. However, the beta one is nestled in it's first level, so I have to read it like a list, THEN read the dictionary from the list.

Tonight I'm going to write up a working beta updater. But I'm also going to play with a better way to do this all around.

There also may be some other weird issues with pythons json reader. I was getting weird results, mainly just a link to their api wiki. I pulled the json with curl on the beta API just to verify I could, then all of a sudden python could pull it also. I'm wondering if it wasn't liking the python request till my IP pulled it from curl. Doesn't make a lot of sense, but that's what happened it seems. If I verify that's true, I may have to play with this more.

I would have rather used curl, but I didn't want to force someone to install curl to use the updater. But it's still on the table.

doonze commented 5 years ago

Well, I just rolled version 1.1 that has beta installs as an option. Mainly I dropped pulling the releases from /latest and pull instead from the master list at /releases. That exposed the beta versions, called pre-release in github language. I figured out pythons list of dictionaries puts whatever the most recent release is (beta or stable) in index position 0, and moves the previous release to index position 1. So on and so forth.

There were about 10 ways to skin this cat. But due to the, in my opinion, silly way github structures their API json, and the way the Emby devs decided to use the release system, the simplest and most straight forward way to get the latest versions is to search through the python array until if finds the very first beta or stable version (depending on what you set it to look for). Once it finds it, it stops and saves that version. It will always be the most recent of it's flavor (beta or stable).

Just to explain here. Say you have it set to install stable versions. The last stable version is in index position 5 currently. Index positions 0-4 are beta's (pre-release). So if you have it set to stable, it searches through indexes 0-4 and discards them as they are not stable. It then gets to index 5 and since it's stable it saves that version # and installs it.

If Luke decides tomorrow to release a new stable version, it will go into index 0, and the current beta will move to index 1. So in that case stable install will find it in the first index and install it without even bothering looking deeper.

Make sense?

Beta is untested, as I don't run beta and don't want to. But there is no reason it won't work fine. I've tested stable and it's working perfectly as expected with the new code and logic.

wibuf commented 5 years ago

Thanks doonze! I'll be testing this out today.

doonze commented 5 years ago

No problem! Glad I was able to get that done for you. It was fun and informative. And it made it a better app!

On Wed, Dec 12, 2018 at 11:01 AM wibuf notifications@github.com wrote:

Thanks doonze!

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/doonze/EmbyUpdate/issues/1#issuecomment-446663072, or mute the thread https://github.com/notifications/unsubscribe-auth/AXwT27uIyAeLPPZceV7a9ugVhqXSrk-nks5u4TZugaJpZM4XTus_ .