aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan <me@jordan.im>2020-04-05 23:45:39 -0700
committerJordan <me@jordan.im>2020-04-05 23:45:39 -0700
commit5d2827f8ba1f2ebeaef347fd7dd62f2de845cf99 (patch)
tree2af65da2db6c4cf20ba5444ba74ad1e0261727a0
parent73b0587f756b226448dde79c6550ce269316446a (diff)
downloadroka-5d2827f8ba1f2ebeaef347fd7dd62f2de845cf99.tar.gz
roka-5d2827f8ba1f2ebeaef347fd7dd62f2de845cf99.zip
sort listing by title, demo link
-rw-r--r--README2
-rwxr-xr-xrun.py9
2 files changed, 10 insertions, 1 deletions
diff --git a/README b/README
index 9621ec1..c870e4e 100644
--- a/README
+++ b/README
@@ -1,5 +1,7 @@
audiobook-rss: stream directory of audiobooks to podcasting apps via RSS
+demo (no audio): https://demo.jordan.im/audiobook-rss/
+
installation
------------
diff --git a/run.py b/run.py
index 095c9ab..f2899f4 100755
--- a/run.py
+++ b/run.py
@@ -5,6 +5,8 @@ import mimetypes
import os
import re
import xml.etree.cElementTree as ET
+from collections import OrderedDict
+from operator import getitem
from datetime import date, timedelta
from flask import Flask, request, Response, render_template, send_file
@@ -14,11 +16,16 @@ app.config.from_pyfile(os.path.join(abs_path, 'app.cfg'))
cache_path = os.path.join(abs_path, 'cache')
json_path = os.path.join(cache_path, 'audiobooks.json')
-# populate books object from JSON cache
+# populate books object from JSON cache sorted by title
if os.path.exists(json_path):
try:
with open(json_path, 'r') as cache:
books = json.load(cache)
+ books = OrderedDict(sorted(
+ books.items(),
+ key=lambda x: x[1]['title']
+ ))
+
except Exception:
raise ValueError('error loading JSON cache')
else: