From e84f275f42ee4dc0c78fd266c82e6849c799fe4e Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sat, 9 Apr 2022 01:18:12 +0200 Subject: [PATCH] Cambiato sistema di ricerca delle release - ora basate su DownloadPage. --- loaih/versions.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/loaih/versions.py b/loaih/versions.py index fa0d972..201e531 100644 --- a/loaih/versions.py +++ b/loaih/versions.py @@ -6,6 +6,7 @@ from lxml import etree from packaging.version import parse as parse_version class BuildVersion(object): + DOWNLOADPAGE = "https://www.libreoffice.org/download/download/" ARCHIVE = "https://downloadarchive.documentfoundation.org/libreoffice/old/" RELEASE = "https://download.documentfoundation.org/libreoffice/stable/" DAILY = "https://dev-builds.libreoffice.org/daily/master/Linux-rpm_deb-x86_64@tb87-TDF/" @@ -67,13 +68,23 @@ class BuildVersion(object): return { 'version': version, 'basedirurl': basedirurl } # Stable releases. - versions = etree.HTML(urllib.request.urlopen(BuildVersion.RELEASE).read()).xpath('//td/a') - index = 1 + # Old approach - Doesn't really work because RelEng can screw order. + #versions = etree.HTML(urllib.request.urlopen(BuildVersion.RELEASE).read()).xpath('//td/a') + #index = 1 + #if branch == 'still': + # index = -2 + #elif branch == 'fresh': + # index = -1 + #version = self.__getlatestrel(versions[index].text.strip('/')) + + # Now I'll rely on DownloadPage + versions = etree.HTML(urllib.request.urlopen(BuildVersion.DOWNLOADPAGE).read()).xpath('//span[@class="dl_version_number"]') + index = 0 if branch == 'still': - index = -2 + index = 1 elif branch == 'fresh': - index = -1 - version = self.__getlatestrel(versions[index].text.strip('/')) + index = 0 + version = self.__getlatestrel(versions[index].text) return { 'version': version, 'basedirurl': self.__getbaseurl(version) }