Files
endoflife-date-release-data/src/firefox.py
Nemo d3723a2c5e [firefox] Fetch first 200 versions (#508)
* [firefox] Fetch first 200 versions

115 ESR does not get picked up otherwise.

Ref: https://github.com/endoflife-date/endoflife.date/issues/8324

* 🤖: coder, firefox

coder:
- Item root['versions']['2.24.4'] ({'name': '2.24.4', 'date': '2025-09-04'}) added to dictionary.

firefox:
- Item root['versions']['115.27.0'] ({'name': '115.27.0', 'date': '2025-08-19'}) added to dictionary.
- Item root['versions']['115.26.0'] ({'name': '115.26.0', 'date': '2025-07-22'}) added to dictionary.
- Item root['versions']['115.25.0'] ({'name': '115.25.0', 'date': '2025-06-24'}) added to dictionary.
- Item root['versions']['115.24.0'] ({'name': '115.24.0', 'date': '2025-05-27'}) added to dictionary.
- Item root['versions']['115.23.1'] ({'name': '115.23.1', 'date': '2025-05-17'}) added to dictionary.

* Increase MAX_VERSIONS_LIMIT from 200 to 250

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-09-04 12:03:27 +05:30

36 lines
1.7 KiB
Python

import urllib.parse
from bs4 import BeautifulSoup
from common import dates, http
from common.releasedata import ProductData, config_from_argv
"""Fetch Firefox versions with their dates from https://www.mozilla.org/.
This script is cumulative: previously found versions are kept, and eventually updated if needed. It only considers the
first MAX_VERSIONS_COUNT versions on Firefox release page because:
- it is too long to fetch them all (at least a minute usually),
- this generates too many requests to the mozilla.org servers,
- and anyway oldest versions are never updated.
Note that it was assumed that:
- the script is ran regularly enough to keep the versions up to date (once a day or week looks enough),
- the versions are listed in descending order on the page,
- new versions are always added inside in the last MAX_VERSIONS_COUNT versions.
The script will need to be updated if someday those conditions are not met."""
MAX_VERSIONS_LIMIT = 250
config = config_from_argv()
with ProductData(config.product) as product_data:
releases_page = http.fetch_url(config.url)
releases_soup = BeautifulSoup(releases_page.text, features="html5lib")
releases_list = releases_soup.find_all("ol", class_="c-release-list")
release_notes_urls = [urllib.parse.urljoin(releases_page.url, p.get("href")) for p in releases_list[0].find_all("a")]
for release_notes in http.fetch_urls(release_notes_urls[:MAX_VERSIONS_LIMIT]):
version = release_notes.url.split("/")[-3]
release_notes_soup = BeautifulSoup(release_notes.text, features="html5lib")
date_str = release_notes_soup.find(class_="c-release-date").get_text() # note: only works for versions > 25
product_data.declare_version(version, dates.parse_date(date_str))