Skip to content

Commit

Permalink
Debian
Browse files Browse the repository at this point in the history
  • Loading branch information
xavivars committed Oct 10, 2023
1 parent 6bbc4e7 commit def6855
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
34 changes: 34 additions & 0 deletions debian/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from cachetools import cached, TTLCache

from utils import download_data, add_program, get_eol_date

add_program("debian", 'debian', 'debian')


@cached(cache=TTLCache(maxsize=10, ttl=300))
def get():

d = get_eol_date('debian')

version = d['latest']

return [
download_data(
'Live CD',
url=f"https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/debian-live-{version}.0-amd64-gnome.iso",
os='linux',
get_size=True
),
download_data(
'DVD',
url=f"https://cdimage.debian.org/debian-cd/current/amd64/iso-dvd/debian-{version}.0-amd64-DVD-1.iso",
os='linux',
get_size=True
),
download_data(
'CD',
url=f"https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-{version}.0-amd64-netinst.iso",
os='linux',
get_size=True
)
]
10 changes: 10 additions & 0 deletions handler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from flask import Flask, jsonify

import calibre
import debian
import notepadplusplus
import sevenzip
import tor
Expand Down Expand Up @@ -158,6 +159,15 @@ def sevenzip_route():
return "NoData", 404


@app.route("/debian")
def debian_route():
r = debian.get()
if r is not None:
return __jsonify(r)
else:
return "NoData", 404


def __jsonify(r):
r = sorted(r, key=lambda x: x['download_os'], reverse=True)
return jsonify(r)
Expand Down
12 changes: 11 additions & 1 deletion utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,14 @@ def add_program(group, api, wp):


def get_all_programs():
return programs
return programs


def get_eol_date(program):
url = f'https://endoflife.date/api/{program}.json'

r = requests.get(url)

js = r.json()

return js[0]

0 comments on commit def6855

Please sign in to comment.