Page 1 of 2
please help creating an update script
Posted: November 8th, 2023, 6:38 pm
by Droyellis
hi all
I'm creating a python script on windows that will download the portable zip version and extract it to a neutral folder name (without version numbers), in place of the folder I have it running from.
I pretty much had everything working the way I wanted it until I realized the web link will always point to version 4.1.0
is there a weblink that will always point to the latest portable release?
Re: please help creating an update script
Posted: November 9th, 2023, 8:52 am
by sander
Do you use github, or sabnzbd.org?
On github:
https://github.com/sabnzbd/sabnzbd/releases/latest
which now will lead to
https://github.com/sabnzbd/sabnzbd/releases/tag/4.1.0
which contains the files.
Ah:
https://api.github.com/repos/sabnzbd/sa ... ses/latest is better / more technical, and gives what you want:
Code: Select all
$ lynx --dump https://api.github.com/repos/sabnzbd/sabnzbd/releases/latest | tr '"' '\n' | grep -i download | grep github
https://github.com/sabnzbd/sabnzbd/releases/download/4.1.0/README.mkd
https://github.com/sabnzbd/sabnzbd/releases/download/4.1.0/SABnzbd-4.1.0-osx.dmg
https://github.com/sabnzbd/sabnzbd/releases/download/4.1.0/SABnzbd-4.1.0-src.tar.gz
https://github.com/sabnzbd/sabnzbd/releases/download/4.1.0/SABnzbd-4.1.0-win-setup.exe
https://github.com/sabnzbd/sabnzbd/releases/download/4.1.0/SABnzbd-4.1.0-win32-bin.zip
https://github.com/sabnzbd/sabnzbd/releases/download/4.1.0/SABnzbd-4.1.0-win64-bin.zip
On
https://sabnzbd.org/downloads
Code: Select all
$ lynx --dump https://sabnzbd.org/downloads | grep /download/ | grep -vi -e alpha -e beta
20. https://github.com/sabnzbd/sabnzbd/releases/download/4.1.0/SABnzbd-4.1.0-win-setup.exe
21. https://github.com/sabnzbd/sabnzbd/releases/download/4.1.0/SABnzbd-4.1.0-win64-bin.zip
22. https://github.com/sabnzbd/sabnzbd/releases/download/4.1.0/SABnzbd-4.1.0-win32-bin.zip
23. https://github.com/sabnzbd/sabnzbd/releases/download/4.1.0/SABnzbd-4.1.0-osx.dmg
24. https://github.com/sabnzbd/sabnzbd/releases/download/4.1.0/SABnzbd-4.1.0-src.tar.gz
Re: please help creating an update script
Posted: November 9th, 2023, 4:18 pm
by Droyellis
this is the link i was using:
https://github.com/sabnzbd/sabnzbd/rele ... 64-bin.zip
so your first link takes me to the GitHub page where I'd need to somehow have the right zip file selected, and that zip file will always have a newer filename with the version number.
the better link you provided opens up a wall of text, I tried looking through the links but they all seem to point directly to version 4.1.0
I'm on windows so cant use grep

Re: please help creating an update script
Posted: November 9th, 2023, 4:29 pm
by safihre
On Windows it's a bit difficult.. All kind of magic possible with grep. But not sure how to do it on Windows.
Re: please help creating an update script
Posted: November 9th, 2023, 5:06 pm
by Droyellis
most linux distros would have a repo or an app image, so kinda pointless. would building self/auto update into sabnzbd be a possible thing? would running it from source be a better option? would i be able to script / automate the update process???
Re: please help creating an update script
Posted: November 9th, 2023, 6:04 pm
by sander
to me,
https://api.github.com/repos/sabnzbd/sa ... ses/latest looks like JSON.
So parse it as JSON!
A few lines op python3 code:
Code: Select all
import urllib.request, json
myurl = "https://api.github.com/repos/sabnzbd/sabnzbd/releases/latest"
with urllib.request.urlopen(myurl) as url:
data = json.load(url)
for j in data['assets']:
print(j["browser_download_url"])
which gives
Code: Select all
$ python3 bla2.py
https://github.com/sabnzbd/sabnzbd/releases/download/4.1.0/README.mkd
https://github.com/sabnzbd/sabnzbd/releases/download/4.1.0/SABnzbd-4.1.0-osx.dmg
https://github.com/sabnzbd/sabnzbd/releases/download/4.1.0/SABnzbd-4.1.0-src.tar.gz
https://github.com/sabnzbd/sabnzbd/releases/download/4.1.0/SABnzbd-4.1.0-win-setup.exe
https://github.com/sabnzbd/sabnzbd/releases/download/4.1.0/SABnzbd-4.1.0-win32-bin.zip
https://github.com/sabnzbd/sabnzbd/releases/download/4.1.0/SABnzbd-4.1.0-win64-bin.zip
... and there you have it. You want the win64-zbin.zip ... so get it!
Re: please help creating an update script
Posted: November 9th, 2023, 6:22 pm
by Droyellis
thanks heaps for that, its a good start. how would i automate the download of the latest win64-bin.zip regardless of listed version number?
Re: please help creating an update script
Posted: November 9th, 2023, 6:30 pm
by sander
Droyellis wrote: ↑November 9th, 2023, 6:22 pm
thanks heaps for that, its a good start. how would i automate the download of the latest win64-bin.zip regardless of listed version number?
In your OP you said "
I pretty much had everything working the way I wanted it until I realized the web link will always point to version 4.1.0", so I'm surprised by your question.
I'm not going to do all the work for you.
Re: please help creating an update script
Posted: November 9th, 2023, 8:48 pm
by Droyellis
and yet the new web link still points to version 4.1.0, we're still at square one.
I asked for help, you didn't have to... "help"
I understand that script will always parse the latest results, I'd still need code to process newer links with newer version numbers. I'll start figuring out how to use json, you don't have to help if you don't want to.
just so I know for sure tho, this is the general help section isn't it?
Re: please help creating an update script
Posted: November 10th, 2023, 12:02 am
by sander
Droyellis wrote: ↑November 9th, 2023, 8:48 pm
and yet the new web link still points to version 4.1.0, we're still at square one.
Oh? I thought you wanted the current version, which is version 4.1.0?
Re: please help creating an update script
Posted: November 10th, 2023, 1:01 am
by Droyellis
No I want a link in the script to always download the latest version. So that when 4.2 is released my script will update
Re: please help creating an update script
Posted: November 10th, 2023, 2:10 am
by sander
Droyellis wrote: ↑November 10th, 2023, 1:01 am
No I want a link in the script to always download the latest version. So that when 4.2 is released my script will update
And what do you think that
https://api.github.com/repos/sabnzbd/sa ... ses/latest will yield as soon as 4.2 is there?
Re: please help creating an update script
Posted: November 10th, 2023, 2:39 am
by Droyellis
A new WebLink with the number 4.2.0 in it, my script would still download version 4.1.0
Re: please help creating an update script
Posted: November 10th, 2023, 8:17 am
by sander
I see. Maybe you can wait until 4.2.0 appears, and then verify your hypothesis / assumption?
Re: please help creating an update script
Posted: November 10th, 2023, 2:34 pm
by Droyellis
https://github.com/sabnzbd/sabnzbd/rele ... 64-bin.zip
Have a good look at this link, and think about what it's going to download, compare it with previous versions if you like...
here's the exact same link for version 2.0.0
https://github.com/sabnzbd/sabnzbd/rele ... 64-bin.zip
it still downloads version 2.0.0