BoboTiG / pep-epub

[Unofficial] Python PEP in EPUB format
11 stars 1 forks source link

Single epub #7

Open irismessage opened 2 years ago

irismessage commented 2 years ago

It would be helpful to have every pep packaged in a single epub with working links to one another - like what's provided at https://docs.python.org/3.10/download.html

Upvote & Fund

Fund with Polar

irismessage commented 2 years ago

I found a way to combine them in calibre with the epupmerge plugin, but it would be useful to have Series metadata on each one for sorting

BoboTiG commented 2 years ago

I'm not familiar with series metadata, and I'm not against such features.

I'm open for pull requests, if you wanted to give a try :)

irismessage commented 2 years ago

I found this https://github.com/kovidgoyal/calibre/blob/master/src/calibre/ebooks/metadata/opf2.py to use as a reference for metadata keys, then I started doing this:

@@ -6,11 +6,14 @@ convert() {
     local pep
     local output
     local title
+    local date

     file="$1"
     output="$(echo "${file}" | sed s'#.rst$#.epub# ; s#.txt$#.epub#')"
     pep="$(head -1 "${file}")"
     title="$(head -2 "${file}" | tail -1 | sed 's/Title: // ; s/"/\"/g')"
+    date="$(grep "Created:" "${file}"| sed 's/Created: // ; s/"/\"/g')"
+    date="$(date --date=${date} '+%Y-%m-%d')"

     echo ">>> Processing ${pep} (${title}) ..."
     pandoc \
@@ -23,6 +26,7 @@ convert() {
         --metadata="creator:Python" \
         --metadata="language:en" \
         --metadata="title:${pep} (${title})" \
+        --metadata="date:${date}" \
         --output="../peps_epub/${output}" \
         "${file}"
 }

to sort by publishing date, however I then found this https://github.com/python/peps/pull/1995 which is probably a more efficient route than using pandoc

BoboTiG commented 2 months ago

I implemented your idea of using the date in 2b8239599434df71da8c9e64aca0c6e280fd8eb6 and updated all ePUB in c4d9d5017e4950c689b0aa502b992e0ec9bc6f21. Thank you for the idea :)