From e92870d42beaa1a01ab48a60cb322efa95e399bc Mon Sep 17 00:00:00 2001 From: Dylan Garrett Date: Sun, 6 Jun 2021 15:12:58 -0700 Subject: Some hacks. But generates some static rss feeds --- lib/util.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib/util.py') diff --git a/lib/util.py b/lib/util.py index a2f982d..4a884af 100644 --- a/lib/util.py +++ b/lib/util.py @@ -78,9 +78,7 @@ def escape(s): return s -def generate_rss(request, books): - book = request.args.get('a') # audiobook hash - +def generate_rss(base_url, book, books, static=False): # we only make use of the itunes ns, others provided for posterity namespaces = { 'itunes':'http://www.itunes.com/dtds/podcast-1.0.dtd', @@ -156,8 +154,9 @@ def generate_rss(request, books): pub_format = '%a, %d %b %Y %H:%M:%S %z' pub_date.text = (date(2000, 12, 31) - timedelta(days=idx)).strftime( pub_format) + url_format = '{}{}/{}.mp3' if static else '{}?a={}&f={}' enc_attr = { - 'url': '{}?a={}&f={}'.format(request.base_url, book, f), + 'url': url_format.format(base_url, book, f), 'length': str(books[book]['files'][f]['size_bytes']), 'type': 'audio/mpeg' } -- cgit v1.2.3-54-g00ecf From a262d5da79d4140fa866f885481ffcad2c33bb93 Mon Sep 17 00:00:00 2001 From: Dylan Garrett Date: Mon, 7 Jun 2021 07:58:48 -0700 Subject: Fix sort --- lib/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/util.py') diff --git a/lib/util.py b/lib/util.py index 4a884af..4693ef1 100644 --- a/lib/util.py +++ b/lib/util.py @@ -119,7 +119,7 @@ def generate_rss(base_url, book, books, static=False): track_list.append(track) else: # we have populated and unique track values, use those - key = lambda x: books[book]['files'][x]['track'] + key = lambda x: int(books[book]['files'][x]['track']) # populate XML attribute values required by Apple podcasts for idx, f in enumerate(sorted(books[book]['files'], key=key)): -- cgit v1.2.3-54-g00ecf